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



Showing 12 results of 12

From: Jeff W. <jef...@no...> - 2012年02月09日 23:46:24
On 2/9/12 10:49 AM, Jeff Whitaker wrote:
> On 2/9/12 9:05 AM, Andreas H. wrote:
>> Hi,
>>
>> I'm trying to use pcolor on a masked array. I would like masked elements
>> to show up in a special color. I have written some code, but it does not
>> seem to work:
>>
>> I would appreciate any help :)
>>
>> Cheers,
>> Andreas.
>>
>> ---8<-------
>>
>> import matplotlib as mpl
>> import matplotlib.pyplot as plt
>>
>> from numpy import linspace
>> from numpy.random import randn
>> from numpy.ma import masked_invalid
>>
>> D = randn(12*72).reshape((12,72))
>> D[4,:] = nan
>> D[6,6] = nan
>>
>> D = masked_invalid(D)
>>
>> cmap = mpl.cm.bwr
>> cmap.set_bad('k', 1.)
>>
>> xbin = linspace(0, 12, 13)
>> ybin = linspace(-90, 90, 73)
>>
>> fig = plt.figure()
>> spl = fig.add_subplot(111)
>> pl = spl.pcolor(xbin, ybin, D.T, cmap=cmap, edgecolors='none',
>> vmin=-5, vmax=5)
> Andreas: That's because pcolor only fills polygons that are not masked
> - it does do anything with the masked ones.
>
> From the docstring:
>
> *X*, *Y* and *C* may be masked arrays. If either C[i, j], or one
> of the vertices surrounding C[i,j] (*X* or *Y* at [i, j], [i+1, j],
> [i, j+1],[i+1, j+1]) is masked, *]nothing is plotted.
>
> I suppose pcolor could be modified to fill the masked polygons with the
> color indicated by cmap.set_bad - I think that's what most people would
> expect.
>
> -Jeff
>
>
BTW: pcolormesh will do what you want.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: phils <phi...@ho...> - 2012年02月09日 21:07:55
Paul Ivanov wrote:
> 
> Hi Phil,
> 
> phils, on 2012年02月04日 07:41, wrote:
>> Newbie to using matplotlib
> 
> welcome to the party :)
> 
>> Is it possible to use wx and have a window with say 2 buttons on where
>> when
>> clicking on either button a different graph will appear using a different
>> data set. Any examples?
> 
> Yes, it's possible. Here's a modified version of
> examples/event_handling/keypress_demo.py which toggles between
> two different axes when you press the 'w' key on your keyboard:
> one has green points connected by dashed lines, the other with
> multi-colored multi-sized scatter data.
> --------
> import numpy as np
> import matplotlib.pyplot as plt
> 
> plt.close('all')
> def press(event):
> print('press', event.key)
> if event.key=='w':
> visible = ax.get_visible()
> ax.set_visible(not visible)
> ax2.set_visible(visible)
> fig.canvas.draw()
> 
> fig = plt.figure()
> ax = fig.add_axes([.1,.1,.8,.8], label='one')
> ax2 = fig.add_axes([.1,.1,.8,.8], label='two')
> ax2.set_visible(False)
> 
> fig.canvas.mpl_connect('key_press_event', press)
> 
> ax.plot(np.random.rand(12), np.random.rand(12), 'go--')
> ax2.scatter(100*np.random.rand(12), 100*np.random.rand(12),
> c=np.random.rand(12), s=np.random.rand(12)*100)
> 
> plt.show()
> --------
> 
> I don't want to take away all of your fun, so have a look at
> adding (mouse clickable) buttons to this using either
> examples/widgets/buttons.py or examples/widgets/radio_buttons.py
> - depending on your preference.
> 
> best,
> -- 
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
> 
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
Paul
Thanks for this - really good. 
Day job is Crystal Reports developer and look foward to getting to use
Matplotlib.
Thanks again.
-- 
View this message in context: http://old.nabble.com/Switch-graphs-tp33263048p33296436.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: phils <phi...@ho...> - 2012年02月09日 21:07:55
Paul Ivanov wrote:
> 
> Hi Phil,
> 
> phils, on 2012年02月04日 07:41, wrote:
>> Newbie to using matplotlib
> 
> welcome to the party :)
> 
>> Is it possible to use wx and have a window with say 2 buttons on where
>> when
>> clicking on either button a different graph will appear using a different
>> data set. Any examples?
> 
> Yes, it's possible. Here's a modified version of
> examples/event_handling/keypress_demo.py which toggles between
> two different axes when you press the 'w' key on your keyboard:
> one has green points connected by dashed lines, the other with
> multi-colored multi-sized scatter data.
> --------
> import numpy as np
> import matplotlib.pyplot as plt
> 
> plt.close('all')
> def press(event):
> print('press', event.key)
> if event.key=='w':
> visible = ax.get_visible()
> ax.set_visible(not visible)
> ax2.set_visible(visible)
> fig.canvas.draw()
> 
> fig = plt.figure()
> ax = fig.add_axes([.1,.1,.8,.8], label='one')
> ax2 = fig.add_axes([.1,.1,.8,.8], label='two')
> ax2.set_visible(False)
> 
> fig.canvas.mpl_connect('key_press_event', press)
> 
> ax.plot(np.random.rand(12), np.random.rand(12), 'go--')
> ax2.scatter(100*np.random.rand(12), 100*np.random.rand(12),
> c=np.random.rand(12), s=np.random.rand(12)*100)
> 
> plt.show()
> --------
> 
> I don't want to take away all of your fun, so have a look at
> adding (mouse clickable) buttons to this using either
> examples/widgets/buttons.py or examples/widgets/radio_buttons.py
> - depending on your preference.
> 
> best,
> -- 
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
> 
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
Paul
Thanks for this - really good. 
Day job is Crystal Reports developer and look foward to getting to use
Matplotlib.
Thanks again.
-- 
View this message in context: http://old.nabble.com/Switch-graphs-tp33263048p33296437.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: phils <phi...@ho...> - 2012年02月09日 21:07:51
Paul Ivanov wrote:
> 
> Hi Phil,
> 
> phils, on 2012年02月04日 07:41, wrote:
>> Newbie to using matplotlib
> 
> welcome to the party :)
> 
>> Is it possible to use wx and have a window with say 2 buttons on where
>> when
>> clicking on either button a different graph will appear using a different
>> data set. Any examples?
> 
> Yes, it's possible. Here's a modified version of
> examples/event_handling/keypress_demo.py which toggles between
> two different axes when you press the 'w' key on your keyboard:
> one has green points connected by dashed lines, the other with
> multi-colored multi-sized scatter data.
> --------
> import numpy as np
> import matplotlib.pyplot as plt
> 
> plt.close('all')
> def press(event):
> print('press', event.key)
> if event.key=='w':
> visible = ax.get_visible()
> ax.set_visible(not visible)
> ax2.set_visible(visible)
> fig.canvas.draw()
> 
> fig = plt.figure()
> ax = fig.add_axes([.1,.1,.8,.8], label='one')
> ax2 = fig.add_axes([.1,.1,.8,.8], label='two')
> ax2.set_visible(False)
> 
> fig.canvas.mpl_connect('key_press_event', press)
> 
> ax.plot(np.random.rand(12), np.random.rand(12), 'go--')
> ax2.scatter(100*np.random.rand(12), 100*np.random.rand(12),
> c=np.random.rand(12), s=np.random.rand(12)*100)
> 
> plt.show()
> --------
> 
> I don't want to take away all of your fun, so have a look at
> adding (mouse clickable) buttons to this using either
> examples/widgets/buttons.py or examples/widgets/radio_buttons.py
> - depending on your preference.
> 
> best,
> -- 
> Paul Ivanov
> 314 address only used for lists, off-list direct email at:
> http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
> 
> ------------------------------------------------------------------------------
> Keep Your Developer Skills Current with LearnDevNow!
> The most comprehensive online learning library for Microsoft developers
> is just 99ドル.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-d2d
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
Paul
Thanks for this - really good. 
Day job is Crystal Reports developer and look foward to getting to use
Matplotlib.
Thanks again.
-- 
View this message in context: http://old.nabble.com/Switch-graphs-tp33263048p33296435.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: C M <cmp...@gm...> - 2012年02月09日 20:12:07
Jae-Joon's code, make_axes_area_auto_adjustable has been a great help to
dynamically resizing my plots' axes area--such an improvement. But there
are two bugs I've noticed that I wonder if has been identified/fixed yet:
1) When I point-pick on the plot, the plot area still "jumps" (expands
vertically a small amount). It used to do this each time I point-picked,
but after upgrading MPL it now just does it the *first* time only. But is
it possible it can be fixed so it doesn't jump at all?
2) I just noticed that if a plot is resized so that the window that the
plot is embedded in is *narrower than the title on the plot*, the resizing
of the axes area gets very messed up (it gets *much8 narrower than is
necessary to fit the available area). I'm not sure what the best approach
to fixing this is, since it's not ideal to have a title not fit the
figure's area, either...is it possible to flow-wrap a plot title?
Thanks,
Che
From: Jeff W. <jef...@no...> - 2012年02月09日 17:49:18
On 2/9/12 9:05 AM, Andreas H. wrote:
> Hi,
>
> I'm trying to use pcolor on a masked array. I would like masked elements
> to show up in a special color. I have written some code, but it does not
> seem to work:
>
> I would appreciate any help :)
>
> Cheers,
> Andreas.
>
> ---8<-------
>
> import matplotlib as mpl
> import matplotlib.pyplot as plt
>
> from numpy import linspace
> from numpy.random import randn
> from numpy.ma import masked_invalid
>
> D = randn(12*72).reshape((12,72))
> D[4,:] = nan
> D[6,6] = nan
>
> D = masked_invalid(D)
>
> cmap = mpl.cm.bwr
> cmap.set_bad('k', 1.)
>
> xbin = linspace(0, 12, 13)
> ybin = linspace(-90, 90, 73)
>
> fig = plt.figure()
> spl = fig.add_subplot(111)
> pl = spl.pcolor(xbin, ybin, D.T, cmap=cmap, edgecolors='none',
> vmin=-5, vmax=5)
Andreas: That's because pcolor only fills polygons that are not masked 
- it does do anything with the masked ones.
 From the docstring:
*X*, *Y* and *C* may be masked arrays. If either C[i, j], or one
 of the vertices surrounding C[i,j] (*X* or *Y* at [i, j], [i+1, j],
 [i, j+1],[i+1, j+1]) is masked, *]nothing is plotted.
I suppose pcolor could be modified to fill the masked polygons with the 
color indicated by cmap.set_bad - I think that's what most people would 
expect.
-Jeff
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Andreas H. <li...@hi...> - 2012年02月09日 16:22:24
Hi,
I'm trying to use pcolor on a masked array. I would like masked elements
to show up in a special color. I have written some code, but it does not
seem to work:
I would appreciate any help :)
Cheers,
Andreas.
---8<-------
import matplotlib as mpl
import matplotlib.pyplot as plt
from numpy import linspace
from numpy.random import randn
from numpy.ma import masked_invalid
D = randn(12*72).reshape((12,72))
D[4,:] = nan
D[6,6] = nan
D = masked_invalid(D)
cmap = mpl.cm.bwr
cmap.set_bad('k', 1.)
xbin = linspace(0, 12, 13)
ybin = linspace(-90, 90, 73)
fig = plt.figure()
spl = fig.add_subplot(111)
pl = spl.pcolor(xbin, ybin, D.T, cmap=cmap, edgecolors='none',
 vmin=-5, vmax=5)
From: David C. <dcd...@gm...> - 2012年02月09日 15:34:16
Hi,
I am trying to relabel the x-axis on a plot. I want it to have 10 evenly 
spaced labels ranging from 274 at zero to 283 at one increment short of 
the axis. My code is as follows:
 im.axes.xaxis.set_major_locator(py.MaxNLocator(10))
 im.axes.xaxis.set_ticklabels(range(274,284))
My understanding is that MaxNLocator defines the number of spaces 
between labels. I've tried a few variations on the above but can only 
seem to get the last label to be 282 or 284. Anyone know what I am doing 
wrong.
Thanks
D
From: Jerzy K. <jer...@un...> - 2012年02月09日 09:44:05
Christopher Ellison :
> Taking the image size to (30,30) made all the segments appear, but their
> thickness was still not uniform. Using some sort of smoothing helped,
> but it still not displaying what the matrix was specified as: a set of
> blocks, somewhat resembling a line, all of which are the same color and
> thickness.
>
> Can I have matplotlib show the matrix as I have specified it? Or is
> that too naive (on my part)?
Thickness is not uniform, since the system MUST truncate something when 
you code your drawing as you do.
With sinc or bilinear interpolation you will see non-uniform shades of gray.
Bicubic interpolation will be - probably - much better.
But if you want to see your matrix as you want to see it, don't use 
imshow. Use figimage.
plt.figure(figsize=(7.5,7.5))
plt.figimage(x,cmap=plt.cm.gray_r)
And, for goodness sake... Don't shoot yourself in the foot by savefig, 
which stores not the matrix, but the figure, the drawing
of it after all the calamities. Use
plt.imsave('bug.png',x,cmap=plt.cm.gray_r)
Good luck.
Jerzy Karczmarczuk
From: Christopher E. <cje...@uc...> - 2012年02月09日 06:59:42
Jerzy Karczmarczuk wrote the following on 02/08/2012 05:55 PM:
>
>> I am experiencing missing "segments" in the output of imshow()....
>>
>> Here is a minimal example:
>>
>> I have attached an example of the output. In theory, there should be
>> a continuous line from the left side of the picture to the right side.
>> The problem seems to occur across backends. Additionally, the
>> thickness of the segments is not uniform. Some are thinner than the
>> rest. Decreasing the value of N seems to make the issue go away.
>> Increasing the value of N makes the problem worse.
>>
>> Any ideas on what is going on and how I can fix it?
>>
> Imshow scales your geometry according to the figure size, and if you
> *insist* on having the "nearest" interpolation, you may lose pixels
> while drawing, it is as simple as that. No miracles.
>
> How to fix it?
> 1. Use bilinear, or sinc, or any smooth interpolation.
> 2. Make your figure big enough, say plt.figure(figsize=(14,14)).
>
Taking the image size to (30,30) made all the segments appear, but their 
thickness was still not uniform. Using some sort of smoothing helped, 
but it still not displaying what the matrix was specified as: a set of 
blocks, somewhat resembling a line, all of which are the same color and 
thickness.
Can I have matplotlib show the matrix as I have specified it? Or is 
that too naive (on my part)?
From: Benjamin R. <ben...@ou...> - 2012年02月09日 02:11:35
On Wednesday, February 8, 2012, Jerzy Karczmarczuk <
jer...@un...> wrote:
>
>> I am experiencing missing "segments" in the output of imshow()....
>>
>> Here is a minimal example:
>>
>> I have attached an example of the output. In theory, there should be
>> a continuous line from the left side of the picture to the right side.
>> The problem seems to occur across backends. Additionally, the
>> thickness of the segments is not uniform. Some are thinner than the
>> rest. Decreasing the value of N seems to make the issue go away.
>> Increasing the value of N makes the problem worse.
>>
>> Any ideas on what is going on and how I can fix it?
>>
> Imshow scales your geometry according to the figure size, and if you
> *insist* on having the "nearest" interpolation, you may lose pixels
> while drawing, it is as simple as that. No miracles.
>
> How to fix it?
> 1. Use bilinear, or sinc, or any smooth interpolation.
> 2. Make your figure big enough, say plt.figure(figsize=(14,14)).
>
> Jerzy Karczmarczuk
>
>
Agreed.
Your example above is basically the equivalent of rasterizing a line
(without anti-aliasing) and then down-scaling and possibly causing some
stretching due to changes in aspect ratio.
Because imshow() is unaware the you are actually drawing a line, the
backends can not take advantage of their "bag-o-tricks" to make it look
good.
Perhaps the example you provided was an oversimplified version of the
problem you are having?
Cheers!
Ben Root
From: Jerzy K. <jer...@un...> - 2012年02月09日 01:55:43
> I am experiencing missing "segments" in the output of imshow()....
>
> Here is a minimal example:
>
> I have attached an example of the output. In theory, there should be 
> a continuous line from the left side of the picture to the right side. 
> The problem seems to occur across backends. Additionally, the 
> thickness of the segments is not uniform. Some are thinner than the 
> rest. Decreasing the value of N seems to make the issue go away. 
> Increasing the value of N makes the problem worse.
>
> Any ideas on what is going on and how I can fix it?
>
Imshow scales your geometry according to the figure size, and if you 
*insist* on having the "nearest" interpolation, you may lose pixels 
while drawing, it is as simple as that. No miracles.
How to fix it?
1. Use bilinear, or sinc, or any smooth interpolation.
2. Make your figure big enough, say plt.figure(figsize=(14,14)).
Jerzy Karczmarczuk
1 message has been excluded from this view by a project administrator.

Showing 12 results of 12

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