[Matplotlib-users] How to draw a specific country by basemap?
Hi all, I'm using the Basemap module in matplotlib, it's great to draw a world map but for a specific country. Empirically, one can draw its own country by specifying the lats and longs like this example: http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html And you can use the method: drawcontries() to draw the country boundries, but all the countries are in the same colour. Does anyone know how to highlight a specific country? Thanks in advance. Eric -- -BEGIN GEEK CODE BLOCK- Version: 3.1 GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+++ L++ E++ W++ N+ o+++ K+++ w !O M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+* tv@ b DI-- D G++ e+@ h* r !y+ --END GEEK CODE BLOCK-- -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Zooming into plots?
Hi there: Does matplotlib have provide any feature to allow zooming into plot regions like a waveform viewer does? regards, Soumyaroop -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colorbar+log+latex
Hi All, Thanks a bunch for your help! Eric: your suggestion works brilliantly ( I didn't use the interpolation kwarg though because I like the 'smudged' look). Paul: thanks for your suggestions but I get errors when trying to execute * cbar.set_ticks(np.linspace(300,350,6))*. The c.bar.set_ticks option doesn't seem to exist.. All I now need to figure out is how to get the log scale ticklabels to show for a different imshow plot... cheers! Shrividya -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] How to draw a specific country by basemap?
Hi, An easy way is to use the data from http://www.gadm.org/ and to plot it with m.readshapefile() HTH, Thom ** Thomas Lecocq Geologist Ph.D.Student (Seismology) Royal Observatory of Belgium ** Date: Wed, 26 Jan 2011 16:03:27 +0800 From: eric.l.2...@gmail.com To: matplotlib-users@lists.sourceforge.net Subject: [Matplotlib-users] How to draw a specific country by basemap? Hi all, I'm using the Basemap module in matplotlib, it's great to draw a world map but for a specific country. Empirically, one can draw its own country by specifying the lats and longs like this example: http://matplotlib.sourceforge.net/basemap/doc/html/users/geography.html And you can use the method: drawcontries() to draw the country boundries, but all the countries are in the same colour. Does anyone know how to highlight a specific country? Thanks in advance. Eric -- -BEGIN GEEK CODE BLOCK- Version: 3.1 GCM/CS/E/MU/P d+(-) s: a- C++ UL$ P+++ L++ E++ W++ N+ o+++ K+++ w !O M-(+) V-- PS+ PE+ Y+ PGP++ t? 5? X? R+* tv@ b DI-- D G++ e+@ h* r !y+ --END GEEK CODE BLOCK-- -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] too many values to unpack with a bar chart
I usually do this for line graphs with markers: line, = self.subplot.plot_date(dates,data) along with some keywords to tweak the plot. I then add line to a dictionary to keep track of it: self.line_to_data_dict[line] = self.activity But today I tried this with a bar chart, just changing plot_date to bar and renaming the line, to bars,: fake_data = [2,2,5] bars, = self.subplot.bar(fake_data, fake_data ) This gave me the error: ValueError: too many values to unpack. OK, so if I removed the comma from bars, so it is just bars, it goes through but then I cannot add it to my dictionary--I get: TypeError: list objects are unhashable Help in understanding this and a better approach would be helpful. Thanks, Che -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Bug in dviread?
Hello to all, using a standard python install on Ubuntu 10.04 the example fails to produce a figure. Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] on linux2 Type help, copyright, credits or license for more information. import matplotlib matplotlib.__version__ '0.99.1.1' Test case in python: from numpy import sin, cos import matplotlib import matplotlib.pyplot as plt plt.matplotlib.rc('text', usetex = True) import pylab fig = plt.figure() ax = fig.add_subplot(111) t = pylab.linspace(0,10,400) ax.plot(t, sin(3*t), '-', t, sin(0.3*t**2), '--', t, cos(t), '-.') ax.legend((r'$A^{\omega}$', r'$A^{2\omega}$', r'$A^{3\omega}$'), shadow = False, loc = (0.75, 0.1)) ax.set_xlabel(r'$\gamma_1 + \gamma_2$', {'fontsize' : 20 }) ax.set_ylabel(r'$A^{n\omega}$ (dB)', {'fontsize' : 20 }) fig.savefig(filename='test.pdf') This leads to the following traceback: Traceback (most recent call last): File test.py, line 18, in module fig.savefig(filename='test.pdf') File /usr/lib/pymodules/python2.6/matplotlib/figure.py, line 1032, in savefig self.canvas.print_figure(*args, **kwargs) File /usr/lib/pymodules/python2.6/matplotlib/backend_bases.py, line 1476, in print_figure **kwargs) File /usr/lib/pymodules/python2.6/matplotlib/backend_bases.py, line 1334, in print_pdf return pdf.print_pdf(*args, **kwargs) File /usr/lib/pymodules/python2.6/matplotlib/backends/backend_pdf.py, line 2025, in print_pdf self.figure.draw(renderer) File /usr/lib/pymodules/python2.6/matplotlib/artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File /usr/lib/pymodules/python2.6/matplotlib/figure.py, line 773, in draw for a in self.axes: a.draw(renderer) File /usr/lib/pymodules/python2.6/matplotlib/artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File /usr/lib/pymodules/python2.6/matplotlib/axes.py, line 1735, in draw a.draw(renderer) File /usr/lib/pymodules/python2.6/matplotlib/artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File /usr/lib/pymodules/python2.6/matplotlib/axis.py, line 742, in draw tick.draw(renderer) File /usr/lib/pymodules/python2.6/matplotlib/artist.py, line 46, in draw_wrapper draw(artist, renderer, *kl) File /usr/lib/pymodules/python2.6/matplotlib/axis.py, line 196, in draw self.label1.draw(renderer) File /usr/lib/pymodules/python2.6/matplotlib/text.py, line 553, in draw self._fontproperties, angle) File /usr/lib/pymodules/python2.6/matplotlib/backends/backend_pdf.py, line 1431, in draw_tex psfont = self.tex_font_mapping(dvifont.texname) File /usr/lib/pymodules/python2.6/matplotlib/backends/backend_pdf.py, line 1264, in tex_font_mapping dviread.PsfontsMap(dviread.find_tex_file('pdftex.map')) File /usr/lib/pymodules/python2.6/matplotlib/dviread.py, line 668, in __init__ self._parse(file) File /usr/lib/pymodules/python2.6/matplotlib/dviread.py, line 701, in _parse self._register(words) File /usr/lib/pymodules/python2.6/matplotlib/dviread.py, line 727, in _register assert encoding is None AssertionError I assume that the errors happens during parsing of the file 8r.enc (http://tug.org/fontname/8r.enc). This file belongs to TexLive 2010 and can also be found identically in MikTeX 2.9. I could only reproduce the error in Linux so far. Any help would be appreciated. Alexander -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Zooming into plots?
On Wednesday, January 26, 2011, Soumyaroop Roy soumyar...@gmail.com wrote: Hi there: Does matplotlib have provide any feature to allow zooming into plot regions like a waveform viewer does? regards, Soumyaroop Mpl offers full control of the plot display. Maybe if you offer an example of what you are looking for, we might be able to point you to a way to do what you want? Ben Root -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] too many values to unpack with a bar chart
On Wednesday, January 26, 2011, C M cmpyt...@gmail.com wrote: I usually do this for line graphs with markers: line, = self.subplot.plot_date(dates,data) along with some keywords to tweak the plot. I then add line to a dictionary to keep track of it: self.line_to_data_dict[line] = self.activity But today I tried this with a bar chart, just changing plot_date to bar and renaming the line, to bars,: fake_data = [2,2,5] bars, = self.subplot.bar(fake_data, fake_data ) This gave me the error: ValueError: too many values to unpack. OK, so if I removed the comma from bars, so it is just bars, it goes through but then I cannot add it to my dictionary--I get: TypeError: list objects are unhashable Help in understanding this and a better approach would be helpful. Thanks, Che Just a thought, are you trying out the new legend code? Could you do a print of the type for bars? Ben Root -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] too many values to unpack with a bar chart
Just a thought, are you trying out the new legend code? I don't know if I am or not. But these problems are prior to any code regarding the legend. Could you do a print of the type for bars? When I write it as just bars without the comma it is: bars type = type 'list' If I write it with the comma ( bars,) then it won't even run because of the ValueError. I know the 2nd problem is that a dictionary cannot have a mutable object like a list as a key. But previously, as I said, I was able to call line, (with the comma) and it would work. In fact, line, with a comma gives this type: line type = class 'matplotlib.lines.Line2D' Thanks, Che -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Zooming into plots?
Hi Ben: That's encouraging! I want to be able plot up to N data points (the points are in an ordered sequence) on a canvas and then zoom into the plot region enclosed within a subset sequence (e.g., T1 to T2 data points, 0 = T1 T2 =N) by putting two cursors - one on T1 and the other one on T2. regards, Soumyaroop On Wed, Jan 26, 2011 at 6:44 PM, Benjamin Root ben.r...@ou.edu wrote: On Wednesday, January 26, 2011, Soumyaroop Roy soumyar...@gmail.com wrote: Hi there: Does matplotlib have provide any feature to allow zooming into plot regions like a waveform viewer does? regards, Soumyaroop Mpl offers full control of the plot display. Maybe if you offer an example of what you are looking for, we might be able to point you to a way to do what you want? Ben Root -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] too many values to unpack with a bar chart
On Thu, Jan 27, 2011 at 10:07 AM, C M cmpyt...@gmail.com wrote: I know the 2nd problem is that a dictionary cannot have a mutable object like a list as a key. But previously, as I said, I was able to call line, (with the comma) and it would work. In fact, line, with a comma gives this type: If you just want a hashable object, can you just cast it to a tuple? bars = self.subplot.bar(fake_data, fake_data ) bars_tuple = tuple(bars) bars_tuple can be used as a dictionary key. Regards, -JJ -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Plot to display or file in the same script?
I'm trying to make a simple utility for doing a quick check of some data (electrophysiology recordings from our fMRI scanner lab). I want it to be foolproof as much as possible, so I was trying to figure out how to write a script that would try to plot to the display, then if that didn't work, to save it to a file instead (preferably as pdf, but I could live with png if that was the only option.) I've been searching the documentation and code examples for a while, and all I can find seems to suggest that the choice of display vs. file is predetermined at the very beginning by the choice of backend. I suppose that would mean I'd have to put the whole thing inside a try block, then if that didn't work, start over from scratch with a different backend and build the plot again. I was hoping to find a way to build the plot, then just try to show it or something like that, and if that failed, then save it instead. But so far I have not been able to figure out such a thing. So I would appreciate any help! Thanks very much! -- -dave Pseudo-colored pictures of a person's brain lighting up are undoubtedly more persuasive than a pattern of squiggles produced by a polygraph. That could be a big problem if the goal is to get to the truth. -Dr. Steven Hyman, Harvard -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plot to display or file in the same script?
On Wednesday, January 26, 2011, David Perlman dperl...@wisc.edu wrote: I'm trying to make a simple utility for doing a quick check of some data (electrophysiology recordings from our fMRI scanner lab). I want it to be foolproof as much as possible, so I was trying to figure out how to write a script that would try to plot to the display, then if that didn't work, to save it to a file instead (preferably as pdf, but I could live with png if that was the only option.) I've been searching the documentation and code examples for a while, and all I can find seems to suggest that the choice of display vs. file is predetermined at the very beginning by the choice of backend. I suppose that would mean I'd have to put the whole thing inside a try block, then if that didn't work, start over from scratch with a different backend and build the plot again. I was hoping to find a way to build the plot, then just try to show it or something like that, and if that failed, then save it instead. But so far I have not been able to figure out such a thing. So I would appreciate any help! Thanks very much! You can always put the show call in a try block and do a savefig if the show fails. I don't know where you get the idea that you have to do one or the other... Unless you are talking about the issue where the closing of a figure window would cause you to lose the figure data? In which case, you should be fine catching the show and doing the savefigg because the close event never occurred. However, you might get messy this way with a blank figure window... To be foolproof I would just always save first and then attempt to show. If the show was successful, you can delete the saved figure. Sorry for the rambling, but those are my thoughts on it. Ben Root -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Plot to display or file in the same script?
The problem is that if no display is available, the error gets raised on the point where I try to create a new figure, long before getting to show(), so I can't do anything at all. Here's what it looks like when I log in without a display available: import matplotlib.pyplot as plt plt.figure() Traceback (most recent call last): File stdin, line 1, in module File /usr/local/Python/Versions/2.6.5/lib/python2.6/site-packages/matplotlib/pyplot.py, line 270, in figure **kwargs) File /usr/local/Python/Versions/2.6.5/lib/python2.6/site-packages/matplotlib/backends/backend_tkagg.py, line 83, in new_figure_manager window = Tk.Tk() File /usr/local/Python/Versions/2.6.5/lib/python2.6/lib-tk/Tkinter.py, line 1643, in __init__ self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use) _tkinter.TclError: no display name and no $DISPLAY environment variable I can do this, which is widely recommended: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt fig=plt.figure() fig.save_fig('test.png') But as far as I can tell from searching, once you do this, there is no way to display to the screen. Unless there is a very clever trick that I don't know about... which I am asking for here... :-) On Jan 26, 2011, at 11:16 PM, Benjamin Root wrote: On Wednesday, January 26, 2011, David Perlman dperl...@wisc.edu wrote: I'm trying to make a simple utility for doing a quick check of some data (electrophysiology recordings from our fMRI scanner lab). I want it to be foolproof as much as possible, so I was trying to figure out how to write a script that would try to plot to the display, then if that didn't work, to save it to a file instead (preferably as pdf, but I could live with png if that was the only option.) I've been searching the documentation and code examples for a while, and all I can find seems to suggest that the choice of display vs. file is predetermined at the very beginning by the choice of backend. I suppose that would mean I'd have to put the whole thing inside a try block, then if that didn't work, start over from scratch with a different backend and build the plot again. I was hoping to find a way to build the plot, then just try to show it or something like that, and if that failed, then save it instead. But so far I have not been able to figure out such a thing. So I would appreciate any help! Thanks very much! You can always put the show call in a try block and do a savefig if the show fails. I don't know where you get the idea that you have to do one or the other... Unless you are talking about the issue where the closing of a figure window would cause you to lose the figure data? In which case, you should be fine catching the show and doing the savefigg because the close event never occurred. However, you might get messy this way with a blank figure window... To be foolproof I would just always save first and then attempt to show. If the show was successful, you can delete the saved figure. Sorry for the rambling, but those are my thoughts on it. Ben Root -- -dave Pseudo-colored pictures of a person's brain lighting up are undoubtedly more persuasive than a pattern of squiggles produced by a polygraph. That could be a big problem if the goal is to get to the truth. -Dr. Steven Hyman, Harvard -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] too many values to unpack with a bar chart
On Wed, Jan 26, 2011 at 9:16 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote: On Thu, Jan 27, 2011 at 10:07 AM, C M cmpyt...@gmail.com wrote: I know the 2nd problem is that a dictionary cannot have a mutable object like a list as a key. But previously, as I said, I was able to call line, (with the comma) and it would work. In fact, line, with a comma gives this type: If you just want a hashable object, can you just cast it to a tuple? bars = self.subplot.bar(fake_data, fake_data ) bars_tuple = tuple(bars) bars_tuple can be used as a dictionary key. Yes, that can work, thanks, but I am still stuck without a bar chart for other reasons (see point #3 below), and I am still confused. I have some questions that if answered can hopefully help me get clearer: 1) What does the comma do exactly? If I put this: line, I create a matplotlib line object, whereas if I put just line I create a list. Does this mean that plot() in mpl returns a tuple that contains one element, which is a mpl line object? (If so, why doesn't it just return the line object itself?) 2) Why does line, followed by plot() return a mpl line object but bars, followed by bar() not return some kind of matplotlib object (like a line)? Why does it instead give the ValueError: Too many values to unpack error? 3) I am getting just hammered with the following error *a lot* in date plotting lately: ValueError: ordinal must be = 1 And I can't figure out what sorts of mistakes or situations are triggering it. More of the traceback above that error is at the end of this message. Does someone know when this error will be thrown when using dates so I can at least know what to check for in my data? Thanks, Che -- more of Traceback: for ylabel_i in self.subplot.get_yticklabels(): File C:\Python25\lib\site-packages\matplotlib\axes.py, line 2646, in get_yticklabels self.yaxis.get_ticklabels(minor=minor)) File C:\Python25\lib\site-packages\matplotlib\axis.py, line 1087, in get_ticklabels return self.get_majorticklabels() File C:\Python25\lib\site-packages\matplotlib\axis.py, line 1071, in get_majorticklabels ticks = self.get_major_ticks() File C:\Python25\lib\site-packages\matplotlib\axis.py, line 1169, in get_major_ticks numticks = len(self.get_major_locator()()) File C:\Python25\lib\site-packages\matplotlib\dates.py, line 743, in __call__ self.refresh() File C:\Python25\lib\site-packages\matplotlib\dates.py, line 752, in refresh dmin, dmax = self.viewlim_to_dt() File C:\Python25\lib\site-packages\matplotlib\dates.py, line 524, in viewlim_to_dt return num2date(vmin, self.tz), num2date(vmax, self.tz) File C:\Python25\lib\site-packages\matplotlib\dates.py, line 289, in num2date if not cbook.iterable(x): return _from_ordinalf(x, tz) File C:\Python25\lib\site-packages\matplotlib\dates.py, line 203, in _from_ordinalf dt = datetime.datetime.fromordinal(ix) ValueError: ordinal must be = 1 -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] too many values to unpack with a bar chart
3) I am getting just hammered with the following error *a lot* in date plotting lately: ValueError: ordinal must be = 1 OK, I made up a small runnable sample to show this with bar(). (Using code that someone else wrote[1]). This code runs when using plot_date(), but if you comment that out and comment in the ax.bar() line, it will give this ValueError. import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np import datetime as dt # Make a series of events 1 day apart x = mpl.dates.drange(dt.datetime(2009,10,1), dt.datetime(2010,1,15), dt.timedelta(days=1)) # Vary the datetimes so that they occur at random times # Remember, 1.0 is equivalent to 1 day in this case... x += np.random.random(x.size) # We can extract the time by using a modulo 1, and adding an arbitrary base date times = x % 1 + int(x[0]) # (The int is so the y-axis starts at midnight...) # I'm just plotting points here, but you could just as easily use a bar. fig = plt.figure() ax = fig.add_subplot(111) #comment out: ax.plot_date(x, times, 'ro') #comment in #ax.bar(x, times) ax.yaxis_date() fig.autofmt_xdate() plt.show() [1]http://stackoverflow.com/questions/4790265/plot-time-of-day-vs-date-in-matplotlib -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] too many values to unpack with a bar chart
C M, on 2011-01-27 02:03, wrote: 3) I am getting just hammered with the following error *a lot* in date plotting lately: ValueError: ordinal must be = 1 OK, I made up a small runnable sample to show this with bar(). (Using code that someone else wrote[1]). This code runs when using plot_date(), but if you comment that out and comment in the ax.bar() line, it will give this ValueError. import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np import datetime as dt # Make a series of events 1 day apart x = mpl.dates.drange(dt.datetime(2009,10,1), dt.datetime(2010,1,15), dt.timedelta(days=1)) # Vary the datetimes so that they occur at random times # Remember, 1.0 is equivalent to 1 day in this case... x += np.random.random(x.size) # We can extract the time by using a modulo 1, and adding an arbitrary base date times = x % 1 + int(x[0]) # (The int is so the y-axis starts at midnight...) # I'm just plotting points here, but you could just as easily use a bar. fig = plt.figure() ax = fig.add_subplot(111) #comment out: ax.plot_date(x, times, 'ro') Hi C. M., The reason you were getting that error is because unless you specify otherwise, ax.bar will make the bottom of the bars at 0 - which isn't an allowed date, hence the error. Change your bar line to this (I also added align='center', but you can remove it if you want): #comment in bot = times.min().round() ax.bar(x, times-bot, bottom=bot, align='center') ax.yaxis_date() fig.autofmt_xdate() plt.show() best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 signature.asc Description: Digital signature -- Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)! Finally, a world-class log management solution at an even better price-free! Download using promo code Free_Logger_4_Dev2Dev. Offer expires February 28th, so secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsight-sfd2d___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users