On Thu, Aug 19, 2010 at 6:49 AM, Rob Schneider <rmsc...@rmschneider.com>wrote:
> > On Wed, Aug 18, 2010 at 3:32 PM, Friedrich Romstedt > > <friedrichromst...@gmail.com> wrote: > >> 2010/8/14 Rob Schneider <rmsc...@rmschneider.com>: > >>>> Agreed. The only thing I can think of is that the second figure is > >>>> reusing the first. You can try calling plt.figure() at the beginning > >>>> of the functions to create a new figure, or call plt.figure() in > >>>> between the calls to CreateMemberStatCategoryFigure() and > >>>> CreateMemberStatFigure(). I can't be sure since you didn't include the > >>>> code that actually calls these functions. > >> > >> Still, there shouldn't be artists rendered outside of the axes. I > >> often replot things and do not create a new figure. I believe there > >> is something under the hood! It *should* be unnecessary to create a > >> new fig, although it surely fixes the thing, and is an easy enough > >> fix. > > > > One bar chart was categorical, the other based on dates. That threw > > the axes scaling completely off. There weren't any misdrawn artists, > > unless you're referring to the jumble of text. These are actually > > tightly packed ticklabels for x-axis. Since the scaling is fubar-ed, > > it looks messed up. > > > > Not sure what could be reasonably expected in such a case. > > > > Ryan > > > > -- > > Ryan May > > Graduate Research Assistant > > School of Meteorology > > University of Oklahoma > > > > I think the graphs were composed correctly, else why would they ever work? > They were fixed by calling the figure() and close() functions. i'm > reporting that to the list with the hope that others can value from it. > > > Just to add my 2 cents... In python, explicit is preferred over implicit. So, it would be a good idea to call figure() or any other figure-handling function when you mean to use them. However, because we strive to cater to those who come from Matlab, we need to make matplotlib a little bit more robust and allow it to implicitly make assumptions when the programmer does not explicitly state their intentions. So, while the following code example works just fine: from pylab import * > scatter([0.0, 0.5, 2.4, 1.2], [1.4, 0.7, 2.1, 0.3]) > title("This is a scatter plot") > show() > The "better", more robust way would be this: import matplotlib.pyplot as plt > fig = plt.figure() > ax = fig.gca() > ax.scatter([0.0, 0.5, 2.4, 1.2], [1.4, 0.7, 2.1, 0.3]) > ax.set_title("This is a scatter plot") > plt.show() > This way, you explicitly state that you want to do a particular action on a particular axes that belongs in a particular figure. With this approach, you can make functions that take a 'ax' parameter and make specialty graphs on whatever axes you tell it. You can have multiple figures made simultaneously with multiple axes (think subplots) and be able to open and close whichever ones you want whenever you like. In the documentation, you see a variety of styles because of this flexibility. Whether this is wise or not, that is probably a different question. I hope this clears up any confusion you and other future matplotlib-ers have! I hope you continue to use and enjoy matplotlib! Ben Root
------------------------------------------------------------------------------ This SF.net email is sponsored by Make an app they can't live without Enter the BlackBerry Developer Challenge http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users