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



Showing results of 480

<< < 1 2 3 4 .. 20 > >> (Page 2 of 20)
From: Reinier H. <re...@he...> - 2009年09月30日 08:32:06
Hi,
I will have a look at mplot3d sub-plots next weekend and try to fix
issues like this. I'll also add a working example.
Cheers,
Reinier
On Tue, Sep 29, 2009 at 5:05 PM, Jae-Joon Lee <lee...@gm...> wrote:
> Hmm, axes3d does not seem to support it currently. I hope Reinier or
> others confirm this.
> Anyhow, here is a quick workaround you may try.
>
>
> from matplotlib.axes import subplot_class_factory
>
> class MyAxes3D(Axes3D):
>  def _button_press(self, event):
>    if event.inaxes == self:
>      Axes3D._button_press(self, event)
>
>
> Subplot3D = subplot_class_factory(MyAxes3D)
>
> This makes rotate/zoom is effective only in the axes where the initial
> button-press event occurred.
>
> While I think it is reasonable to have Subplot3D and above fix in
> place, I'll defer this to Reinier or others who better know how Axes3D
> works.
>
> Regards,
>
> -JJ
>
>
> On Tue, Sep 29, 2009 at 6:22 AM, <qu...@gm...> wrote:
>> Thanks,
>>
>> that works like a charm.
>>
>> final bonus question: How can i individually set the point of view/zoom level
>> for the different 3d subplots?
>>
>> Currently, when i rotate/zoom (with the mouse) in one subplot, the changes
>> are applied on all 3d subplots.
>>
>> Thanks again,
>> q
>>
>> On Mon, Sep 28, 2009 at 11:52:08PM -0400, Jae-Joon Lee wrote:
>>> Try below instead of Axes3D. Obviously, "131" is the geometry
>>> parameter for subplot command. You don't need to add "ax" to "fig"
>>> since Axes3D do that by itself.
>>>
>>> from matplotlib.axes import subplot_class_factory
>>> Subplot3D = subplot_class_factory(Axes3D)
>>>
>>> ax = Subplot3D(fig, 131)
>>>
>>> This will show you the title also. However, the 3d axes will occupy
>>> smaller area than the area of the subplot.
>>>
>>> Regards,
>>>
>>> -JJ
>>>
>>>
>>> On Mon, Sep 28, 2009 at 6:23 PM, <qu...@gm...> wrote:
>>> > Greetings,
>>> >
>>> > I would like to plot to make a figure with 3 subplots
>>> > of the form (221) to (223):
>>> > - each subplot should show a bar3d plot of a matrix
>>> > - each subplot should have it's own title
>>> >
>>> > The problems:
>>> > a) I don't see (nor did i find something) how i can
>>> >  use subplots combined with bar3d (from the mpl_toolkits.mplot3d)
>>> >  package.
>>> >
>>> > b) I don't manage to give the 3d bar plot a title. In the attached
>>> >  code you will see that a title is set, but it does not show
>>> >  up in the figure
>>> >
>>> > Could someone please help me out with these problems?
>>> >
>>> > Thanks,
>>> > q
>>> >
>>> > ---------------------
>>> >
>>> > The code for the basic plot of the matrix:
>>> >
>>> >
>>> > from mpl_toolkits.mplot3d import Axes3D
>>> > import matplotlib.pyplot as plt
>>> > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator
>>> > from numpy import *
>>> >
>>> > psi=1/sqrt(2)*array([1, 0, 0, 1])
>>> > rho=outer(psi,psi)
>>> >
>>> > fig = plt.figure()
>>> >
>>> > ax = Axes3D(fig)
>>> >
>>> > elements = (len(rho) * len(rho))
>>> > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25)
>>> >
>>> > xpos = xpos.flatten()
>>> > ypos = ypos.flatten()
>>> > zpos = zeros(elements)
>>> >
>>> > dx = 0.5 * ones_like(zpos)
>>> > dy = dx.copy()
>>> > dz = absolute(rho.flatten())
>>> >
>>> > ax.set_title('absolute')
>>> >
>>> > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800')
>>> >
>>> > plt.show()
>>> >
>>> >
>>> >
>>> > ------------------------------------------------------------------------------
>>> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>>> > is the only developer event you need to attend this year. Jumpstart your
>>> > developing skills, take BlackBerry mobile applications to market and stay
>>> > ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>>> > http://p.sf.net/sfu/devconf
>>> > _______________________________________________
>>> > Matplotlib-users mailing list
>>> > Mat...@li...
>>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> >
>>
>> --
>> The king who needs to remind his people of his rank, is no king.
>>
>> To gain that which is worth having, it may be necessary to lose everything else.
>>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Reinier Heeres
Tel: +31 6 10852639
From: David C. <da...@ar...> - 2009年09月30日 08:32:06
Hi Sandro,
(sorry for the private reply)
Sandro Tosi wrote:
> Hi David,
>
> On Wed, Sep 30, 2009 at 07:48, David Cournapeau
> <da...@ar...> wrote:
> 
>> Hi,
>>
>> I tried to build matplotlib in place (setup.py build_ext -i), and
>> found out that I could not import it:
>> 
>
> yes, you should be able to build it in-place (even if usually run
> 'python setup.py build' because I need the full package be available
> in build/<platform> ) even from the unpacked tarball or from svn
> trunk.
>
> 
>> matplotlib/rcsetup.py:117: UserWarning: rcParams key "numerix" is
>> obsolete and has no effect;
>> please delete it from your matplotlibrc file
>> warnings.warn('rcParams key "numerix" is obsolete and has no effect;\n'
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "pylab.py", line 1, in <module>
>> from matplotlib.pylab import *
>> File "matplotlib/pylab.py", line 206, in <module>
>> from matplotlib import mpl # pulls in most modules
>> File "matplotlib/mpl.py", line 2, in <module>
>> from matplotlib import axis
>> File "matplotlib/axis.py", line 10, in <module>
>> import matplotlib.font_manager as font_manager
>> File "matplotlib/font_manager.py", line 52, in <module>
>> from matplotlib import ft2font
>> ImportError: matplotlib/ft2font.so: undefined symbol: py_object_initializer
>> 
>
> what version are you using? 0.99.1.1, svn trunk, other?
> 
It ended up a confusion between the distutils build and the new scons
scripts I was working on, sorry for the noise.
The good news is that matplotlib can now be built with numscons, with
all scons goodies :)
David
From: Reinier H. <re...@he...> - 2009年09月30日 08:14:51
Hi,
On Wed, Sep 30, 2009 at 8:44 AM, dave martin <mp...@od...> wrote:
> hi
> i've just upgraded to 0.99, and trying out mplot3d for the first time -
> wondering if a few things are standard behaviour or not. any example i
> choose from the standard bunch will work fine with "%run ***" in
> ipython, but once the figure is drawn and closed, i no longer have the
> ability to plt.show().
This sounds like expected behavior to me; plot() is only supposed to
be called once to draw all the figures that have been generated up to
that point.
> also, if i don't %run anything, but try and work my way through
> interactively by ipython (with "-pylab") commands, no axes can be
> generated (Axes3D imported) with "ax=Axes3D(fig)" - just nothing
> happens in the figure brought up previously by "fig=plt.figure()".
Strange, but I indeed see the same behavior here; I'll look into it!
> if i start ipython without "-pylab", it works - sort of. running
> step-wise through the example will work fine, though i lose the ipython
> command line while the figure is open. when it's closed, though, i
> can't get another figure to display at all - sort of like the first
> problem i mentioned not being able to plt.show() again in the same
> interactive session.
Again, this is expected behavior.
> so, is this normal?
Concluding: partly yes, partly no, thanks for reporting!
Regards,
Reinier
>
> thanks
-- 
Reinier Heeres
Tel: +31 6 10852639
From: dave m. <mp...@od...> - 2009年09月30日 07:09:09
hi
i've just upgraded to 0.99, and trying out mplot3d for the first time -
wondering if a few things are standard behaviour or not. any example i
choose from the standard bunch will work fine with "%run ***" in
ipython, but once the figure is drawn and closed, i no longer have the
ability to plt.show().
also, if i don't %run anything, but try and work my way through
interactively by ipython (with "-pylab") commands, no axes can be
generated (Axes3D imported) with "ax=Axes3D(fig)" - just nothing
happens in the figure brought up previously by "fig=plt.figure()".
if i start ipython without "-pylab", it works - sort of. running
step-wise through the example will work fine, though i lose the ipython
command line while the figure is open. when it's closed, though, i
can't get another figure to display at all - sort of like the first
problem i mentioned not being able to plt.show() again in the same
interactive session.
so, is this normal?
thanks
From: Sandro T. <mat...@gm...> - 2009年09月30日 06:40:35
Hi David,
On Wed, Sep 30, 2009 at 07:48, David Cournapeau
<da...@ar...> wrote:
> Hi,
>
>  I tried to build matplotlib in place (setup.py build_ext -i), and
> found out that I could not import it:
yes, you should be able to build it in-place (even if usually run
'python setup.py build' because I need the full package be available
in build/<platform> ) even from the unpacked tarball or from svn
trunk.
> matplotlib/rcsetup.py:117: UserWarning: rcParams key "numerix" is
> obsolete and has no effect;
> please delete it from your matplotlibrc file
> warnings.warn('rcParams key "numerix" is obsolete and has no effect;\n'
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "pylab.py", line 1, in <module>
>  from matplotlib.pylab import *
> File "matplotlib/pylab.py", line 206, in <module>
>  from matplotlib import mpl # pulls in most modules
> File "matplotlib/mpl.py", line 2, in <module>
>  from matplotlib import axis
> File "matplotlib/axis.py", line 10, in <module>
>  import matplotlib.font_manager as font_manager
> File "matplotlib/font_manager.py", line 52, in <module>
>  from matplotlib import ft2font
> ImportError: matplotlib/ft2font.so: undefined symbol: py_object_initializer
what version are you using? 0.99.1.1, svn trunk, other?
Regards,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
From: David C. <da...@ar...> - 2009年09月30日 06:29:41
Hi,
 I tried to build matplotlib in place (setup.py build_ext -i), and
found out that I could not import it:
 matplotlib/rcsetup.py:117: UserWarning: rcParams key "numerix" is
obsolete and has no effect;
 please delete it from your matplotlibrc file
 warnings.warn('rcParams key "numerix" is obsolete and has no effect;\n'
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "pylab.py", line 1, in <module>
 from matplotlib.pylab import *
 File "matplotlib/pylab.py", line 206, in <module>
 from matplotlib import mpl # pulls in most modules
 File "matplotlib/mpl.py", line 2, in <module>
 from matplotlib import axis
 File "matplotlib/axis.py", line 10, in <module>
 import matplotlib.font_manager as font_manager
 File "matplotlib/font_manager.py", line 52, in <module>
 from matplotlib import ft2font
ImportError: matplotlib/ft2font.so: undefined symbol: py_object_initializer
Is this expected ?
cheers,
David
From: rafa5 <rap...@ya...> - 2009年09月30日 05:50:38
Hi guys,
I'm having problems creating a plot. I attached a crude version that I drew
with Gimp to show what I actually want to do with matplotlib 
http://www.nabble.com/file/p25667058/example2.png example2.png . Basically
it boils down to placing an axes instance on top of an existing axes with an
imshow already on it. In the end I would like to have a kind of lineout of
the values of the array of the imshow along an x=constant & y=constant line.
So my pathetic (and unsuccesful attempt) is something like:
import matplotlib.pyplot as p
fig = p.figure(1)
ax1_box = [0.1, 0.1, 0.5, 0.5]
ax2_box = [0.1, 0.1, 0.5, 0.1]
ax1 = fig.add_axes( ax1_box )
ax1.imshow(data)
ax2 = fig.add_axes( ax2_box, frameon=False)
ax2.plot( data[5 , :] ) #lineout of 6th row for
example
p.setp(ax2b, xticks=[], yticks=[])
My problems:
as I don't want to add axis labels ax2 data plot is wider than ax1 data
plot.
when i resize the window ax1 and ax2 move relative to another.
I hope it's possible to also do the lineput along the vertical (y) axis.
I'm too stupid to figure this out myself.
Thanks a lot in advance for any suggestions :)
Raphael
-- 
View this message in context: http://www.nabble.com/placing-a-plot-on-top-of-an-imshow-tp25667058p25667058.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Eric F. <ef...@ha...> - 2009年09月30日 02:33:30
jas...@cr... wrote:
> A couple of us are trying to figure out how to scale arrows in a quiver 
> plot so that we can exactly specify what the output arrows look like. 
> For example, we'd like to scale the vectors to half of their size, and 
> have it look like that on the quiver plot.
> 
> So I tried even just getting a quiver plot to plot an arrow exactly as I 
> passed it, without it scaling anything. My attempt is this:
> 
> import matplotlib.pylab as plt
> fig=plt.figure(figsize=[6,6])
> q=plt.quiver([0],[0],[1],[1],units='x',scale=1,angles='xy')
> ax=plt.axis([0,1.5,0,1.5])
> plt.grid(True)
> plt.savefig('test.png')
> 
> I'm trying to get the arrow to go from (0,0) to (1,1). However, with 
> units='x', it's just short, and with units='y', it's just a bit too 
> long. Furthermore, if I don't make the aspect ratio equal to one, I get 
> wild results since the x-axis and y-axis are different units then. It 
> would be really nice if there was a way to say units='data' (for data 
> coordinates), and then if scale=1, the arrows would be drawn with the 
> heads and tails at exactly the passed points. If scale=2, then each 
> arrow would be drawn exactly half of its length. I realize that 
> units='data' might mess up the other measurements of an arrow, though, 
> so maybe another parameter is called for, like a scale_units, that 
> defaults to units.
This sounds like a good idea. The present situation does the originally 
intended autoscaling of arrows reasonably well, but it is very confusing 
when you need more control. A scale_units parameter could make it much 
easier to figure out how to manually set the scale. I will look into 
it. It might be trivial, it might not.
Eric
From: <jas...@cr...> - 2009年09月30日 01:28:39
A couple of us are trying to figure out how to scale arrows in a quiver 
plot so that we can exactly specify what the output arrows look like. 
For example, we'd like to scale the vectors to half of their size, and 
have it look like that on the quiver plot.
So I tried even just getting a quiver plot to plot an arrow exactly as I 
passed it, without it scaling anything. My attempt is this:
import matplotlib.pylab as plt
fig=plt.figure(figsize=[6,6])
q=plt.quiver([0],[0],[1],[1],units='x',scale=1,angles='xy')
ax=plt.axis([0,1.5,0,1.5])
plt.grid(True)
plt.savefig('test.png')
I'm trying to get the arrow to go from (0,0) to (1,1). However, with 
units='x', it's just short, and with units='y', it's just a bit too 
long. Furthermore, if I don't make the aspect ratio equal to one, I get 
wild results since the x-axis and y-axis are different units then. It 
would be really nice if there was a way to say units='data' (for data 
coordinates), and then if scale=1, the arrows would be drawn with the 
heads and tails at exactly the passed points. If scale=2, then each 
arrow would be drawn exactly half of its length. I realize that 
units='data' might mess up the other measurements of an arrow, though, 
so maybe another parameter is called for, like a scale_units, that 
defaults to units.
What do people think?
Thanks,
Jason
From: Eric F. <ef...@ha...> - 2009年09月29日 21:42:37
TP wrote:
> Hi everybody,
> 
> I try to play with "sharex" feature. Then, I have been guided to the
> class "Grouper" of module cbook:
> 
> http://matplotlib.sourceforge.net/api/cbook_api.html
> 
> So I tried the following example:
> 
> ##############################
> from matplotlib.cbook import *
> 
> g = Grouper()
> g.join('a', 'b')
> ##############################
> 
> I obtain:
> 
> Traceback (most recent call last):
> File "test_grouper.py", line 4, in <module>
> g.join('a', 'b')
> File ".../matplotlib/cbook.py", line 1118, in join
> set_a = mapping.setdefault(ref(a), [ref(a)])
> TypeError: cannot create weak reference to 'str' object
> 
> What is the problem?
Grouper is implemented using weak references, which are supported only 
for some types of objects, as described here:
http://docs.python.org/library/weakref.html
Evidently the cbook Grouper docstring was written when the 
implementation was different, and did not use weakref. So, you have 
found a major bug in the docstring.
Eric
> 
> Thanks in advance,
> 
> Julien
> 
From: Rob F. <rob...@gm...> - 2009年09月29日 20:17:49
The rcParams list seems to list all settings regardless of whether or not
they are defined in matplotlibrc.
If I want the figure.facecolor to be white unless the user defines it as
something else in his or her matplotlibrc file, is there an easy way to do
that short of opening up matplotlib_fname() and parsing it myself?
figure.facecolor in returns True despite the fact that it is not defined in
matplotlibrc.
The following works, but it seems like there should be an easier way of
doing this
 try:
 f = open(matplotlib.matplotlib_fname(),'r')
 settings = [ line.split(':')[0].strip() for line in
f.readlines() if not line.strip().startswith('#') and
line.split(':')[0].strip() != '' ]
 f.close()
 if not 'figure.facecolor' in settings:
 raise ValueError
 except:
 matplotlib.rcParams['figure.facecolor'] = '#FFFFFF'
Thanks,
- Rob Falck
From: Christopher B. <Chr...@no...> - 2009年09月29日 20:03:46
Gökhan Sever wrote:
> This is technically called OpenGL backend, isn't it?
well, I think it's different -- he's not really using the standard 
backend API.
The trick with doing a real OpenGL back-end, is that a lot of 
computation time is spend doing transforms, and that can't be fully 
pushed to the back-end, because MPL provided arbitrary transforms.
There is also a fair bi tof time spent pushing data to the back-end.
I think to really get the benefit of OpenGL, you'd need the back-end to 
be semi-perstent -- you'd pass data in, and teh back-end would render it 
without having to pass the data in again. This would only support 
transforms that the back-end supports (linear only?). However, I think 
there could still be areal performance benefit bey breaking the 
transform pipeline into two parts -- one from arbitrary coordinates to 
something orthogonal and linear, and then a final one from that to 
screen coordinates (zooming and panning). Then you'd at least get full 
hardware accelerated performance for zooming and panning
We're doing this for a high-performance interactive mapping app, and 
it's working pretty well. However, OpenGL is pretty darn low-level, so 
there's a lot of code to write!
-Chris
-- 
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chr...@no...
From: Marco C. <ma...@gm...> - 2009年09月29日 19:28:27
Hello,
	I'm writing my thesis with the Lucida Bright font ( provided by the 
lucidabr package ) and I can't seem to get properly rendered fonts in 
any Matplotlib eps file. Setting the preamble with the rc variable 
doesn't look like a good idea, I even tried adding lucidabr to 
texmanager.py but I keep getting Computer Modern text.
	Any ideas ?
Ciao
~m
P.S.: the TeX preamble for lucidabr should be:
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{lucidabr}
From: Evan M. <eva...@gm...> - 2009年09月29日 18:43:25
On Tue, Sep 29, 2009 at 7:12 PM, Jeff Whitaker <js...@fa...> wrote:
> Evan Mason wrote:
>>
>> Hi, I've just upgraded to mpl 0.99 (from svn) and Basemap (also from svn).
>>
>>
>>
>
> Evan: I believe Ryan May just fixed this yesterday - so if you update
> basemap from svn again it should work.
>
> -Jeff
>>
>> It seems that plt.clim(vmin,vmax) no longer works with Basemap
>> objects. Here is an example, which before used to work:
>>
>>
>> In [92]: M.pcolormesh(x, y, a_var,cmap=cm)
>> Out[92]: <matplotlib.collections.QuadMesh object at 0x7f8f2faf3d90>
>>
>> In [93]: plt.clim(-10,10)
>>
>> ---------------------------------------------------------------------------
>> RuntimeError               Traceback (most recent call
>> last)
>>
>> /home/emason/pytools/fig_thesis_ssh_variance_prime_month.py in <module>()
>> ----> 1
>>   2
>>   3
>>   4
>>   5
>>
>> /usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in clim(vmin,
>> vmax)
>>  1379   im = gci()
>>  1380   if im is None:
>> -> 1381     raise RuntimeError('You must first define an image, eg
>> with imshow')
>>  1382
>>  1383   im.set_clim(vmin, vmax)
>>
>> RuntimeError: You must first define an image, eg with imshow
>>
>> In [94]:
>>
>>
>>
>> Using plt.pcolormesh there's no problem. Has this change been done
>> intentionally? If so, what is now the recommended way to apply
>> climits to a Basemap plot?
>>
>>
>> Thanks, Evan
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
> --
> 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
>
>
Yes, that works now. Thanks, Evan
From: Eric F. <ef...@ha...> - 2009年09月29日 18:23:19
Tsviki Hirsh wrote:
> Dear list,
> 
> Is it possible to specify to contourf an alpha value which is not a pure 
> number but lets say an array?
> I would like to change the value of alpha according to the contourf 
> values and to get in this way a fading effect on the vallies.
For contourf, one approach is to use the returned ContourSet.
cs = contourf(rand(10,10))
cs.collections[0].set_alpha(0.1)
draw()
So, you can cycle through the collections, setting the alpha for each to 
whatever you like.
> What about imshow?
You would need to set the alpha values in the _lut attribute of the 
colormap. Unfortunately, this is an area of alpha-handling that is 
still a mess. I'm not sure whether it works for some colormap types, 
but at least for ListedColormap, it doesn't. The alpha values of the 
input colors are ignored. I've been wanting to overhaul this, but 
obviously haven't gotten to it.
Eric
> 
> Thank you v much,
> I really enjoy the conversations in this list, and of course matplotlib.
> 
> Best Regards,
> Tsviki Hirsh
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jeff W. <js...@fa...> - 2009年09月29日 18:12:13
Evan Mason wrote:
> Hi, I've just upgraded to mpl 0.99 (from svn) and Basemap (also from svn).
>
>
> 
Evan: I believe Ryan May just fixed this yesterday - so if you update 
basemap from svn again it should work.
-Jeff
> It seems that plt.clim(vmin,vmax) no longer works with Basemap
> objects. Here is an example, which before used to work:
>
>
> In [92]: M.pcolormesh(x, y, a_var,cmap=cm)
> Out[92]: <matplotlib.collections.QuadMesh object at 0x7f8f2faf3d90>
>
> In [93]: plt.clim(-10,10)
> ---------------------------------------------------------------------------
> RuntimeError Traceback (most recent call last)
>
> /home/emason/pytools/fig_thesis_ssh_variance_prime_month.py in <module>()
> ----> 1
> 2
> 3
> 4
> 5
>
> /usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in clim(vmin, vmax)
> 1379 im = gci()
> 1380 if im is None:
> -> 1381 raise RuntimeError('You must first define an image, eg
> with imshow')
> 1382
> 1383 im.set_clim(vmin, vmax)
>
> RuntimeError: You must first define an image, eg with imshow
>
> In [94]:
>
>
>
> Using plt.pcolormesh there's no problem. Has this change been done
> intentionally? If so, what is now the recommended way to apply
> climits to a Basemap plot?
>
>
> Thanks, Evan
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
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: Ryan M. <rm...@gm...> - 2009年09月29日 18:06:53
On Tue, Sep 29, 2009 at 12:52 PM, Evan Mason <eva...@gm...> wrote:
> Hi, I've just upgraded to mpl 0.99 (from svn) and Basemap (also from svn).
>
>
>
> It seems that plt.clim(vmin,vmax) no longer works with Basemap
> objects. Here is an example, which before used to work:
>
>
> In [92]: M.pcolormesh(x, y, a_var,cmap=cm)
> Out[92]: <matplotlib.collections.QuadMesh object at 0x7f8f2faf3d90>
>
> In [93]: plt.clim(-10,10)
> ---------------------------------------------------------------------------
> RuntimeError               Traceback (most recent call last)
>
> /home/emason/pytools/fig_thesis_ssh_variance_prime_month.py in <module>()
> ----> 1
>   2
>   3
>   4
>   5
>
> /usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in clim(vmin, vmax)
>  1379   im = gci()
>  1380   if im is None:
> -> 1381     raise RuntimeError('You must first define an image, eg
> with imshow')
>  1382
>  1383   im.set_clim(vmin, vmax)
>
> RuntimeError: You must first define an image, eg with imshow
>
> In [94]:
>
>
>
> Using plt.pcolormesh there's no problem. Has this change been done
> intentionally? If so, what is now the recommended way to apply
> climits to a Basemap plot?
I think this is due to an issue I fixed yesterday. Matplotlib changed
how it handled tracking the current image (in trunk) and Basemap
hadn't been updated. A fresh pull of basemap (I checked in the
changes yesterday afternoon) should fix it. If not, we can dig
further.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Phillip M. F. <pfe...@ve...> - 2009年09月29日 18:00:49
Hello Eric,
The functions that I've created make it possible to generate a discrete 
(piecewise-constant) or continuous (piecewise-linear) colormap and 
register it at a single shot. These functions also accept a list of 
thresholds if the user wants to specify non-default thresholds. It 
seems as though the best alternatives require multiple steps and a 
considerable amount of fiddling. Furthermore, my functions are 
thoroughly documented, while the alternatives are not. I've found that 
it often takes less time to write something myself than to figure out 
how to use an undocumented function (which may not even do what I 
need). If you agree that my functions provide a better interface, then 
I hope that you and John Hunter can get them incorporated into matplotlib.
Yours,
Phillip
Eric Firing wrote:
> Dr. Phillip M. Feldman wrote:
>> After experimenting with colormaps for a while, I was able to make both
>> discrete (piecewise-constant) and continuous (piecewise-linear) 
>> colormaps
>> work. Although colormaps can be created directly using
>> LinearSegmentedColormap from the matplotlib.colors package, this is a
>> tedious and error-prone process. So, I compiled a set of three interface
>> functions. (I wrote two of these myself, and got one from the SciPy
>> website). The two functions that I wrote permit one to define a discrete
>> (piecewise-constant) and continuous (piecewise-linear) colormap 
>> directly via
>> a sequence of colors and a set of thresholds specified as lists. Each 
>> color
>> may be specified either via an RGB tuple or via an English color name 
>> known
>> to webcolors.name_to_rgb. I'm going to submit all of this to the 
>> matplotlib
>> developers forums in the hopes of getting it incorporated into 
>> matplotlib.
>
> Something I should have mentioned earlier: for the discrete case, one 
> good option is to use a ListedColormap to make a map with only a few 
> colors, and then use a BoundaryNorm to handle the mapping from data 
> values to colors. See 
> http://matplotlib.sourceforge.net/examples/pylab_examples/image_masked.html?highlight=image_masked 
>
> for a BoundaryNorm example. Unfortunately, we don't have an example 
> of using it with a ListedColormap, but it should be straigtforward; 
> the key point is to set the BoundaryNorm ncolors kwarg to match the 
> actual number of colors in the colormap.
>
> Eric
>
From: Evan M. <eva...@gm...> - 2009年09月29日 17:53:01
Hi, I've just upgraded to mpl 0.99 (from svn) and Basemap (also from svn).
It seems that plt.clim(vmin,vmax) no longer works with Basemap
objects. Here is an example, which before used to work:
In [92]: M.pcolormesh(x, y, a_var,cmap=cm)
Out[92]: <matplotlib.collections.QuadMesh object at 0x7f8f2faf3d90>
In [93]: plt.clim(-10,10)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
/home/emason/pytools/fig_thesis_ssh_variance_prime_month.py in <module>()
----> 1
 2
 3
 4
 5
/usr/lib64/python2.6/site-packages/matplotlib/pyplot.pyc in clim(vmin, vmax)
 1379 im = gci()
 1380 if im is None:
-> 1381 raise RuntimeError('You must first define an image, eg
with imshow')
 1382
 1383 im.set_clim(vmin, vmax)
RuntimeError: You must first define an image, eg with imshow
In [94]:
Using plt.pcolormesh there's no problem. Has this change been done
intentionally? If so, what is now the recommended way to apply
climits to a Basemap plot?
Thanks, Evan
From: Eric F. <ef...@ha...> - 2009年09月29日 17:44:57
Ralph Kube wrote:
> Hey everybody,
> thank you for your answers. I use matplotlib from qt4 now. What I do is
> creating a widget in a gui and using this for plotting. The plot is to
> refreshed by clicking on a button. This works perfectly fine,
> until I start adding a colorbar to the plot.
> When I add the colorbar and replot the whole thing, the plot doesnt
> fill up the area of the widget in the gui, but roughly 80% of the
> horizontal extent of the last plot. So when I replot in the axes, my
> plot shrinks around 20% horizontally every time I click on the button.
> I found out how to delete the old colorbar, but where do I tell
> matplotlib to plot into the whole extent of the plot?
The colorbar method or pyplot function optionally resizes the image axes 
and uses the liberated space to make an axes for itself. For your 
application, you don't want to use this option; you need to make the 
axes object manually and use the cax kwarg to tell colorbar to use it. 
Or you could generate it automatically the first time, and then reuse it 
for all subsequent colorbar calls.
Eric
> 
> 
> This is the widget i instantiate in my gui:
> 
> 
> class MyMplCanvas(FigureCanvas):
> 	def __init__(self, parent=None, width = 10, height = 12, dpi = 100, 
> sharex = None, sharey = None):
> 	 self.fig = Figure(figsize = (width, height), dpi=dpi, facecolor = 
> '#FFFFFF')
> 	self.ax = self.fig.add_subplot(111, sharex = sharex, sharey = sharey)
> 	self.fig.subplots_adjust(left=0.1, bottom=0.15, right=0.9, top=0.9)
> 	self.xtitle="x [a.u.]"
> 	self.ytitle="y [a.u.]"
> 	self.PlotTitle = ""
> 	self.grid_status = True
> 	self.xaxis_style = 'linear'
> 	self.yaxis_style = 'linear'
> 	self.format_labels()
> 	self.ax.hold(False)
> .......
> 
> 
> And this would be the code I call for plotting:
> 
> 	elif self.ui.radioButton_theta.isChecked() :
> 		data = N.vstack([ self.data_theta[self.nx/2:,:,self.filepos], 
> self.data_theta[:self.nx/2,:,self.filepos]] )
> 		title_str = 'Theta T.%03d' % self.filepos
> 
> 		self.ui.widget.canvas.ax.collections = []
> 		plt = self.ui.widget.canvas.ax.contourf(data)
> 		self.ui.widget.canvas.fig.colorbar(plt)
> 		self.ui.widget.canvas.PlotTitle = title_str
> 		self.ui.widget.canvas.print_figure('plot')
> 
> I thought the call self.ui.widget.canvas.ax.collections = [] clears the 
> axes. Any ideas?
> 
> Cheers, Ralph
> 
> 
> Eric Firing wrote:
>> Matthias Michler wrote:
>>> Hi Ralph,
>>>
>>> I don't think there exists a function like the line-'set_data'-method for 
>>> collections, which are generated by 'contour'. This particular method of 
>>> lines only changes the data but leave anything else unchanged.
>>> I attached an easy approach of updating a contour plot (simply deleting old 
>>> collections), but I'm not sure that this is the best solution.
>> I don't think you area gaining anything at all by manually deleting the 
>> collections. Better to just clear the axes, or clear the figure, and 
>> make a fresh plot.
>>
>> Eric
>>
>>
>>> Kind regards,
>>> Matthias
>>>
>>> On Monday 28 September 2009 13:52:42 Ralph Kube wrote:
>>>> Hi,
>>>> is there a way to update a contour plot? I need to display a series of
>>>> contour plots from a directory with data files and want to view them
>>>> consecutively, preferrably without building a gui for it. Is there an
>>>> easy way out?
>>>>
>>>> Cheers, Ralph
> 
> 
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Eric F. <ef...@ha...> - 2009年09月29日 17:38:17
Dr. Phillip M. Feldman wrote:
> After experimenting with colormaps for a while, I was able to make both
> discrete (piecewise-constant) and continuous (piecewise-linear) colormaps
> work. Although colormaps can be created directly using
> LinearSegmentedColormap from the matplotlib.colors package, this is a
> tedious and error-prone process. So, I compiled a set of three interface
> functions. (I wrote two of these myself, and got one from the SciPy
> website). The two functions that I wrote permit one to define a discrete
> (piecewise-constant) and continuous (piecewise-linear) colormap directly via
> a sequence of colors and a set of thresholds specified as lists. Each color
> may be specified either via an RGB tuple or via an English color name known
> to webcolors.name_to_rgb. I'm going to submit all of this to the matplotlib
> developers forums in the hopes of getting it incorporated into matplotlib.
Something I should have mentioned earlier: for the discrete case, one 
good option is to use a ListedColormap to make a map with only a few 
colors, and then use a BoundaryNorm to handle the mapping from data 
values to colors. See 
http://matplotlib.sourceforge.net/examples/pylab_examples/image_masked.html?highlight=image_masked
for a BoundaryNorm example. Unfortunately, we don't have an example of 
using it with a ListedColormap, but it should be straigtforward; the key 
point is to set the BoundaryNorm ncolors kwarg to match the actual 
number of colors in the colormap.
Eric
From: Jae-Joon L. <lee...@gm...> - 2009年09月29日 15:06:18
Hmm, axes3d does not seem to support it currently. I hope Reinier or
others confirm this.
Anyhow, here is a quick workaround you may try.
from matplotlib.axes import subplot_class_factory
class MyAxes3D(Axes3D):
 def _button_press(self, event):
 if event.inaxes == self:
 Axes3D._button_press(self, event)
Subplot3D = subplot_class_factory(MyAxes3D)
This makes rotate/zoom is effective only in the axes where the initial
button-press event occurred.
While I think it is reasonable to have Subplot3D and above fix in
place, I'll defer this to Reinier or others who better know how Axes3D
works.
Regards,
-JJ
On Tue, Sep 29, 2009 at 6:22 AM, <qu...@gm...> wrote:
> Thanks,
>
> that works like a charm.
>
> final bonus question: How can i individually set the point of view/zoom level
> for the different 3d subplots?
>
> Currently, when i rotate/zoom (with the mouse) in one subplot, the changes
> are applied on all 3d subplots.
>
> Thanks again,
> q
>
> On Mon, Sep 28, 2009 at 11:52:08PM -0400, Jae-Joon Lee wrote:
>> Try below instead of Axes3D. Obviously, "131" is the geometry
>> parameter for subplot command. You don't need to add "ax" to "fig"
>> since Axes3D do that by itself.
>>
>> from matplotlib.axes import subplot_class_factory
>> Subplot3D = subplot_class_factory(Axes3D)
>>
>> ax = Subplot3D(fig, 131)
>>
>> This will show you the title also. However, the 3d axes will occupy
>> smaller area than the area of the subplot.
>>
>> Regards,
>>
>> -JJ
>>
>>
>> On Mon, Sep 28, 2009 at 6:23 PM, <qu...@gm...> wrote:
>> > Greetings,
>> >
>> > I would like to plot to make a figure with 3 subplots
>> > of the form (221) to (223):
>> > - each subplot should show a bar3d plot of a matrix
>> > - each subplot should have it's own title
>> >
>> > The problems:
>> > a) I don't see (nor did i find something) how i can
>> >  use subplots combined with bar3d (from the mpl_toolkits.mplot3d)
>> >  package.
>> >
>> > b) I don't manage to give the 3d bar plot a title. In the attached
>> >  code you will see that a title is set, but it does not show
>> >  up in the figure
>> >
>> > Could someone please help me out with these problems?
>> >
>> > Thanks,
>> > q
>> >
>> > ---------------------
>> >
>> > The code for the basic plot of the matrix:
>> >
>> >
>> > from mpl_toolkits.mplot3d import Axes3D
>> > import matplotlib.pyplot as plt
>> > from matplotlib.ticker import FixedFormatter, LinearLocator, FixedLocator
>> > from numpy import *
>> >
>> > psi=1/sqrt(2)*array([1, 0, 0, 1])
>> > rho=outer(psi,psi)
>> >
>> > fig = plt.figure()
>> >
>> > ax = Axes3D(fig)
>> >
>> > elements = (len(rho) * len(rho))
>> > xpos, ypos = meshgrid(array(range(len(rho)))+0.25, array(range(len(rho)))+0.25)
>> >
>> > xpos = xpos.flatten()
>> > ypos = ypos.flatten()
>> > zpos = zeros(elements)
>> >
>> > dx = 0.5 * ones_like(zpos)
>> > dy = dx.copy()
>> > dz = absolute(rho.flatten())
>> >
>> > ax.set_title('absolute')
>> >
>> > ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color='#F8F800')
>> >
>> > plt.show()
>> >
>> >
>> >
>> > ------------------------------------------------------------------------------
>> > Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> > is the only developer event you need to attend this year. Jumpstart your
>> > developing skills, take BlackBerry mobile applications to market and stay
>> > ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> > http://p.sf.net/sfu/devconf
>> > _______________________________________________
>> > Matplotlib-users mailing list
>> > Mat...@li...
>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> >
>
> --
> The king who needs to remind his people of his rank, is no king.
>
> To gain that which is worth having, it may be necessary to lose everything else.
>
From: Uri L. <las...@mi...> - 2009年09月29日 14:35:56
Thanks so much for all the help! If my effort will produce something
nice, I'll forward it on...
Uri
On Mon, Sep 28, 2009 at 23:38, Jae-Joon Lee <lee...@gm...> wrote:
> The exception will go away if you explicitly use np.array as below.
>
>   box = np.array([[self.x, self.y1],
>           [self.x, self.y2]])
>
> However, note that Mike's example has x-center at 0.
>
> -JJ
>
>
> On Mon, Sep 28, 2009 at 6:41 PM, Uri Laserson <las...@mi...> wrote:
>> Hi Mike,
>>
>> This is definitely on the right track. Thanks a lot for writing it
>> out. When I change the view limits, indeed the width stays constant
>> while the height gets rescaled. However, when I try to change to a
>> logarithmic axis, I get the following errors. Again, excuse my
>> ignorance, but I am not sure where exactly the offense is and how to
>> fix it.
>>
>>
>> In [57]: ax.set_xscale('log')
>>
>> In [58]: plt.draw()
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (568, 0))
>>
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (568, 0))
>>
>> ERROR: An unexpected error occurred while tokenizing input
>> The following traceback may be corrupted or invalid
>> The error message is: ('EOF in multi-line statement', (568, 0))
>>
>> ---------------------------------------------------------------------------
>> TypeError                 Traceback (most recent call last)
>>
>> /Users/laserson/Desktop/<ipython console> in <module>()
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/pyplot.pyc
>> in draw()
>>  348 def draw():
>>  349   'redraw the current figure'
>> --> 350   get_current_fig_manager().canvas.draw()
>>  351
>>  352 @docstring.copy_dedent(Figure.savefig)
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/backends/backend_tkagg.pyc
>> in draw(self)
>>  213
>>  214   def draw(self):
>> --> 215     FigureCanvasAgg.draw(self)
>>  216     tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
>>  217     self._master.update_idletasks()
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/backends/backend_agg.pyc
>> in draw(self)
>>  376
>>  377     self.renderer = self.get_renderer()
>> --> 378     self.figure.draw(self.renderer)
>>  379
>>  380   def get_renderer(self):
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc
>> in draw_wrapper(artist, renderer, *kl)
>>   53   def draw_wrapper(artist, renderer, *kl):
>>   54     before(artist, renderer)
>> ---> 55     draw(artist, renderer, *kl)
>>   56     after(artist, renderer)
>>   57
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/figure.pyc
>> in draw(self, renderer)
>>  770
>>  771     # render the axes
>> --> 772     for a in self.axes: a.draw(renderer)
>>  773
>>  774     # render the figure text
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc
>> in draw_wrapper(artist, renderer, *kl)
>>   53   def draw_wrapper(artist, renderer, *kl):
>>   54     before(artist, renderer)
>> ---> 55     draw(artist, renderer, *kl)
>>   56     after(artist, renderer)
>>   57
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/axes.pyc
>> in draw(self, renderer, inframe)
>>  1743
>>  1744     for zorder, i, a in dsu:
>> -> 1745       a.draw(renderer)
>>  1746
>>  1747     renderer.close_group('axes')
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/artist.pyc
>> in draw_wrapper(artist, renderer, *kl)
>>   53   def draw_wrapper(artist, renderer, *kl):
>>   54     before(artist, renderer)
>> ---> 55     draw(artist, renderer, *kl)
>>   56     after(artist, renderer)
>>   57
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/patches.pyc
>> in draw(self, renderer)
>>  353
>>  354     path = self.get_path()
>> --> 355     transform = self.get_transform()
>>  356     tpath = transform.transform_path_non_affine(path)
>>  357     affine = transform.get_affine()
>>
>> /Users/laserson/Desktop/testMyPatch.py in get_transform(self)
>>   22   box = [[self.x, self.y1],
>>   23       [self.x, self.y2]]
>> ---> 24   box = self.axes.transData.transform(box)
>>   25
>>   26   # Get the width as a fraction of the axes width
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/transforms.pyc
>> in transform(self, points)
>>  1893   def transform(self, points):
>>  1894     return self._b.transform(
>> -> 1895       self._a.transform(points))
>>  1896   transform.__doc__ = Transform.transform.__doc__
>>  1897
>>
>> /Library/Frameworks/Python.framework/Versions/4.3.0/lib/python2.5/site-packages/matplotlib/transforms.pyc
>> in transform(self, points)
>>  1721       x_points = x.transform(points)[:, 0:1]
>>  1722     else:
>> -> 1723       x_points = x.transform(points[:, 0])
>>  1724       x_points = x_points.reshape((len(x_points), 1))
>>  1725
>>
>> TypeError: list indices must be integers
>>
>>
>>
>> On Mon, Sep 28, 2009 at 16:56, Michael Droettboom <md...@st...> wrote:
>>> Is the attached sort of what you want? It defines a custom rectangle by (x,
>>> w, y1, y2) and overrides the get_transform of the patch to update itself at
>>> draw time.
>>>
>>> Mike
>>>
>>> Uri Laserson wrote:
>>>>
>>>> On Mon, Sep 28, 2009 at 16:03, Michael Droettboom <md...@st...> wrote:
>>>>
>>>>>
>>>>> If I understand correctly, the top and bottom of the box are in data
>>>>> coordinates, the x-center of the box is in data coordinates, only the
>>>>> width
>>>>> of the box is in axes coordinates. Is that correct? If so, a
>>>>>
>>>>
>>>> That's exactly correct.
>>>>
>>>>
>>>>>
>>>>> PolyCollection won't be able to do this (directly), since that would
>>>>> require
>>>>> both the width and height to be in axes coordinates.
>>>>>
>>>>
>>>> In principle, could you use a blended tranform for that? Eitherway, I
>>>> don't think it would work, because the patch objects would be drawn to
>>>> specific Axes coords. If the scale is changed (e.g, by switching to
>>>> log scale), then what would prompt the Axes coords to be recalculated?
>>>> I was thinking earlier that I could compose the transData and
>>>> transAxes.inverse transforms to recalculate where the new Axes coord
>>>> should be, but Mike thought this approach would fail (though I'm still
>>>> not exactly sure why, no doubt because of my own ignorance).
>>>>
>>>> Uri
>>>>
>>>>
>>>>>
>>>>> Mike
>>>>>
>>>>> Eric Firing wrote:
>>>>>
>>>>>>
>>>>>> Uri Laserson wrote:
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Is it possible to specify a path object that will use different
>>>>>>> transforms for different vertices?
>>>>>>>
>>>>>>> This is again related to plotting a box whose height is specified by
>>>>>>> data coords, but whose width is a constant in axes coords regardless
>>>>>>> of scale (so linear and log x-scales would produce a box of the same
>>>>>>> width).
>>>>>>>
>>>>>>> Ideally, I would draw a path like this:
>>>>>>> 1. the center of the box would be located at x and bottom and top
>>>>>>> would be y1, y2, all in data coords
>>>>>>> 2. I would move to (x,y1) at the bottom-center of the box.
>>>>>>> 3. The x value would now need to be converted to Axes coords, possibly
>>>>>>> by applying transData + transAxes.inverted
>>>>>>> 4. I would want to draw a line to (x-0.1, y1) where x is now in axes
>>>>>>> coords and y is still in data coords. Then up, then right, then down,
>>>>>>> and then close the polygon.
>>>>>>>
>>>>>>> How do I implement this?
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> I must be missing something, because I still don't see why you can't do
>>>>>> all this very simply by using a PolyCollection, with the vertices in
>>>>>> axes
>>>>>> coordinates and the offset in data coordinates.
>>>>>>
>>>>>> Eric
>>>>>>
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> As I mentioned before, a blended transform would allow me to make the
>>>>>>> moves i am interested in. However, a change of scale would change the
>>>>>>> correspondence between data and axes coords, so the axes transform
>>>>>>> part of the blended axes would have to be recomputed everytime the
>>>>>>> scale changes based on where the (x,y1) point lands in the axes. Is
>>>>>>> this correct?
>>>>>>>
>>>>>>> Any suggestions are welcome...thanks!
>>>>>>>
>>>>>>> Uri
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------------------------
>>>>>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>>>>>> is the only developer event you need to attend this year. Jumpstart your
>>>>>> developing skills, take BlackBerry mobile applications to market and
>>>>>> stay
>>>>>> ahead of the curve. Join us from November 9&#45;12, 2009. Register
>>>>>> now&#33;
>>>>>> http://p.sf.net/sfu/devconf
>>>>>> _______________________________________________
>>>>>> Matplotlib-users mailing list
>>>>>> Mat...@li...
>>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Michael Droettboom
>>>>> Science Software Branch
>>>>> Operations and Engineering Division
>>>>> Space Telescope Science Institute
>>>>> Operated by AURA for NASA
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>> --
>>> Michael Droettboom
>>> Science Software Branch
>>> Operations and Engineering Division
>>> Space Telescope Science Institute
>>> Operated by AURA for NASA
>>>
>>>
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> import matplotlib.patches as mpatches
>>> import matplotlib.transforms as mtransforms
>>> import matplotlib.path as mpath
>>>
>>> class MyBox(mpatches.Patch):
>>>
>>>  def __init__(self, x, w, y1, y2, **kwargs):
>>>   self.x = x
>>>   self.w = w
>>>   self.y1 = y1
>>>   self.y2 = y2
>>>   mpatches.Patch.__init__(self, **kwargs)
>>>
>>>  def get_path(self):
>>>   return mpath.Path.unit_rectangle()
>>>
>>>  def get_transform(self):
>>>
>>>   # Transform the data-relative values
>>>   box = [[self.x, self.y1],
>>>       [self.x, self.y2]]
>>>   box = self.axes.transData.transform(box)
>>>
>>>   # Get the width as a fraction of the axes width
>>>   w = self.w * self.axes.bbox.width / 2.0
>>>
>>>   # Add it to the data-transformed coordinates
>>>   box[0][0] -= w
>>>   box[1][0] += w
>>>
>>>   return mtransforms.BboxTransformTo(mtransforms.Bbox(box))
>>>
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> patch = MyBox(0, 0.1, 0.5, 1.5)
>>> ax.add_patch(patch)
>>> ax.set_xlim((-1, 1))
>>> ax.set_ylim((0, 2))
>>>
>>> plt.show()
>>>
>>>
>>
>>
>>
>> --
>> Uri Laserson
>> PhD Candidate, Biomedical Engineering
>> Harvard Medical School (Genetics)
>> Massachusetts Institute of Technology (Mathematics)
>> phone +1 917 742 8019
>> las...@mi...
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
-- 
Uri Laserson
PhD Candidate, Biomedical Engineering
Harvard Medical School (Genetics)
Massachusetts Institute of Technology (Mathematics)
phone +1 917 742 8019
las...@mi...
From: Tsviki H. <tsv...@gm...> - 2009年09月29日 13:29:14
Dear list,
Is it possible to specify to contourf an alpha value which is not a pure
number but lets say an array?
I would like to change the value of alpha according to the contourf values
and to get in this way a fading effect on the vallies.
What about imshow?
Thank you v much,
I really enjoy the conversations in this list, and of course matplotlib.
Best Regards,
Tsviki Hirsh
From: Jeff W. <js...@fa...> - 2009年09月29日 12:02:52
John [H2O] wrote:
> I'm trying to 'automate' a few components within basemap. I have a pretty
> complicated, and assuredly poorly written, set of functions that allow me to
> 'dynamically' plot a grid of data (lon,lat).
>
> Here is one section where I try to deal with transforming the data based on
> the projection. 'data' is a grid, often of size 720x360 or 720x180,
> representing full globe or hemisphere at 0.5 degree resolution. 'outlon0',
> outlat0', and 'd*out' are the llcrnr coordinates and step. 'transform' is an
> option, that is set to True by default:
>
> 1680 ## set up transformations for the data array 
> 1681 if m.projection not in ['cyl','merc','mill']:
> 1682 lats = np.arange( outlat0, ( outlat0 + ( numygrid*dyout ) ),
> dyout )[:-1]
> 1683 lons = np.arange( outlon0, ( outlon0 + ( numxgrid*dxout ) ),
> dxout )[:-1]
> 1684 data = data[:-1,:-1]
> 1685 else:
> 1686 lats = np.arange( outlat0, ( outlat0 + ( numygrid*dyout ) ),
> dyout )
> 1687 lons = np.arange( outlon0, ( outlon0 + ( numxgrid*dxout ) ),
> dxout )
> 1688 
> 1689 ## transform to nx x ny regularly spaced native projection grid
> 1690 if transform:
> 1691 dx = 2.*np.pi*m.rmajor/len(lons)
> 1692 nx = int((m.xmax-m.xmin)/dx)+1; ny = int((m.ymax-m.ymin)/dx)+1
> 1693 if nx is 1:
> 1694 topodat = data
> 1695 else:
> 1696 topodat = m.transform_scalar(data,lons,lats,nx,ny)
> 1697 else:
> 1698 topodat = data
>
> The problem is, when I use the approach with a 'cyl' grid, then subsequently
> try to draw the lsmask, I get a failure. Is this approach incorrect? I had
> to use the if nx is 1 statement because it was crashing with zero division
> error in some cases.
>
> Thanks.
> 
John: Please supply us with a self-contained example triggering the 
error that we can run.
-Jeff
12 messages has been excluded from this view by a project administrator.

Showing results of 480

<< < 1 2 3 4 .. 20 > >> (Page 2 of 20)
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 によって変換されたページ (->オリジナル) /