Thanks Eric!

Some followup questions.

-Can I give it more of a 3d look?  Like the pie charts in MS Word?

-How can I reduce the size of the canvas behind the chart?  There is a
lot of empty whitespace and I need to tighten up the margins as the
graph will be displayed inline on an html page...

-for the colors, do I use numbers to customize the colors, or do I
have to use colors from a built in pallet?

-lastly - is it possible to print the labels inside each slice of the
chart, instead of outside?

Thanks!
Erik


On 6/3/07, Eric Firing <[EMAIL PROTECTED]> wrote:
> Forgot "reply-to-all".
>
> Eric
>
>
> ---------- Forwarded message ----------
> From: Eric Firing <[EMAIL PROTECTED]>
> To: Erik Wickstrom <[EMAIL PROTECTED]>
> Date: Sun, 03 Jun 2007 16:19:20 -1000
> Subject: Re: [Matplotlib-users] Pie chart is "stretched"
> Erik Wickstrom wrote:
> > 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
> see inserted call to set_aspect method, below.
> > the pie is oblong instead of circular.  It also keeps rendering with a
> > grey background, I need the background to be white.
> see inserted call to set_facecolor method, below.
> >
> > I've attached a jpg of the chart - here is my source.
> Do you really want jpeg? It is suitable for photos, but very inefficient
> (and a bit fuzzy) for things like pie charts.  I would use png format
> instead, which is efficient for this sort of plot.
>
> >
> > 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_aspect('equal', adjustable='box')
>       fig.set_facecolor('w')
>
> >    #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?
>
> Yes, use the "colors" kwarg to specify your own list.  From the docstring:
>
>      PIE(x, explode=None, labels=None,
>          colors=('b', 'g', 'r', 'c', 'm', 'y', 'k', 'w'),
>          autopct=None, pctdistance=0.6, shadow=False)
>
> Eric
>
>
> -------------------------------------------------------------------------
> 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
>
>

-------------------------------------------------------------------------
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

Reply via email to