|
From: Joe K. <jof...@gm...> - 2014-09-16 11:45:28
|
A quick way to do this is ``ax.invert_yaxis()`` (and invert_xaxis() for the x-axis). That way you preserve auto-scaling and don't wind up with manually set axis limits. What you did should have worked, but ``ymin`` and ``ymax`` are probably datetime objects. ``ylim`` isn't smart enough to convert them to the datetime units that matplotlib uses internally. Hope that helps! -Joe On Tue, Sep 16, 2014 at 4:00 AM, Gerd Wellenreuther < Ger...@xf...> wrote: > Dear all, > > I hope some of you could help me out. I am currently trying to generate > some timetables using matplotlib.pyplot.plot_date, having the time-axis > on the y-axis. Typically, one would like to read these plots from top to > bottom, from older to newer items (future on the bottom). Unfortunately, > the default enumeration of the y-axis is the other way around, and it > resists my attempts to invert its direction e.g. by changing limits > using matplotlib.pyplot.ylim (Traceback below). I found a quite old > entry in stackoverflow which is most probably outdated, at least the > proposed solution did not work for me... > ( > http://stackoverflow.com/questions/5804969/displaying-an-inverted-vertical-date-axis > ). > > Since the longish traceback seems to try to tell me I did not understand > some kind of important - even trivial - point about those datetime-axis > maybe some of you came about this problem before? > > Thanks, Gerd > > P.S.: Traceback after trying to use something like > "matplotlib.pyplot.ylim(ymax,ymin)": > > Traceback (most recent call last): > > File "C:\Users\gwellenr\Desktop\Test_Sabine\Plot_csv.py", line 187, > > in <module> > > matplotlib.pyplot.savefig(save_path+'test.png') > > File "C:\Python27\lib\site-packages\matplotlib\pyplot.py", line 561, > > in savefig > > return fig.savefig(*args, **kwargs) > > File "C:\Python27\lib\site-packages\matplotlib\figure.py", line > > 1421, in savefig > > self.canvas.print_figure(*args, **kwargs) > > File "C:\Python27\lib\site-packages\matplotlib\backend_bases.py", > > line 2220, in print_figure > > **kwargs) > > File > > "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", > > line 505, in print_png > > FigureCanvasAgg.draw(self) > > File > > "C:\Python27\lib\site-packages\matplotlib\backends\backend_agg.py", > > line 451, in draw > > self.figure.draw(self.renderer) > > File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, > > in draw_wrapper > > draw(artist, renderer, *args, **kwargs) > > File "C:\Python27\lib\site-packages\matplotlib\figure.py", line > > 1034, in draw > > func(*args) > > File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, > > in draw_wrapper > > draw(artist, renderer, *args, **kwargs) > > File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 2086, > > in draw > > a.draw(renderer) > > File "C:\Python27\lib\site-packages\matplotlib\artist.py", line 55, > > in draw_wrapper > > draw(artist, renderer, *args, **kwargs) > > File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 1091, > > in draw > > ticks_to_draw = self._update_ticks(renderer) > > File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 945, > > in _update_ticks > > tick_tups = [t for t in self.iter_ticks()] > > File "C:\Python27\lib\site-packages\matplotlib\axis.py", line 889, > > in iter_ticks > > majorLocs = self.major.locator() > > File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 802, > > in __call__ > > self.refresh() > > File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 820, > > in refresh > > self._locator = self.get_locator(dmin, dmax) > > File "C:\Python27\lib\site-packages\matplotlib\dates.py", line 896, > > in get_locator > > raise ValueError('No sensible date limit could be found in the ' > > ValueError: No sensible date limit could be found in the AutoDateLocator. > > > > ------------------------------------------------------------------------------ > Want excitement? > Manually upgrade your production database. > When you want reliability, choose Perforce. > Perforce version control. Predictably reliable. > > http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |