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


Showing 7 results of 7

From: Ryan M. <rm...@gm...> - 2008年07月25日 19:04:28
David Arnold wrote:
> All,
> 
> I am aware of the 3d examples at: http://scipy.org/Cookbook/ 
> Matplotlib/mplot3D
> 
> However, this seems out of date, some examples work, some don't. Are 
> there other pointers that show how I can use matplotlib to draw three 
> dimensional surfaces similar to the ones drawn in Matlab with mesh, 
> surf, and friends?
Unfortunately, the 3d plotting routine, axes3d, is unmaintained and 
unsupported. It has actually been removed from SVN and won't be in 
future releases. Volunteers are welcome to try and see if they can fix 
it. :)
Other options would be Vtk (with python bindings) (http://www.vtk.org) 
or Mayavi2 (https://svn.enthought.com/enthought/wiki/MayaVi).
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Ryan M. <rm...@gm...> - 2008年07月25日 18:56:49
Ben Axelrod wrote:
> 3. Both of the above mentioned bandaid fixes suffer from some bug (I 
> think in numpy). Where the min() and max() of a numpy array where the 
> first value is NaN, bugs out:
> 
> 
> 
> x = np.asarray([None, 1, 2, 3, 4, 5, 6, 7, 8, 9], float)
> 
> y = np.asarray([0, 1, 2, 3, 4, 5, 6, 7, 8, None], float)
> 
> z = np.asarray([0, 1, 2, 3, 4, 5, None, 7, 8, 9], float)
> 
> 
> 
> print min(x), max(x) #prints 1.#QNAN 1.#QNAN
> 
> print min(y), max(y) #prints 0.0 8.0
> 
> print min(z), max(z) #pritns 0.0 9.0
It's actually pure luck that min/max worked at all. What you want is 
numpy.nanmax() and numpy.nanmin() which properly handle NaN's in your array.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: David A. <dwa...@su...> - 2008年07月25日 17:51:31
All,
I am aware of the 3d examples at: http://scipy.org/Cookbook/ 
Matplotlib/mplot3D
However, this seems out of date, some examples work, some don't. Are 
there other pointers that show how I can use matplotlib to draw three 
dimensional surfaces similar to the ones drawn in Matlab with mesh, 
surf, and friends?
Any url's appreciated.
Thanks.
David
From: John H. <jd...@gm...> - 2008年07月25日 17:00:05
On Fri, Jul 25, 2008 at 10:22 AM, Peter Wesbdell
<fly...@go...> wrote:
> Hello all, my first post here.
>
> I am moving from using scilab to Pylab, can anyone tell me why the two
> following snippets of code produce very different results? BTW. The scilab
> code produces the expected result.
I don't know what scilab does, but the filling of the z array looks
wrong, since python indexing starts at 0, not 1, so you would want to
do
for i in range(0,100):
 for j in range(0,100):
but you rarely want to loop over arrays. My snippet below shows how
to use meshgrid to use numpy's elementwise operations and avoid loops.
 By only filling starting at 1, you are using the memory in the 0-th
row and column unintialized (np.zeros can be safer than np.empty in
this regard) Also, be careful when defining constants as integers,
since integer division produces integers (3/2=1)
Here is my script - does it produce what you are expecting?
import numpy as np
import matplotlib.pyplot as plt
Lx = 1.
Ly = 1.
n = 2.
m = 2.
f = 100.
w = 2*np.pi*f
t = 1.
A = 2.
Kx = n*np.pi/Lx
Ky = m*np.pi/Ly
x = np.arange(100.)
y = np.arange(100.)
X, Y = np.meshgrid(x, y)
Z = A * np.sin(Kx*X) * np.sin(Ky*Y) * np.exp(1j*w*t)
plt.contourf(Z)
plt.show()
>
> Scilab:
> Lx=1;
> Ly=1;
> n=2;
> m=2;
> f=100;
> w=2*%pi*f;
> t=1;
> A=2;
> Kx=n*%pi/Lx;
> Ky=m*%pi/Ly;
> x=linspace(0,100);
> y=linspace(0,100);
> z=zeros(100,100);
> for i = 1:100
> for j = 1:100
> z(i,j) = A * sin(Kx*x(i)) * sin(Ky*y(j)) * %e^(%i*w*t);
> end
> end
> contour(z)
>
>
> Pylab:
> from pylab import *
> Lx=1
> Ly=1
> n=2
> m=2
> f=100
> w=2*pi*f
> t=1
> A=2
> Kx=n*pi/Lx
> Ky=m*pi/Ly
> x=arange(0,100)
> y=arange(0,100)
> z=empty((100,100))
> for i in range(1,100):
> for j in range(1,100):
> z[i, j] = A * sin(Kx*x[i]) * sin(Ky*y[j]) * e**(1j*w*t)
> contourf(z)
> show()
>
> Cheers,
> Pete.
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: John H. <jd...@gm...> - 2008年07月25日 16:39:13
On Fri, Jul 25, 2008 at 10:08 AM, Ben Axelrod <bax...@co...> wrote:
> I have noticed 2 bugs having to do with NaN handling in the scatter()
I believe this is fixed in svn (0.98 branch) -- I tested your first
example and it behaved as expected. I f you have a build environment,
please test the release candidate
http://matplotlib.sourceforge.net/tmp/matplotlib-0.98.3rc1.tar.gz
Any other users who would like to test the release candidate, we would
be much obliged. We do not have any binaries for testing
unfortunately.
JDH
From: Peter W. <fly...@go...> - 2008年07月25日 15:39:48
Hello all, my first post here.
 
I am moving from using scilab to Pylab, can anyone tell me why the two
following snippets of code produce very different results? BTW. The scilab
code produces the expected result.
 
Scilab:
Lx=1;
Ly=1;
n=2;
m=2;
f=100;
w=2*%pi*f;
t=1;
A=2;
Kx=n*%pi/Lx;
Ky=m*%pi/Ly;
x=linspace(0,100);
y=linspace(0,100);
z=zeros(100,100);
for i = 1:100
 for j = 1:100
 z(i,j) = A * sin(Kx*x(i)) * sin(Ky*y(j)) * %e^(%i*w*t);
 end
end
contour(z)
 
 
Pylab:
from pylab import *
Lx=1
Ly=1
n=2
m=2
f=100
w=2*pi*f
t=1 
A=2
Kx=n*pi/Lx
Ky=m*pi/Ly
x=arange(0,100)
y=arange(0,100)
z=empty((100,100))
for i in range(1,100):
 for j in range(1,100):
 z[i, j] = A * sin(Kx*x[i]) * sin(Ky*y[j]) * e**(1j*w*t)
contourf(z)
show()
 
Cheers,
Pete.
From: Ben A. <bax...@co...> - 2008年07月25日 15:09:01
I have noticed 2 bugs having to do with NaN handling in the scatter() function. And one other bug that seems to be in numpy.
1. The min and max for the axes are not computed properly when there are NaNs in the data. Example:
import pylab as pl
import numpy as np
x = np.asarray([0, 1, 2, 3, None, 5, 6, 7, 8, 9], float)
y = np.asarray([0, None, 2, 3, 4, 5, 6, 7, 8, 9], float)
ax = pl.subplot(111)
ax.scatter(x, y)
pl.show()
The points with NaN values are left out of the plot as expected, but you will see that everything before the NaN is ignored when computing the axis ranges. (The X axis goes from 4 to 10, cutting off some data, when it should be from -1 to 10. The Y axis goes from 1 to 10 when it should be also be from -1 to 10.) This is rather annoying since these simple calls fix the issue:
ax.set_xlim(min(x), max(y))
ax.set_ylim(min(y), max(y))
2. We see the same behavior for the 'c' axis. Example:
import pylab as pl
import numpy as np
x = np.asarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], float)
y = np.asarray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], float)
z = np.asarray([0, 1, 2, 3, 4, 5, None, 7, 8, 9], float)
ax = pl.subplot(111)
ax.scatter(x, y, c=z)
pl.show()
We see that everything before point 7 has zero color. And we can bandaid fix it by adding:
ax.scatter(x, y, c=z,
 vmin=min(z),
 vmax=max(z))
Then only the one NaN point has zero color.
3. Both of the above mentioned bandaid fixes suffer from some bug (I think in numpy). Where the min() and max() of a numpy array where the first value is NaN, bugs out:
x = np.asarray([None, 1, 2, 3, 4, 5, 6, 7, 8, 9], float)
y = np.asarray([0, 1, 2, 3, 4, 5, 6, 7, 8, None], float)
z = np.asarray([0, 1, 2, 3, 4, 5, None, 7, 8, 9], float)
print min(x), max(x) #prints 1.#QNAN 1.#QNAN
print min(y), max(y) #prints 0.0 8.0
print min(z), max(z) #pritns 0.0 9.0
FYI, I am using MatPlotLib version 0.91.4 and NumPy 1.1.0 on windows and Debian Linux.
Thanks,
-Ben

Showing 7 results of 7

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