I am using python Pychart. I have done the following code to generate pie chart:
from pychart import *
import sys
data = [("foo", 10),("bar", 20), ("baz", 30), ("ao", 40)]
theme.get_options()
ar = area.T(size=(150,150), legend=legend.T(),
x_grid_style = None, y_grid_style = None)
plot = pie_plot.T(data=data, arc_offsets=[0,0,0,0],
shadow = (0, 0, fill_style.gray50),
label_offset = 25,
arrow_style = arrow.a3)
ar.add_plot(plot)
ar.draw()
It generates the pie chart with gray scale. Instead of gray-scale, I want different colors in pie chart. How can I do that?
Add theme.use_color = True
before the call to get_options().
For the theme documentation:
use_color
The default value of this variable is False. If the value is True, PyChart colorizes some of the default objects. If the value is False, PyChart uses gray scale for the color of these objects.
Looks like pychart haven't been updated since 2006, I would recommend that you have a look at matplotlib , perhaps the best plotting library for python.
Pie-chart example here
You have to specify the filling colors with the fill_styles
argument (len of this list should be the same as the data length):
from pychart import *
import sys
data = [("foo", 10),("bar", 20), ("baz", 30), ("ao", 40)]
theme.get_options()
ar = area.T(size=(150,150), legend=legend.T(),
x_grid_style = None, y_grid_style = None)
plot = pie_plot.T(data=data, arc_offsets=[0,0,0,0],
fill_styles = [fill_style.red, fill_style.blue, fill_style.green, fill_style.yellow],
shadow = (0, 0, fill_style.gray50),
label_offset = 25,
arrow_style = arrow.a3)
ar.add_plot(plot)
ar.draw()
and it will work in colors:)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.