Reputation: 10138
How to set one to red and second to blue?
import pygal
chart = pygal.Line()
chart.x_labels = range(5)
chart.add('one', [1, None, 3, None, 5])
chart.add('two', range(5))
chart.render_to_png(__file__ + '-linear.png')
Upvotes: 3
Views: 2509
Reputation: 2767
You can add custom styles as follows.
from pygal.style import Style
yourCustomStyle = Style(
...
colors=['#hex_color1', '#hex_color2', ...],
...
)
yourChart = pygal.Line(style=yourCustomStyle)
yourChart.add('Series1', [value1, value2, value3, ...])
yourChart.add('Series2', [value1, value2, value3, ...])
...
yourChart.render()
You have many styling options to change colors, font-size, font-family, background, transparency etc... Check official documentation here
By the time I'm posting this, there is a mistake in the doc though. They have provided tuple of colors rather that a list, for colors
option in their example. You have to use a list[]
for adding colors in your custom styles.
Upvotes: 0
Reputation: 1168
You can use Pygal's Custom Styles to define specific colors for the series that you are loading. The only drawback is that the colors are assigned based on series order, so in your case you should set the colors parameter to ('red','blue')
so that they match your serie order.
Upvotes: 1