Hi all, I'm trying to generate a pie chart to use in my django web app. But it keeps rendering in a rectanuglar canvas instead of a square one, so the pie is oblong instead of circular. It also keeps rendering with a grey background, I need the background to be white.
I've attached a jpg of the chart - here is my source. def chart(request): from PIL import Image as PILImage from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from StringIO import StringIO fig = Figure() canvas = FigureCanvas(fig) ax = fig.add_subplot(111) #ax.plot([1,2,3]) labels = 'Frogs', 'Hogs', 'Dogs', 'Logs' fracs = [15,30,45, 10] ax.pie(fracs, labels=labels, shadow=True) #ax.set_title('hi mom') ax.grid(True) #ax.set_xlabel('time') #ax.set_ylabel('volts') canvas.draw() size = canvas.get_renderer().get_canvas_width_height() buf=canvas.tostring_rgb() im=PILImage.fromstring('RGB', size, buf, 'raw', 'RGB', 0, 1) imdata=StringIO() im.save(imdata, format='JPEG') response = HttpResponse(imdata.getvalue(), mimetype='image/jpeg') return response Also - can I choose my own colors for the slices? Thanks! Erik
<<attachment: chart.jpg>>
------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users