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





Showing 10 results of 10

From: Andre' Walker-L. <wal...@gm...> - 2012年12月17日 23:55:00
> http://en.wikipedia.org/wiki/Polar_coordinate_system#Uniqueness_of_polar_coordinates
quoting from the site
'''
Where a unique representation is needed for any point, it is usual to limit r to non-negative numbers (r ≥ 0) and θ to the interval [0, 360°) or (−180°, 180°] (in radians, [0, 2π) or (−π, π]).[12] One must also choose a unique azimuth for the pole, e.g., θ = 0.
'''
Of course I don't have anything close to a scientific study of the following statement, but I suspect in practice (ie as polar coordinates are used in practice by working scientists), they expect to find values of "r" consistent with the above definition of unique - however, still wanting theta to not be bounded.
Taking another quote form the site
'''
Also, a negative radial coordinate is best interpreted as the corresponding positive distance measured in the opposite direction.
'''
How does one define opposite in polar coordinates? The natural definition for "opposite" direction is presumably theta --> theta + pi, as that definition would correspond to the same notion of "opposite" in Cartesian coordinates (take whatever direction you were drawing a line, and go in "-" that direction. If we agree that this is the sensible definition of opposite, then pyplot.polar is not representing this definition of opposite.
Attached are two plots. The first uses
''' as matplotlib is - neg_r.png '''
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(-np.pi, np.pi, 60)
r = t
plt.polar(t,r)
The second produces a curve which I say represents the natural definition of "opposite". Note, the tangents of the curves are also opposite as well
''' as matplotlib "should be" - neg_r_opposite.png '''
import numpy as np
import matplotlib.pyplot as plt
t = np.linspace(0, np.pi, 30)
r = t
plt.polar(t,r)
t_opp = np.linspace(np.pi,2*np.pi,30)
r_opp = t_opp - np.pi
plt.polar(t_opp,r_opp)
I have three points to make with these plots:
1) my definition of opposite makes more sense than the default behavior of matplotlib
2) other people may have different ideas about what is best
3) matplotlib should at least raise a NOISY warning about what it is doing.
Andre
From: Alan G I. <ala...@gm...> - 2012年12月17日 22:50:42
From: Andre' Walker-L. <wal...@gm...> - 2012年12月17日 22:36:38
On Dec 17, 2012, at 1:12 PM, Pierre Haessig wrote:
> Le 17/12/2012 21:59, Pierre Haessig a écrit :
>> Maybe this the code behind the masking of half your curve, but I don't
>> know more.
> Looking closer at the plot, the curve is actually not masked !
> 
> Actually the "rmin functionality' is activated with rmin=-2*pi so that
> the whole r-axis is offset by +2pi. The plot is therefore pretty
> consistent only it is not what you want, I guess.
> I don't know how to disable this radius offset functionality.
Hi Pierre, Bob and all,
I reiterate that in polar coordinates, a negative value of "r" does not make sense. It is confusing at best.
At the very least, I think matplotlib should raise a NOISY warning. (I just checked that it does not).
I would advocate for a change however. I suggest that given negative values of "r", pyplot.polar raises an error and exits. One could add a kwarg that allows you to override this default behavior, "neg_r=False" unless the user specifies otherwise.
In general, when I code things that don't make sense mathematically, I like it when the code tells me I made a dumb mistake. If the code is defaulting to "fixing" the dumb mistake for me without any explicit warnings, that is more likely to raise a more serious error in my code, and a much harder bug to track down.
My two cents (well, it looks like a bit more than two).
Regards,
Andre
From: Pierre H. <pie...@cr...> - 2012年12月17日 21:12:53
Le 17/12/2012 21:59, Pierre Haessig a écrit :
> Maybe this the code behind the masking of half your curve, but I don't
> know more.
Looking closer at the plot, the curve is actually not masked !
Actually the "rmin functionality' is activated with rmin=-2*pi so that
the whole r-axis is offset by +2pi. The plot is therefore pretty
consistent only it is not what you want, I guess.
I don't know how to disable this radius offset functionality.
Best,
Pierre
From: Pierre H. <pie...@cr...> - 2012年12月17日 20:59:52
Hi Bob,
Le 17/12/2012 19:09, Bob Dowling a écrit :
>
> I am plotting a polar graph with some negative values of r. 
> Everything goes well until I try to use rgrids(). Am I doing
> something wrong? 
I just noticed that calling rgrids *after* plotting works nicely for me:
subplot(111, polar=True)
polar(t, r)
rgrids([2,4,6])
However, calling rgrids before plotting indeed leads to a weird
situation where only half of the curve is plotted. After digging in the
source code, this may relate to the `use_rmin` parameter in the
PolarTransform class init (in matplotlib.projections.polar)
In the tranform_non_affine method I see
# line 40-42:
 if self._axis is not None:
 if self._use_rmin:
 rmin = self._axis.viewLim.ymin
# [...]
 if rmin != 0:
 r = r - rmin
 mask = r < 0
 x[:] = np.where(mask, np.nan, r * np.cos(t))
 y[:] = np.where(mask, np.nan, r * np.sin(t))
 else:
 x[:] = r * np.cos(t)
 y[:] = r * np.sin(t)
Maybe this the code behind the masking of half your curve, but I don't
know more.
Best,
Pierre
From: Andre' Walker-L. <wal...@gm...> - 2012年12月17日 19:04:03
> I am a matplotlib.pyplot novice, but I have looked through various FAQs to no avail.
> 
> I am plotting a polar graph with some negative values of r. Everything goes well until I try to use rgrids(). Am I doing something wrong?
> 
> I attach some demo scripts and their outputs.
> 
> version1.py uses rgrid() but only has positive values of r. Everything works the way I expect it to (see version1.png).
> 
> version2.py has negative values of r and the same call to rgrid() and misbehaves (see version2.png).
> 
> version3.py is the same as version2.py, but without the call to rgrids() (but with negative values of r). Again everything is as expected.
> 
> What am I doing wrong in version2.py?
and only because it (sadly) took me a few minutes to figure out (even though it seemed so obvious), to create the plot of your version 3, with only positively defined values for "r", you can do 
t = numpy.linspace(0,2*numpy.pi,61)
r = t
t2 = numpy.linspace(-numpy.pi,numpy.pi,61)
r2 = numpy.pi - t2
plt.polar(t,r)
plt.polar(t2,r2)
andre
From: Andre' Walker-L. <wal...@gm...> - 2012年12月17日 18:34:46
Hi Bob,
> I am a matplotlib.pyplot novice, but I have looked through various FAQs to no avail.
> 
> I am plotting a polar graph with some negative values of r. Everything goes well until I try to use rgrids(). Am I doing something wrong?
> 
> I attach some demo scripts and their outputs.
> 
> version1.py uses rgrid() but only has positive values of r. Everything works the way I expect it to (see version1.png).
> 
> version2.py has negative values of r and the same call to rgrid() and misbehaves (see version2.png).
> 
> version3.py is the same as version2.py, but without the call to rgrids() (but with negative values of r). Again everything is as expected.
> 
> What am I doing wrong in version2.py?
I am not sure why things work in version 3 and do not work in version 2. A guess would be how matplotlib is covering up illegal values of your "r" coordinate. Here I am only speaking from the math point of view, and not what is actually happening in matplotlib. I tired finding info in the docs, but did not succeed in getting 
The coordinates "t" and "r" are angle and radius. In polar coordinates, negative values of the radial coordinate "r" are not well defined, since in this coordinate system, you can not have negative values of a radius.
So my **guess** is that your problems are related to this ill definition of the radial coordinate. And that sometimes matplotlib can cover it up for you, and other times it complains more loudly.
Regards,
Andre
I am a matplotlib.pyplot novice, but I have looked through various FAQs 
to no avail.
I am plotting a polar graph with some negative values of r. Everything 
goes well until I try to use rgrids(). Am I doing something wrong?
I attach some demo scripts and their outputs.
version1.py uses rgrid() but only has positive values of r. Everything 
works the way I expect it to (see version1.png).
version2.py has negative values of r and the same call to rgrid() and 
misbehaves (see version2.png).
version3.py is the same as version2.py, but without the call to rgrids() 
(but with negative values of r). Again everything is as expected.
What am I doing wrong in version2.py?
From: Benjamin R. <ben...@ou...> - 2012年12月17日 15:18:35
On Sun, Dec 16, 2012 at 8:22 PM, Diego Avesani <die...@gm...>wrote:
> dear all,
> I have plot a 3D picture, I would like to have xy projection with contours
> levels and labels.
> The contours works but I do not get the labels.
>
> This is my code:
>
> import matplotlib.pyplot as plt
>
> from mpl_toolkits.mplot3d import axes3d, Axes3D
>
> fig = plt.figure()
>
> ax = Axes3D(fig) #<-- Note the difference from your original code...
>
>
> X, Y, Z = axes3d.get_test_data(0.05)
>
>
> cset = ax.contour(X, Y, Z,100,zdir='z',offset=-100)
>
> ax.clabel(cset, fontsize=9, inline=1)
>
>
> plt.show()import matplotlib.pyplot as plt
>
> from mpl_toolkits.mplot3d import axes3d, Axes3D #<-- Note the
> capitalization!
>
> fig = plt.figure()
>
>
> ax = Axes3D(fig) #<-- Note the difference from your original code...
>
>
> X, Y, Z = axes3d.get_test_data(0.05)
>
>
> cset = ax.contour(X, Y, Z,100,zdir='z',offset=-100)
>
> ax.clabel(cset, fontsize=9, inline=1)
>
>
> plt.show()
>
>
> Is it possible to have also the labels?
>
> Thanks
>
>
> Diego
>
>
Theoretically, yes. I have just never thought about that sort of feature
before, and it would not be trivial to implement. In the meantime, you can
take a look at this example for a way to manually label things in a 3d plot.
http://matplotlib.org/examples/mplot3d/text3d_demo.html
Ben Root
From: Diego A. <die...@gm...> - 2012年12月17日 01:22:21
dear all,
I have plot a 3D picture, I would like to have xy projection with contours
levels and labels.
The contours works but I do not get the labels.
This is my code:
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d, Axes3D
fig = plt.figure()
ax = Axes3D(fig) #<-- Note the difference from your original code...
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z,100,zdir='z',offset=-100)
ax.clabel(cset, fontsize=9, inline=1)
plt.show()import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import axes3d, Axes3D #<-- Note the
capitalization!
fig = plt.figure()
ax = Axes3D(fig) #<-- Note the difference from your original code...
X, Y, Z = axes3d.get_test_data(0.05)
cset = ax.contour(X, Y, Z,100,zdir='z',offset=-100)
ax.clabel(cset, fontsize=9, inline=1)
plt.show()
Is it possible to have also the labels?
Thanks
Diego

Showing 10 results of 10

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