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

Showing results of 419

<< < 1 .. 14 15 16 17 > >> (Page 16 of 17)
How do I draw two 3D surface plots where the surface patch colors have
consistent meaning?
Hope this makes sense ...
Currently, I'm just doing two plot_surface commands, each of which has
cmap=cm.jet. The two surfaces have different shapes and sizes and have
different highest/lowest points. It seems that the colormap is automatically
normalised to the highest/lowest values for each surface independently (e.g.
the highest point on both surfaces is red, even though they are different
values). Instead, I want the same color to represent the same value on both
surfaces.
Any ideas will be appreciated. Perhaps there's a way to force the colormap
to be normalised to a specified range of values?
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = 5*np.sin(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
Z = np.cos(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
plt.show()
How do I draw two 3D surface plots where the surface patch colors have
consistent meaning?
Hope this makes sense ...
Currently, I'm just doing two plot_surface commands, each of which has
cmap=cm.jet. The two surfaces have different shapes and sizes and have
different highest/lowest points. It seems that the colormap is automatically
normalised to the highest/lowest values for each surface independently (e.g.
the highest point on both surfaces is red, even though they are different
values). Instead, I want the same color to represent the same value on both
surfaces.
Any ideas will be appreciated. Perhaps there's a way to force the colormap
to be normalised to a specified range of values?
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = 5*np.sin(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
Z = np.cos(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
plt.show()
From: David Warde-F. <dw...@cs...> - 2009年10月02日 19:51:36
On 2-Oct-09, at 2:54 PM, Jae-Joon Lee wrote:
> I just noticed that there IS a public method.
> You may use
>
> leg.draw_frame(False)
Great!
On a related note, I just submitted a patch to fix the box() command 
in pyplot to accept the 'off' argument like axis() does. I thought I 
was going a little crazy when it just wouldn't work, then I looked at 
the source code. :)
https://sourceforge.net/tracker/?func=detail&aid=2871949&group_id=80706&atid=560720
David
From: Jae-Joon L. <lee...@gm...> - 2009年10月02日 19:07:53
On Fri, Oct 2, 2009 at 7:30 AM, rafa5 <rap...@ya...> wrote:
>
> I had to change the inset_locater.py file a little though. In your suggested
> code below :
>
> axins1 = inset_axes(ax, width="100%", height="20%",
>          loc=3, borderpad=0,
>          axes_kwargs=dict(frameon=False)
>          )
>
> the kwarg 'borderpad' was not doing anything because it was not being passed
> to 'AnchoredSizeLocator', so there is a slightly modified version that works
> for me attached that replaces the old one in
> /usr/share/pyshared/mpl_toolkits/axes_grid
>
The attachment is missing.
However, I think this is already fixed in the svn.
http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/lib/mpl_toolkits/axes_grid/inset_locator.py?view=diff&r1=7729&r2=7730
I should have checked whether my code works in the released version.
Regards,
-JJ
> before anyone uses it maybe one of you more expereinced guys can say whether
> it makes sense what I did.
>
> For the lineout along the y axis I just changed the width to 20% and the
> height to 100% and always set the correct data limits by using
> axins1.set_ylim( ymiin= ... , ymax= ...).
>
> Thanks again for your help :)
>
> Raphael
>
>
>
> Jae-Joon Lee wrote:
>>
>> Can you just reuse the ax1 for plotting? I guess that might be the easiest
>> way.
>>
>> With imshow, the location of ax1 is determined at the drawing time,
>> therefore you need a way to adjust the location of ax2 after this
>> happens. Doing this manually requires some internal knowledge of mpl.
>>
>> If you use 0.99 and later, you can use axes_grid toolkits. Here is an
>> example code.
>>
>> import matplotlib.pyplot as plt
>> from mpl_toolkits.axes_grid.inset_locator import inset_axes
>>
>> fig = plt.figure(1, [5.5, 3])
>> ax = fig.add_subplot(1,1,1)
>> ax.set_aspect(1.)
>>
>> axins1 = inset_axes(ax, width="100%", height="20%",
>>          loc=3, borderpad=0,
>>          axes_kwargs=dict(frameon=False)
>>          )
>>
>> axins1.xaxis.set_visible(False)
>> axins1.yaxis.set_visible(False)
>> axins1.plot([0, 0.5, 1], [0,1,0])
>>
>> plt.show()
>>
>> See here for more details.
>>
>> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html
>>
>> One thing to note, the current design of mpl does not allow you to
>> share axis when aspect is set(i.e., w/ imshow) (or you have to have
>> adjustable="datalim"), although there is a way to do it with
>> axes_grid.
>>
>> Regards,
>>
>> -JJ
>>
>>
>>
>> On Wed, Sep 30, 2009 at 1:50 AM, rafa5 <rap...@ya...>
>> wrote:
>>>
>>> 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.
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Come build with us! The BlackBerry® 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-12, 2009. Register now!
>>> http://p.sf.net/sfu/devconf
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry® 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-12, 2009. Register
>> now!
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
> http://www.nabble.com/file/p25714268/inset_locator.py inset_locator.py
> --
> View this message in context: http://www.nabble.com/placing-a-plot-on-top-of-an-imshow-tp25667058p25714268.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® 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-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Jae-Joon L. <lee...@gm...> - 2009年10月02日 18:55:10
I just noticed that there IS a public method.
You may use
leg.draw_frame(False)
-JJ
On Fri, Oct 2, 2009 at 2:45 PM, Jae-Joon Lee <lee...@gm...> wrote:
> While it is not possible to toggle the box off during the
> initialization, you can turn it off after the legend is created.
>
> leg = legend()
> leg._drawFrame=False
>
> public methods and initialization option will be added in the future release.
>
> Regards,
>
> -JJ
>
>
>
> On Fri, Oct 2, 2009 at 2:02 PM, David Warde-Farley <dw...@cs...> wrote:
>> Hmm, that's odd, I still haven't seen my question go up.
>>
>> I suppose I will re-ask it, then: turning the border off of the
>> legend. Is there an easy way, like MATLAB's legend('boxoff')?
>>
>> David
>>
>>
>> Begin forwarded message:
>>
>>> Is there a simple way to turn off the border of an inset legend?
>>>
>>> Regards,
>>>
>>> David
>>
>>
>> ------------------------------------------------------------------------------
>> 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: Jae-Joon L. <lee...@gm...> - 2009年10月02日 18:51:46
While it is not possible to toggle the box off during the
initialization, you can turn it off after the legend is created.
leg = legend()
leg._drawFrame=False
public methods and initialization option will be added in the future release.
Regards,
-JJ
On Fri, Oct 2, 2009 at 2:02 PM, David Warde-Farley <dw...@cs...> wrote:
> Hmm, that's odd, I still haven't seen my question go up.
>
> I suppose I will re-ask it, then: turning the border off of the
> legend. Is there an easy way, like MATLAB's legend('boxoff')?
>
> David
>
>
> Begin forwarded message:
>
>> Is there a simple way to turn off the border of an inset legend?
>>
>> Regards,
>>
>> David
>
>
> ------------------------------------------------------------------------------
> 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: Michael D. <md...@st...> - 2009年10月02日 18:39:38
matplotlib should pick up your installed fonts on OS-X --- but 
matplotlib only supports TrueType (and some OpenType) fonts. It won't 
work with Type 1 fonts -- it that what those particular ones are? Are 
you not able to use any of your installed fonts, or only some of them?
Cheers,
Mike
On 10/02/2009 01:59 PM, Buz Barstow wrote:
> Dear All,
>
> I'm trying to get matplotlib to use some of my MacOSX fonts (Helvetica
> and Times) so that I can produce plots with these two fonts.
>
> I'm using matplotlib installed with fink on MacOSX 10.5.8, and using
> XQuartz 2.4.0.
>
> Has anyone tried to do this, and can they point me to a procedure to
> make matplotlib find these fonts?
>
> Thanks! and all the best,
>
> --Buz
>
>
>
> ------------------------------------------------------------------------------
> 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: Nicolas B. <nbi...@gm...> - 2009年10月02日 18:34:43
I was looking for something similar. It seems Axes3D() takes the angle as
argument:
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d as m3d
fig = plt.figure()
ax = m3d.Axes3D(fig, elev = 20.0, azim = 45)
in degrees.
2009年10月2日 German Ocampo <ger...@gm...>
> Hello
>
> After search in google, I found a solution changing the initial point
> of view of the plot, using a function which control the angle and
> elevation of the initial view:
>
> ax.view_init(elevation, azimuth) and tried and works
>
> ax = Axes3D(fig)
> ax.view_init(64, -30)
>
> Question: Is it possible to include this function in the Axes3D
> documentation web page? or where I could find it in the webpage?
>
>
> http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/api.html?highlight=axes3d#module-mpl_toolkits.mplot3d.axes3d
>
> Thanks
>
> German
>
>
> On Fri, Oct 2, 2009 at 1:24 PM, German Ocampo <ger...@gm...> wrote:
> > Hello everybody
> >
> > How can I control the size of the Z axis in a 3D plot using Axes3D in
> > matplotlib?
> >
> > regards
> >
> > german
> >
>
>
> ------------------------------------------------------------------------------
> 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: David Warde-F. <dw...@cs...> - 2009年10月02日 18:18:57
Hmm, that's odd, I still haven't seen my question go up.
I suppose I will re-ask it, then: turning the border off of the 
legend. Is there an easy way, like MATLAB's legend('boxoff')?
David
Begin forwarded message:
> Is there a simple way to turn off the border of an inset legend?
>
> Regards,
>
> David
From: David Warde-F. <dw...@cs...> - 2009年10月02日 18:18:53
Is there a simple way to turn off the border of an inset legend?
Regards,
David
From: Jae-Joon L. <lee...@gm...> - 2009年10月02日 18:13:15
On Fri, Oct 2, 2009 at 11:52 AM, Jae-Joon Lee <lee...@gm...> wrote:
> The attachment is missing.
My bad. There IS an attachment. Again, this is bug is already fixed in svn.
Also, If you can, please post a diff file which makes the job a lot easier.
Regards,
-JJ
From: Buz B. <bu...@ma...> - 2009年10月02日 18:00:11
Dear All,
I'm trying to get matplotlib to use some of my MacOSX fonts (Helvetica 
and Times) so that I can produce plots with these two fonts.
I'm using matplotlib installed with fink on MacOSX 10.5.8, and using 
XQuartz 2.4.0.
Has anyone tried to do this, and can they point me to a procedure to 
make matplotlib find these fonts?
Thanks! and all the best,
--Buz
From: Michael D. <md...@st...> - 2009年10月02日 14:46:13
If you assign each figure to a new number, it will keep all of those 
figures around in memory (because pyplot thinks you may want to use it 
again.) The best route is to call close('all') or fig.close() with each 
loop iteration.
40MB per image doesn't sound way out of reason to me. How big are your 
images?
Mike
On 10/01/2009 10:25 PM, Leo Trottier wrote:
> I have a friend who's having strange memory issues when opening and 
> displaying images (using Matplotlib).
>
> Here's what he says:
> #######################################
>
> pylab seems really inefficient: Opening a few images and displaying 
> them eats up tons of memory, and the memory doesn't get freed.
>
> Starting python, and run
>
> In [5]: from glob import *;
>
> In [6]: from pylab import *
>
> python has 33MB of memory.
>
>
> Run
>
> In [7]: i = 1
>
> In [8]: for imname in glob("*.JPG"):
> ...: im = imread(imname)
> ...: figure(i); i = i+1
> ...: imshow(im)
> ...:
>
> This opens 10 figures and displays them. Python takes 480MB of memory. 
> This is crazy, for 10 images -- 40+MB of memory for each!
>
> In [14]: close("all")
>
> In [15]: i = 1
>
> In [16]: for imname in glob("*.JPG"):
> im = imread(imname)
> figure(i); i = i+1
> imshow(im)
> ....:
> ....:
>
> This closes all figures and opens them again. Python takes up 837MB of 
> memory.
>
> and so on... Something is really wrong with memory management.
>
> ##### System info: ##############
>
> (using macosx backend)
>
> 2.4GHz MacBook Pro Intel Core 2 Duo
>
> 4GB 667MHz DDR2 SDRAM
>
> In [5]: sys.version
> Out[5]: '2.6.2 (r262:71600, Oct 1 2009, 16:44:23) \n[GCC 4.2.1 (Apple 
> Inc. build 5646)]'
>
> In [6]: numpy.__version__
> Out[6]: '1.3.0'
>
> In [7]: matplotlib.__version__
> Out[7]: '0.99.1.1'
>
> In [8]: scipy.__version__
> Out[8]: '0.7.1'
>
> In [9]:
>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> 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: German O. <ger...@gm...> - 2009年10月02日 14:04:53
Hello
After search in google, I found a solution changing the initial point
of view of the plot, using a function which control the angle and
elevation of the initial view:
ax.view_init(elevation, azimuth) and tried and works
ax = Axes3D(fig)
ax.view_init(64, -30)
Question: Is it possible to include this function in the Axes3D
documentation web page? or where I could find it in the webpage?
http://matplotlib.sourceforge.net/mpl_toolkits/mplot3d/api.html?highlight=axes3d#module-mpl_toolkits.mplot3d.axes3d
Thanks
German
On Fri, Oct 2, 2009 at 1:24 PM, German Ocampo <ger...@gm...> wrote:
> Hello everybody
>
> How can I control the size of the Z axis in a 3D plot using Axes3D in
> matplotlib?
>
> regards
>
> german
>
From: marcog <ma...@ga...> - 2009年10月02日 13:03:45
Hi there
I am plotting a bar graph and would like to label the bars (rectangles) with
their quantities. If a bar represents 12 items I want a "12" on the top-end
of the bar, preferable on the edge of the bar and not off the chart as with
a table.
Is this possible?
Thanks
Marco
-- 
View this message in context: http://www.nabble.com/Labelling-Rectangles-tp25714962p25714962.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: German O. <ger...@gm...> - 2009年10月02日 12:50:36
Hello everybody
How can I control the size of the Z axis in a 3D plot using Axes3D in
matplotlib?
regards
german
How do I draw two 3D surface plots where the surface patch colors have
consistent meaning?
Hope this makes sense ...
Currently, I'm just doing two plot_surface commands, each of which has
cmap=cm.jet. The two surfaces have different shapes and sizes and have
different highest/lowest points. It seems that the colormap is automatically
normalised to the highest/lowest values for each surface independently (e.g.
the highest point on both surfaces is red, even though they are different
values). Instead, I want the same color to represent the same value on both
surfaces.
Any ideas will be appreciated. Perhaps there's a way to force the colormap
to be normalised to a specified range of values?
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = Axes3D(fig)
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = 5*np.sin(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
Z = np.cos(R)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
plt.show()
From: rafa5 <rap...@ya...> - 2009年10月02日 11:30:19
I had to change the inset_locater.py file a little though. In your suggested
code below :
axins1 = inset_axes(ax, width="100%", height="20%",
 loc=3, borderpad=0,
 axes_kwargs=dict(frameon=False)
 )
the kwarg 'borderpad' was not doing anything because it was not being passed
to 'AnchoredSizeLocator', so there is a slightly modified version that works
for me attached that replaces the old one in
 /usr/share/pyshared/mpl_toolkits/axes_grid
before anyone uses it maybe one of you more expereinced guys can say whether
it makes sense what I did.
For the lineout along the y axis I just changed the width to 20% and the
height to 100% and always set the correct data limits by using
axins1.set_ylim( ymiin= ... , ymax= ...).
Thanks again for your help :)
Raphael
Jae-Joon Lee wrote:
> 
> Can you just reuse the ax1 for plotting? I guess that might be the easiest
> way.
> 
> With imshow, the location of ax1 is determined at the drawing time,
> therefore you need a way to adjust the location of ax2 after this
> happens. Doing this manually requires some internal knowledge of mpl.
> 
> If you use 0.99 and later, you can use axes_grid toolkits. Here is an
> example code.
> 
> import matplotlib.pyplot as plt
> from mpl_toolkits.axes_grid.inset_locator import inset_axes
> 
> fig = plt.figure(1, [5.5, 3])
> ax = fig.add_subplot(1,1,1)
> ax.set_aspect(1.)
> 
> axins1 = inset_axes(ax, width="100%", height="20%",
> loc=3, borderpad=0,
> axes_kwargs=dict(frameon=False)
> )
> 
> axins1.xaxis.set_visible(False)
> axins1.yaxis.set_visible(False)
> axins1.plot([0, 0.5, 1], [0,1,0])
> 
> plt.show()
> 
> See here for more details.
> 
> http://matplotlib.sourceforge.net/mpl_toolkits/axes_grid/users/overview.html
> 
> One thing to note, the current design of mpl does not allow you to
> share axis when aspect is set(i.e., w/ imshow) (or you have to have
> adjustable="datalim"), although there is a way to do it with
> axes_grid.
> 
> Regards,
> 
> -JJ
> 
> 
> 
> On Wed, Sep 30, 2009 at 1:50 AM, rafa5 <rap...@ya...>
> wrote:
>>
>> 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.
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry® 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-12, 2009. Register now!
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
> 
> ------------------------------------------------------------------------------
> 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
> 
> 
http://www.nabble.com/file/p25714268/inset_locator.py inset_locator.py 
-- 
View this message in context: http://www.nabble.com/placing-a-plot-on-top-of-an-imshow-tp25667058p25714268.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
How do I draw two 3D surface plots where the surface patch colors have
consistent meaning?
Currently, I'm just doing two plot_surface commands, each of which has
cmap=cm.jet. The two surfaces have different shapes and sizes and have
different highest/lowest points. I seems that the colormap is automatically
normalised to the highest/lowest values for each surface independently (e.g.
the highest point on both surfaces is red, even though they are different
values). Instead, I want the same color to represent the same value on both
surfaces.
Any ideas will be appreciated. Perhaps there's a way to force the colormap
to be normalised to a specified range of values?
Thanks!
-- 
View this message in context: http://www.nabble.com/How-to-draw-two-3D-surface-plots-where-colors-represent-same-value-on-both-surfaces-tp25714142p25714142.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Ernest A. <ead...@gm...> - 2009年10月02日 10:22:12
Hi,
 1/10/09 @ 18:17 (-0700), thus spake Matthew Neeley:
> Here is a snippet that might get you started:
> 
> 
> import numpy as np
> from matplotlib import pyplot as plt
> from matplotlib import cm
> import mpl_toolkits.mplot3d as plt3
> 
> data = np.random.random((8,8))**4
> cmap = cm.RdBu
> 
> fig = plt.figure()
> ax = plt3.Axes3D(fig)
> 
> d = 0.1
> 
> w, h = data.shape
> for x in range(w):
> for y in range(h):
> ax.bar3d([x+d], [y+d], [0], 1-d, 1-d, data[x,y], cmap(data[x,y]))
> ax.set_zlim3d((0, 1))
> plt.show()
> 
> Obviously, you should replace data with the actual data you want to
> plot (maybe numpy can help with the histogramming), and use an
> appropriate cmap for your data. Note that in this case the entire box
> is a single color, not shaded up the side as in the example you
> referenced; I actually like it this way but I also don't know how one
> would do the shading in matplotlib. I'll admit it's rather silly to
> have to create all these boxes individually, but that's the only way I
> could see to color each box according to its height. The variable d
> just puts gaps between boxes; you could set this to zero to make the
> boxes adjacent.
> 
> I haven't figured out how to properly set the tick labels on the x and
> y axis in a 3d plot like this. Also, there are often some z-order
> errors with boxes occluding each other when they shouldn't. I don't
> know the details of how these things work internally; maybe some
> experts could weigh in here.
Great!! I like the shading this way, so no problem here.
Too bad about the rendering glitches though. Although, maybe that
can be sorted out by increasing the distance between boxes...? I will
experiment a little with this method of yours as it does basically what
I wanted. If everything fails I think I will finally use a 2-d plot
using a colour map to represent the height of bars,
as in here: http://www.davidbdean.com/wp-content/uploads/hist2d.png
Thanks a lot!
Bye.
-- 
Ernest
From: Ernest A. <ead...@gm...> - 2009年10月02日 10:09:04
Hi,
 1/10/09 @ 19:23 (-0500), thus spake Gökhan Sever:
> Although it is not an exact histogram, if you are you looking for a
> Pythonic alternative you might consider using Mayavi. It has ready
> barchart plotting functionality. Probably with some effort a 2D
> histogram as you linked might be created.
> 
> http://code.enthought.com/projects/mayavi/docs/development/html/mayavi/auto/mlab_helper_functions.html#barchart
Yes, it looks like it! I actually had already had a look at mayavi
but found it overly complicated for a simple histogram. If it has
simple bar chart functionality may be an option though.
Cheers.
-- 
Ernest
From: Steven N. <ste...@gm...> - 2009年10月02日 04:04:21
Hello,
I wrote the following scripts and expected that the y-axis of the figure
changed after each calculation.
But it did't work(the plot stayed at the very first state)
Can somebody help me fix this?
Thanks!
import numpy
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
def calulate1(steps_num):
 cell_num = 200 # Set the cell number.
 hy = numpy.zeros((1,cell_num),float)
 hy = hy[0]
 NSTEPS=1
 cell=range(cell_num)
 line,=ax.plot(cell, hy)
 while NSTEPS<=steps_num:
 for k in cell[:cell_num-1]:
 hy[k]=hy[k]+5
 line.set_ydata(hy)
 fig.canvas.draw()
 NSTEPS+=1
win = fig.canvas.manager.window
fig.canvas.manager.window.after(200, calulate1(20))
plt.show()
-- 
View this message in context: http://www.nabble.com/Got-problem-in-rendering-animation%28TkAgg%29-tp25710223p25710223.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Leo T. <tro...@gm...> - 2009年10月02日 02:25:55
I have a friend who's having strange memory issues when opening and
displaying images (using Matplotlib).
Here's what he says:
#######################################
pylab seems really inefficient: Opening a few images and displaying them
eats up tons of memory, and the memory doesn't get freed.
Starting python, and run
In [5]: from glob import *;
In [6]: from pylab import *
python has 33MB of memory.
Run
In [7]: i = 1
In [8]: for imname in glob("*.JPG"):
 ...: im = imread(imname)
 ...: figure(i); i = i+1
 ...: imshow(im)
 ...:
This opens 10 figures and displays them. Python takes 480MB of memory. This
is crazy, for 10 images -- 40+MB of memory for each!
In [14]: close("all")
In [15]: i = 1
In [16]: for imname in glob("*.JPG"):
 im = imread(imname)
 figure(i); i = i+1
 imshow(im)
 ....:
 ....:
This closes all figures and opens them again. Python takes up 837MB of
memory.
and so on... Something is really wrong with memory management.
##### System info: ##############
(using macosx backend)
2.4GHz MacBook Pro Intel Core 2 Duo
4GB 667MHz DDR2 SDRAM
In [5]: sys.version
Out[5]: '2.6.2 (r262:71600, Oct 1 2009, 16:44:23) \n[GCC 4.2.1 (Apple Inc.
build 5646)]'
In [6]: numpy.__version__
Out[6]: '1.3.0'
In [7]: matplotlib.__version__
Out[7]: '0.99.1.1'
In [8]: scipy.__version__
Out[8]: '0.7.1'
In [9]:
From: Eric F. <ef...@ha...> - 2009年10月02日 01:17:59
Christopher Barker wrote:
> Eric Firing wrote:
>> I have committed a change to svn trunk, so that if you change the
>> above to
>>
>> q = plt.quiver([0],[0], [1], [1], scale_units='xy', angles='xy', scale=1)
> 
> Eric,
> 
> You might recall that I spent a bit of time making a "stick plot" with 
> quiver. I go to work OK, but I couldn't do exactly what I wanted. I 
> think gets closer, but I"m not sure it quite gets there:
> 
> How exactly are the arrows scaled with scale_units='xy'? What I'd like 
> is for the length of the arrow to the the y scale only -- the x scale it 
> irrelevant (x is time, y is velocity). Can I do that with this?
Yes, use scale_units='y'. And I think you will want angles='uv' for 
this. This result was already available via units='y', but it was 
awkward to figure out the scale kwarg itself. The advantage now is that 
with scale_units='y', and scale=1, an arrow with sqrt(u^2+v^2)==1 will 
be 1 y-unit long.
Eric
> 
>> (Maybe I should add "width_units", identical to "units", and deprecate 
>> the latter; this might make the meanings of the kwargs clearer.)
> 
> +1
> 
> But if you're doing that, you may want to make more changes, also -- you 
> might as well do them all at once.
> 
> -Chris
> 
From: Matthew N. <mn...@gm...> - 2009年10月02日 01:17:30
Here is a snippet that might get you started:
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import cm
import mpl_toolkits.mplot3d as plt3
data = np.random.random((8,8))**4
cmap = cm.RdBu
fig = plt.figure()
ax = plt3.Axes3D(fig)
d = 0.1
w, h = data.shape
for x in range(w):
 for y in range(h):
 ax.bar3d([x+d], [y+d], [0], 1-d, 1-d, data[x,y], cmap(data[x,y]))
ax.set_zlim3d((0, 1))
plt.show()
Obviously, you should replace data with the actual data you want to
plot (maybe numpy can help with the histogramming), and use an
appropriate cmap for your data. Note that in this case the entire box
is a single color, not shaded up the side as in the example you
referenced; I actually like it this way but I also don't know how one
would do the shading in matplotlib. I'll admit it's rather silly to
have to create all these boxes individually, but that's the only way I
could see to color each box according to its height. The variable d
just puts gaps between boxes; you could set this to zero to make the
boxes adjacent.
I haven't figured out how to properly set the tick labels on the x and
y axis in a 3d plot like this. Also, there are often some z-order
errors with boxes occluding each other when they shouldn't. I don't
know the details of how these things work internally; maybe some
experts could weigh in here.
Cheers,
Matthew
On Thu, Oct 1, 2009 at 3:29 PM, Ernest Adrogué <ead...@gm...> wrote:
> Hello all,
>
> What is the best way to plot a 2d histogram?
> (Note that a 2d histogram is a histogram of a bivariate variable,
> so it's got to be a 3d plot.)
>
> Ideally, it should look somewhat like this:
> http://www.desy.de/~mraue/public/rootTutorial/v0.2/histogram02.gif
>
> For now, I have tried to do surface plots, one for each "bin",
> but this way you only get the tops of a series of imaginary columns
> and it looks a bit namby-pamby if you know what I mean.
>
> Any idea will be appreciated.
>
> --
> Ernest
>
>
> ------------------------------------------------------------------------------
> 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
>
10 messages has been excluded from this view by a project administrator.

Showing results of 419

<< < 1 .. 14 15 16 17 > >> (Page 16 of 17)
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 によって変換されたページ (->オリジナル) /