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

Showing 5 results of 5

From: TP <par...@fr...> - 2012年11月22日 22:51:21
On Monday, November 19, 2012 13:53:21 Eric Firing wrote:
> It is not entirely clear to me what you are trying to do, but it sounds
> like increasing N is not the right way to do it. Three things might help
> you find a better way:
> 
> 1) The colormap is intended to work with a norm that handles the
> translation from your data numbers to the 0-1.0 range used to select
> values from the colormap (with exceptions--see below). You can choose a
> non-default norm, you can write your own, or you can set the parameters
> (vmin, vmax) of the standard linear norm.
> 
> 2) By creating a colormap and calling its set_under, set_over, and
> set_invalid methods, you can control the colors assigned to data values
> that your norm maps respectively to negative numbers, numbers greater
> than 1, and masked values. See
> http://matplotlib.org/examples/pylab_examples/contourf_demo.html for an
> example of using set_under and set_over. See
> http://matplotlib.org/examples/pylab_examples/image_masked.html for
> another example, and for an example of controlling the norm parameters
> or using an alternative norm.
> 
> 3) It is also possible to index directly into the colormap if you use a
> norm that returns an integer data type. An example of such is the
> BoundaryNorm.
> http://matplotlib.org/examples/pylab_examples/multicolored_line.html
> 
> If all you need is a single assignment of a color to a "large value",
> then using the set_over method will take care of it.
> 
> Eric
Thanks for your answer.
My goal is to keep the correct color, i.e. blue, for the point located at 
(x=0.3, y=0.4), even if there are very large values of z on the plot. As I 
said, increasing N is not satisfying because it leads to large amounts of 
memory to be used. But for the time being, this is the only solution I have 
found.
I cannot use the set_over method to do that, because the "large value" is not 
the only one. Indeed, what I want to do is an imshow plot, with a colorbar 
containing three different linear portions:
* one portion for the values of z contained between the minimum and maximum 
value of z in some measure points.
* one portion for the values of z below the minimum z in the measure points.
* one portion for the values of z above the maximum z in the measure points.
My problem is that I may have very large values on the plot in the range below 
or above the measures z. So I have exactly the problem shown in my dummy 
example of the previous post: all my measures have the same color, although 
they should not, because I have created a colormap that should handle this 
situation (three different linear portions in the map). The only workaround I 
have found is to increase the value of N, but in my case it has to be very 
large, such that the plot is very slow to display, or even can ask for huge 
amounts of memory.
Thus it seems to me that my dummy example given in the previous post covers 
exactly the problem encountered in my real-world imshow function.
Is there a memory-efficient workaround in my dummy example (instead of 
increasing N)?
Thanks,
TP
2012年11月4日 Brickle Macho <bri...@gm...>:
> [...] When I show() a plot form within a Qt application I get the
> following message printed on the console:
>
> QCoreApplication::exec: The event loop is already running
>
> I think I understand the error, obviously the application I calling form
> control the even loop. I suppose I need to somehow supply a parent
> window to pylab plot or the show() function. Is there a way to create
> a plot and show so as not to use the main loop?
Do not use show() in a GUI application.
If you have a FigureCanvas instance embedded in your app, call its
draw() method.
If you use pyplot.figure() to create a matplotlib window from your
app, call pyplot.draw().
Goyo
From: Goyo <goy...@gm...> - 2012年11月22日 17:44:37
2012年11月22日 Jeffrey Melloy <jm...@gm...>:
> I'm graphing data from a web service, and seem to have stumbled upon a
> bug when dates are graphed without any values.
>
> Here's a minimum repro:
>
> import datetime
> import matplotlib.pyplot as plt
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
>
> x = []
> st = datetime.datetime(2012,11,21)
> while st < datetime.datetime(2012,11,21, 16, 00):
> x.append(st)
> st = st + datetime.timedelta(minutes=30)
> y = [None] * len(x)
>
> ax.plot(x,y)
> fig.autofmt_xdate()
> plt.show()
>
>
> The stack trace I get:
>
> Traceback (most recent call last):
> File "min_mpl.py", line 15, in <module>
> fig.autofmt_xdate()
> File "c:\python26\lib\site-packages\matplotlib\figure.py", line 318,
> in autofmt_xdate
> for label in ax.get_xticklabels():
> File "c:\python26\lib\site-packages\matplotlib\axes.py", line 2507,
> in get_xticklabels
> self.xaxis.get_ticklabels(minor=minor))
> File "c:\python26\lib\site-packages\matplotlib\axis.py", line 1104,
> in get_ticklabels
> return self.get_majorticklabels()
> File "c:\python26\lib\site-packages\matplotlib\axis.py", line 1088,
> in get_majorticklabels
> ticks = self.get_major_ticks()
> File "c:\python26\lib\site-packages\matplotlib\axis.py", line 1186,
> in get_major_ticks
> numticks = len(self.get_major_locator()())
> File "c:\python26\lib\site-packages\matplotlib\dates.py", line 749,
> in __call__
> self.refresh()
> File "c:\python26\lib\site-packages\matplotlib\dates.py", line 758, in refresh
> dmin, dmax = self.viewlim_to_dt()
> File "c:\python26\lib\site-packages\matplotlib\dates.py", line 530,
> in viewlim_to_dt
> return num2date(vmin, self.tz), num2date(vmax, self.tz)
> File "c:\python26\lib\site-packages\matplotlib\dates.py", line 289,
> in num2date
> if not cbook.iterable(x): return _from_ordinalf(x, tz)
> File "c:\python26\lib\site-packages\matplotlib\dates.py", line 203,
> in _from_ordinalf
> dt = datetime.datetime.fromordinal(ix)
> ValueError: ordinal must be >= 1
>
> Adding a 0 & the current date stops getting the exception, but the
> range seems wildly messed up. (2011 - 2014).
I can't figure out what's going on here, the calls in the stack trace
seem unrelated to Y data.
As a quick and dirty workaround you can set the first and last Y
values to 0 --won't work well if you use markers.
Goyo
This may help you if I understand your basic problem. I use a lot of
interactive plots. This is an example of the work around to show() that I
use:
 
import matplotlib.pyplot as plt
plt.ion()
fig = plt.figure(figsize=(10,8))
ax = fig.add_axes([.15,.1,.8,.65])
ax.plot([1,2,3])
ax.set_title('Fisrt Plot')
raw_input('Enter to close and Continue: ')
plt.close(fig)
When I use this method when connecting to the axes I re-draw the figure
after updating using:
fig.canvas.draw()
I hope this was useful
Regards,
Bob
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Is-there-a-way-to-create-a-plot-and-call-show-so-as-not-to-use-the-main-Qt-loop-tp39653p39846.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jeffrey M. <jm...@gm...> - 2012年11月22日 00:42:28
I'm graphing data from a web service, and seem to have stumbled upon a
bug when dates are graphed without any values.
Here's a minimum repro:
import datetime
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
x = []
st = datetime.datetime(2012,11,21)
while st < datetime.datetime(2012,11,21, 16, 00):
 x.append(st)
 st = st + datetime.timedelta(minutes=30)
y = [None] * len(x)
ax.plot(x,y)
fig.autofmt_xdate()
plt.show()
The stack trace I get:
Traceback (most recent call last):
 File "min_mpl.py", line 15, in <module>
 fig.autofmt_xdate()
 File "c:\python26\lib\site-packages\matplotlib\figure.py", line 318,
in autofmt_xdate
 for label in ax.get_xticklabels():
 File "c:\python26\lib\site-packages\matplotlib\axes.py", line 2507,
in get_xticklabels
 self.xaxis.get_ticklabels(minor=minor))
 File "c:\python26\lib\site-packages\matplotlib\axis.py", line 1104,
in get_ticklabels
 return self.get_majorticklabels()
 File "c:\python26\lib\site-packages\matplotlib\axis.py", line 1088,
in get_majorticklabels
 ticks = self.get_major_ticks()
 File "c:\python26\lib\site-packages\matplotlib\axis.py", line 1186,
in get_major_ticks
 numticks = len(self.get_major_locator()())
 File "c:\python26\lib\site-packages\matplotlib\dates.py", line 749,
in __call__
 self.refresh()
 File "c:\python26\lib\site-packages\matplotlib\dates.py", line 758, in refresh
 dmin, dmax = self.viewlim_to_dt()
 File "c:\python26\lib\site-packages\matplotlib\dates.py", line 530,
in viewlim_to_dt
 return num2date(vmin, self.tz), num2date(vmax, self.tz)
 File "c:\python26\lib\site-packages\matplotlib\dates.py", line 289,
in num2date
 if not cbook.iterable(x): return _from_ordinalf(x, tz)
 File "c:\python26\lib\site-packages\matplotlib\dates.py", line 203,
in _from_ordinalf
 dt = datetime.datetime.fromordinal(ix)
ValueError: ordinal must be >= 1
Adding a 0 & the current date stops getting the exception, but the
range seems wildly messed up. (2011 - 2014).

Showing 5 results of 5

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 によって変換されたページ (->オリジナル) /