SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S






1
(2)
2
(4)
3
(16)
4
(4)
5
(15)
6
(16)
7
(6)
8
(4)
9
(9)
10
(5)
11
(8)
12
(14)
13
(19)
14
(21)
15
(8)
16
(6)
17
(10)
18
(22)
19
(15)
20
(7)
21
(21)
22
(1)
23
(6)
24
(16)
25
(12)
26
(11)
27
(27)
28
(7)
29
30
(4)
31
(5)





Showing results of 315

<< < 1 2 3 4 .. 13 > >> (Page 2 of 13)
From: Paul I. <piv...@gm...> - 2011年01月27日 17:53:52
Daniel Fulger, on 2011年01月27日 18:16, wrote:
> Dear all,
> 
> contourset = pyplot.contour(..)
> 
> calculates the contourset but also grabs whatever figure is currently 
> active *somewhere* in the entire code
> and whichever scope it was created. The contours are plotted into it.
> 
> While I could possibly live with that, I would really like to
> suppress any plotting and grabbig of focus. Only the contourset 
> should be calculated.
> 
> I can't find anything that describes this. Everybody wants the plot, 
> not me.
> 
> I would like to avoid hte workaround to ask for the currently active 
> figure (if!! there is one at all), store the number, and later return 
> focus. Is there no switch parameter (in pyplot or for contour at 
> least) that turns plotting off?
Hi Daniel,
I'm not sure if this gets at what you're asking for, but if
you just want the contours plotted on a figure other than the
currently active one, grab a handle to some other axes and call
contour from the axes itself (the parameters are the same).
Here's what I mean:
-----------
f,ax =plt.subplots(1,1) #grab handles to figure and axes
# or, if you're using an older version of matplotlib, do:
# f=plt.figure();ax=plt.subplot(1,1,1)
f2,ax2 =plt.subplots(1,1) # "f" no longer active figure
...
contourset = ax.contour(...) # draw to the old figure "f"
-----------
You can read more about the difference between using pyplot and
using the object-oriented api here:
http://matplotlib.sourceforge.net/faq/usage_faq.html
On the other hand, if you just want the contour to not show up,
you can pass it alpha=0.0 to make it completely transparent and
invisible (but it's still there)
contourset = pyplot.contour(.., alpha=0.0)
# later call contourset.set_alpha(1.0) to make visible again
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Daniel F. <dan...@we...> - 2011年01月27日 17:18:51
Dear all,
contourset = pyplot.contour(..)
calculates the contourset but also grabs whatever figure is currently 
active *somewhere* in the entire code
and whichever scope it was created. The contours are plotted into it.
While I could possibly live with that, I would really like to
suppress any plotting and grabbig of focus. Only the contourset 
should be calculated.
I can't find anything that describes this. Everybody wants the plot, 
not me.
I would like to avoid hte workaround to ask for the currently active 
figure (if!! there is one at all), store the number, and later return 
focus. Is there no switch parameter (in pyplot or for contour at 
least) that turns plotting off?
Regards
Daniel
From: Thomas L. <thl...@ms...> - 2011年01月27日 13:35:48
Hi all,
I would like to contribute to a better readshapefile method, who should I contact / where should I commit ?
First improvement and partial solution :
* returning a tuple of linecollections per "record", with its name and other properties.
Cheers,
Thomas
ps : example http://www.geophysique.be/2011/01/27/matplotlib-basemap-tutorial-07-shapefiles-unleached/
**********************
Thomas Lecocq
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**********************
 		 	 		 
From: Thomas L. <thl...@ms...> - 2011年01月27日 13:24:32
Hi,
 
Adding some extra work in the readshapefile method in your code allows you to play with the region names etc,...
 
I've just made a new tutorial script to show this :
 
http://www.geophysique.be/2011/01/27/matplotlib-basemap-tutorial-07-shapefiles-unleached/
 
 
Thom
 
**********************
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**********************
 
Date: 2011年1月27日 17:59:03 +0800
From: eri...@gm...
To: thl...@ms...
CC: eri...@gm...; mat...@li...
Subject: Re: [Matplotlib-users] How to draw a specific country by basemap?
On 01/27/2011 01:38 AM, Thomas Lecocq wrote: 
Hi,
An easy way is to use the data from http://www.gadm.org/ and to plot it with m.readshapefile()
Thank you very much. The GDAM database is great.
BTW, would you like to give some suggestions about how to color the map, i.e., highlight a specific region? 
Thanks,
Eric
HTH,
Thom
**********************
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**********************
Date: 2011年1月26日 16:03:27 +0800
From: eri...@gm...
To: mat...@li...
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 Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users 
-- 
-----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 Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users 		 	 		 
From: Thomas L. <thl...@ms...> - 2011年01月27日 12:17:41
Hi, 
that would do:
 
data = m.readshapefile(r'borders\ita_adm1','itaborder',linewidth=0.5)
italy = data[4]
print dir(italy)
italy.set_facecolors('red')
italy.set_alpha(0.5)
 
I think at some point you"ll meet the limitations of the method, you might need to use another shapefile-reading module ...
 
Thom
 
**********************
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**********************
 
Date: 2011年1月27日 17:59:03 +0800
From: eri...@gm...
To: thl...@ms...
CC: eri...@gm...; mat...@li...
Subject: Re: [Matplotlib-users] How to draw a specific country by basemap?
On 01/27/2011 01:38 AM, Thomas Lecocq wrote: 
Hi,
An easy way is to use the data from http://www.gadm.org/ and to plot it with m.readshapefile()
Thank you very much. The GDAM database is great.
BTW, would you like to give some suggestions about how to color the map, i.e., highlight a specific region? 
Thanks,
Eric
HTH,
Thom
**********************
Thomas Lecocq 
Geologist
Ph.D.Student (Seismology)
Royal Observatory of Belgium
**********************
Date: 2011年1月26日 16:03:27 +0800
From: eri...@gm...
To: mat...@li...
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 Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users 
-- 
-----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------ 		 	 		 
From: Eric L. <eri...@gm...> - 2011年01月27日 09:59:21
On 01/27/2011 01:38 AM, Thomas Lecocq wrote:
> Hi,
>
> An easy way is to use the data from http://www.gadm.org/ and to plot
> it with m.readshapefile()
Thank you very much. The GDAM database is great.
BTW, would you like to give some suggestions about how to color the
map, i.e., highlight a specific region? 
Thanks,
Eric
>
> HTH,
>
> Thom
>
> **********************
> Thomas Lecocq
> Geologist
> Ph.D.Student (Seismology)
> Royal Observatory of Belgium
> **********************
>
>
>
> ------------------------------------------------------------------------
> Date: 2011年1月26日 16:03:27 +0800
> From: eri...@gm...
> To: mat...@li...
> 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 Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users 
-- 
-----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------
From: Paul I. <piv...@gm...> - 2011年01月27日 07:55:04
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 
From: C M <cmp...@gm...> - 2011年01月27日 07:04:09
> 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
From: C M <cmp...@gm...> - 2011年01月27日 06:34:12
On Wed, Jan 26, 2011 at 9:16 PM, Jae-Joon Lee <lee...@gm...> wrote:
> On Thu, Jan 27, 2011 at 10:07 AM, C M <cmp...@gm...> 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
From: David P. <dpe...@wi...> - 2011年01月27日 06:31:24
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 <dpe...@wi...> 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
From: Benjamin R. <ben...@ou...> - 2011年01月27日 05:16:17
On Wednesday, January 26, 2011, David Perlman <dpe...@wi...> 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
From: <pat...@at...> - 2011年01月27日 04:53:23
Forgive me if this is an old question, but I just loaded mplot3d and was
attempting to work through a couple of the examples on the Matplotlib
website. The problem is that whenever I try to make a call to a function
that requires an argument of projection='3d' (such as: ax =
fig.add_subplot(111, projection='3d')), Python gives me the following error:
 
Traceback (most recent call last):
 File "<pyshell#12>", line 1, in <module>
 ax = fig.add_subplot(111, projection='3d')
 File "C:\Python26\lib\site-packages\matplotlib\figure.py", line 677, in
add_subplot
 projection_class = get_projection_class(projection)
 File "C:\Python26\lib\site-packages\matplotlib\projections\__init__.py",
line 61, in get_projection_class
 raise ValueError("Unknown projection '%s'" % projection)
ValueError: Unknown projection '3d'
 
Running help on fig.add_subplot does not show '3d' as a valid projection
type for this function.
 
What's going on, and how do I fix it?
 
I'm running Python 2.6.6 on Windows 7.
 
Thanks in advance.
 
/s/
Pat
From: David P. <dpe...@wi...> - 2011年01月27日 04:26:42
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
From: Jae-Joon L. <lee...@gm...> - 2011年01月27日 02:17:10
On Thu, Jan 27, 2011 at 10:07 AM, C M <cmp...@gm...> 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
From: Soumyaroop R. <sou...@gm...> - 2011年01月27日 01:28:06
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...@ou...> wrote:
> On Wednesday, January 26, 2011, Soumyaroop Roy <sou...@gm...> 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
>
From: C M <cmp...@gm...> - 2011年01月27日 01:08:06
> 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
From: Benjamin R. <ben...@ou...> - 2011年01月27日 00:49:22
On Wednesday, January 26, 2011, C M <cmp...@gm...> 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
From: Benjamin R. <ben...@ou...> - 2011年01月27日 00:44:57
On Wednesday, January 26, 2011, Soumyaroop Roy <sou...@gm...> 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
From: Alex <ale...@go...> - 2011年01月26日 22:52:52
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
From: C M <cmp...@gm...> - 2011年01月26日 22:41:46
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
From: Shrividya R. <pen...@gm...> - 2011年01月26日 22:37:35
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
From: Thomas L. <thl...@ms...> - 2011年01月26日 22:37:17
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: 2011年1月26日 16:03:27 +0800
From: eri...@gm...
To: mat...@li...
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
Mat...@li...
https://lists.sourceforge.net/lists/listinfo/matplotlib-users 		 	 		 
From: Soumyaroop R. <sou...@gm...> - 2011年01月26日 22:03:08
Hi there:
Does matplotlib have provide any feature to allow zooming into plot
regions like a waveform viewer does?
regards,
Soumyaroop
From: Eric L. <eri...@gm...> - 2011年01月26日 08:03:42
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------
From: Eric F. <ef...@ha...> - 2011年01月26日 07:50:55
On 01/25/2011 08:51 PM, Paul Ivanov wrote:
> Eric Firing, on 2011年01月25日 19:52, wrote:
>> On 01/25/2011 06:58 PM, Shrividya Ravi wrote:
>> [...]
>>> On the same topic of the colorbar, how can I readjust the colors such
>>> that it only goes between user-specified values? For example, I have one
>>> imshow plot where the values range between 0 and 350. However, I only
>>> want to look at the values between 300 and 350.
>>
>> z = np.arange(25)
>> z.shape = 5,5
>> imshow(z, vmin=10, vmax=20, interpolation='nearest')
>> colorbar(extend='both')
>>
>> Does that give the desired result?
>
> Hi Shrividya,
>
> Here's how I interpreted what was being asked, in case that
> helps.
(Your interpretation seems like a very strange thing to want to do, but 
maybe you are right. The OP can inform us.)
>
> Also, Eric, is there a reason we make an outline instead of
> just cbar.ax.set_frame_on? - My manual adjustments screw up and
> confuse whatever data cbar.outline depends on
Yes, we need to make our own outline because a colorbar does not have to 
be a rectangle; it can be pointed at either end or both ends.
Eric
>
> x = np.random.rand(100)
> y = np.random.rand(100)
> z = np.random.rand(100)
> collection = plt.scatter(x, y, c=z*350, vmin=0, vmax=350)
> cbar = plt.colorbar()
> cbar.ax.set_ylim(cbar.norm((300,350)))
> cbar.ax.set_xlim(cbar.norm((300,350))) # maintain aspect ratio
> cbar.set_ticks(np.linspace(300,350,6))
> # didn't see a quick way to fix the outline
> cbar.outline.set_visible(False)
> cbar.ax.set_frame_on(True)
> plt.draw()
>
> best,
>
6 messages has been excluded from this view by a project administrator.

Showing results of 315

<< < 1 2 3 4 .. 13 > >> (Page 2 of 13)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /