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

Showing 14 results of 14

From: Andreas M. <and...@gm...> - 2011年09月23日 21:10:33
In the following example the coordinates of the mouse
cursor displayed in the pylab window belong to the
second y-axis. But I would prefer to have the coordinates
of the first y-axis to be displayed. Is this possible?
import pylab as mpl
mpl.plot([1,3,2])
mpl.twinx()
mpl.plot([400,50,100])
mpl.show()
Ciao
Andreas
From: Benjamin R. <ben...@ou...> - 2011年09月23日 19:34:26
On Fri, Sep 23, 2011 at 2:28 PM, Gökhan Sever <gok...@gm...> wrote:
> On Fri, Sep 23, 2011 at 1:22 PM, Benjamin Root <ben...@ou...> wrote:
>
>> On Fri, Sep 23, 2011 at 2:07 PM, Gökhan Sever <gok...@gm...>wrote:
>>
>>> Hello,
>>>
>>> Considering this example plot:
>>> http://imageshack.us/photo/my-images/27/imagefki.png/
>>>
>>> How can I get the minor ticks showing correctly? (ie., 9 minor ticks per
>>> decade likewise for the x-axis)
>>>
>>> For some reason
>>>
>>> axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired
>>> output.
>>>
>>> Any hints?
>>>
>>> Thanks.
>>>
>>> --
>>> Gökhan
>>>
>>>
>> By default, setting the scale to log (e.g., ax.set_yscale('log')) should
>> automatically turn the minor ticks on for you. Note that depending on your
>> version of mpl, there may be a slight error in the documentation for
>> LogLocator.
>>
>> Ben Root
>>
>>
> Hi,
>
> I set the log scales for both axes. However, as you see in the image y-axis
> has only 4 minor ticks (8 expected) where as x-axis has none. I am using a
> couple days old mpl build.
>
>
I guess I would have to see your code. The y-axis ticks works fine in the
examples:
http://matplotlib.sourceforge.net/examples/pylab_examples/log_demo.html
Viewing the pdf or hires png shows 8 minor ticks.
Now, as for the x-axis, there are no minor ticks. That might be an issue...
Ben Root
From: Gökhan S. <gok...@gm...> - 2011年09月23日 19:28:12
On Fri, Sep 23, 2011 at 1:22 PM, Benjamin Root <ben...@ou...> wrote:
> On Fri, Sep 23, 2011 at 2:07 PM, Gökhan Sever <gok...@gm...>wrote:
>
>> Hello,
>>
>> Considering this example plot:
>> http://imageshack.us/photo/my-images/27/imagefki.png/
>>
>> How can I get the minor ticks showing correctly? (ie., 9 minor ticks per
>> decade likewise for the x-axis)
>>
>> For some reason
>>
>> axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired
>> output.
>>
>> Any hints?
>>
>> Thanks.
>>
>> --
>> Gökhan
>>
>>
> By default, setting the scale to log (e.g., ax.set_yscale('log')) should
> automatically turn the minor ticks on for you. Note that depending on your
> version of mpl, there may be a slight error in the documentation for
> LogLocator.
>
> Ben Root
>
>
Hi,
I set the log scales for both axes. However, as you see in the image y-axis
has only 4 minor ticks (8 expected) where as x-axis has none. I am using a
couple days old mpl build.
-- 
Gökhan
From: Benjamin R. <ben...@ou...> - 2011年09月23日 19:22:35
On Fri, Sep 23, 2011 at 2:07 PM, Gökhan Sever <gok...@gm...> wrote:
> Hello,
>
> Considering this example plot:
> http://imageshack.us/photo/my-images/27/imagefki.png/
>
> How can I get the minor ticks showing correctly? (ie., 9 minor ticks per
> decade likewise for the x-axis)
>
> For some reason
>
> axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired
> output.
>
> Any hints?
>
> Thanks.
>
> --
> Gökhan
>
>
By default, setting the scale to log (e.g., ax.set_yscale('log')) should
automatically turn the minor ticks on for you. Note that depending on your
version of mpl, there may be a slight error in the documentation for
LogLocator.
Ben Root
From: Gökhan S. <gok...@gm...> - 2011年09月23日 19:08:03
Hello,
Considering this example plot:
http://imageshack.us/photo/my-images/27/imagefki.png/
How can I get the minor ticks showing correctly? (ie., 9 minor ticks per
decade likewise for the x-axis)
For some reason
axis.set_minor_locator(LogLocator(numdecs=9) is not producing the desired
output.
Any hints?
Thanks.
-- 
Gökhan
From: Benjamin R. <ben...@ou...> - 2011年09月23日 14:59:11
On Wednesday, September 21, 2011, Benjamin Root <ben...@ou...> wrote:
>
>
> On Wednesday, September 21, 2011, Keith Jones <K....@ir...> wrote:
>> Hi,
>>
>> I have two questions about using NavigationToolbar2Wx with mplot3d.
>>
>>
>>
>> 1/ Initially the 3D scatter plot will rotate as usual with a mouse, but
after selecting the ‘pan’ or ‘zoom’ buttons the plot responds with some
confusion. How can I restore it to rotation only, i.e. disconnect the zoom
or pan behaviour?
>>
>
> That is a bug that should be resolved in the upcoming release. Use the
right mouse button for zooming instead. In the upcoming release, the zoom
and pan button should have no effect on axes3d objects, if I remember
correctly.
>
>
>>
>>
>> 2/ When using the ‘save’ button I get different behaviours depending on
the backend. With ‘WXAgg’ the saved png image shows only the axes, not the
scatter points. The scatter points and axes do appear correctly in a pdf
file. Using the ‘WX’ backend gives both scatter points and axes for the png
file.
>>
>
> I dont use WxAgg regularly. I will use your code to test this.
>
> Ben Root
I could not reproduce your problem with WxAgg backend on the development
branch. I could only test on Linux, though. However, if there is a
difference between platforms with WxAgg backend, then it is likely a Wx bug
and not a mpl bug (although the fact that the Wx backend worked is odd).
We are putting out an RC of v1.1.0 later today. Could you try out that
version within the next few days and let me know if it still happens for
you?
Ben Root
From: Søren N. <sor...@gm...> - 2011年09月23日 14:58:36
Hi,
I have a canvas with two subplots on it and the user can pick curves on each
subplot (all lines are pickable). I have created the ability to hide one
subplot and only show one of the two. The remaining subplot is also enlarged
to fit the canvas. This is done using:
self.subplot1.set_visible(True)
self.subplot2.set_visible(False)
self.subplot1.change_geometry(1,1,1)
self.canvas.draw()
However, when I do that, its only possible to pick curves in the area where
the original subplot was located.. like it hasn't updated the geometry for
picking feature.
Is there a way for me to do this?
Thanks,
Soren
From: Tony Yu <ts...@gm...> - 2011年09月23日 14:09:15
On Fri, Sep 23, 2011 at 9:01 AM, Kurt Mueller <kur...@gm...
> wrote:
>
> Without the resize event it works as expected.
> With the resize event (as you suggested),
> it only adjusts the borders of the four axes to the outside of the figure.
> But between the axes there is no space at all.
>
> Do I miss something?
>
I think I was saying (I'm not certain, since it's been a while since the
original email) that the function (layout.tight) had to be called again
*after* resizing.
BTW, one of the matplotlib devs (Jae Joon Lee, I believe) completely
rewrote/improved this function and added it to matplotlib as
tight_layout<https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/figure.py#L1312>(both
as a pyplot function and a figure method). I'm not sure if the
function is in the current mpl release, but there's a pending release in the
works.
Best,
-Tony
From: Kurt M. <kur...@gm...> - 2011年09月23日 13:02:15
<quote author="Tony Yu-3">
A while back, I wrote some functions to calculate a good set of parameters for subplots_adjust (see attached; examples in if-main block at bottom). I've been using these functions pretty regularly, and it works pretty well for my purposes.
The function has to draw the figure a couple of times to calculate correct spacing. When redrawing the figure (e.g. when you resize the window), you'd have to re-call the function, which would redraw the figure a couple of times before drawing the final figure. That's all to say: this is a fairly slow function. If you don't have subplots (like in your example), you can call "layout.tight_borders()" (instead of "layout.tight()"), which only requires a single redraw.
When I originally posted this to the developers list, the functions didn't work with the GtkAgg backend. As far as I know, this hasn't changed. It should work fine for Qt4Agg, macosx, and TkAgg backends.
</quote>
Hi Tony,
I copied your layout.py.
Then run the following python script:
------------------------------------------------------
import matplotlib.pyplot as plt
import layout
import random
fontsizes = [8, 16, 24, 32]
def example_plot(ax):
 ax.plot([1, 2])
 ax.set_xlabel('x-label', fontsize=random.choice(fontsizes))
 ax.set_ylabel('y-label', fontsize=random.choice(fontsizes))
 ax.set_title('Title', fontsize=random.choice(fontsizes))
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2)
example_plot(ax1)
example_plot(ax2)
example_plot(ax3)
example_plot(ax4)
def on_resize(event):
 print( 'on_resize()' )
 layout.tight()
def on_close(event):
 print( 'on_close()' )
 fig.canvas.mpl_disconnect( rsiz_id )
 print rsiz_id
layout.tight()
if False:
#if True:
 rsiz_id = fig.canvas.mpl_connect('resize_event', on_resize)
 print rsiz_id
 fig.canvas.mpl_connect('close_event', on_close)
plt.show()
------------------------------------------------------
Without the resize event it works as expected.
With the resize event (as you suggested),
it only adjusts the borders of the four axes to the outside of the figure.
But between the axes there is no space at all.
Do I miss something?
Thanks a lot
Kurt
-- 
Kurt Mueller
From: yam850 <mu...@pr...> - 2011年09月23日 12:20:53
Tony Yu-3 wrote:
> 
> A while back, I wrote some functions to calculate a good set of parameters
> for subplots_adjust (see attached; examples in if-main block at bottom).
> I've been using these functions pretty regularly, and it works pretty well
> for my purposes. 
> 
> The function has to draw the figure a couple of times to calculate correct
> spacing. When redrawing the figure (e.g. when you resize the window),
> you'd have to re-call the function, which would redraw the figure a couple
> of times before drawing the final figure. That's all to say: this is a
> fairly slow function. If you don't have subplots (like in your example),
> you can call "layout.tight_borders()" (instead of "layout.tight()"), which
> only requires a single redraw.
> 
> When I originally posted this to the developers list, the functions didn't
> work with the GtkAgg backend. As far as I know, this hasn't changed. It
> should work fine for Qt4Agg, macosx, and TkAgg backends.
> 
Hi Tony,
I copied your layout.py.
Then run the following python script:
------------------------------------------------------
import matplotlib.pyplot as plt
import layout
import random
fontsizes = [8, 16, 24, 32]
def example_plot(ax):
 ax.plot([1, 2])
 ax.set_xlabel('x-label', fontsize=random.choice(fontsizes))
 ax.set_ylabel('y-label', fontsize=random.choice(fontsizes))
 ax.set_title('Title', fontsize=random.choice(fontsizes))
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2)
example_plot(ax1)
example_plot(ax2)
example_plot(ax3)
example_plot(ax4)
def on_resize(event):
 print( 'on_resize()' )
 layout.tight()
def on_close(event):
 print( 'on_close()' )
 fig.canvas.mpl_disconnect( rsiz_id )
 print rsiz_id
layout.tight()
if False:
#if True:
 rsiz_id = fig.canvas.mpl_connect('resize_event', on_resize)
 print rsiz_id
 fig.canvas.mpl_connect('close_event', on_close)
plt.show()
------------------------------------------------------
Without the resize event it works as expected.
With the resize event (as you suggested),
it only adjusts the borders of the four axes to the outside of the figure.
But between the axes there is no space at all.
Do I miss something?
Thanks a lot
Kurt
-- 
View this message in context: http://old.nabble.com/axis-labels-clipped-tp29738218p32503869.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Martijn <mar...@gm...> - 2011年09月23日 11:04:25
Hi,
I found that ndarray is the wrong class to use for this purpose. The
vector I created in the example below was just en uninitialised 3D
vector. Arrays cannot be subclassed:
class Vector(np.array):
	pass
returns an error. But using a matrix as base class works:
class Vector(np.matrix):
	def __abs__(self):
		l = np.sqrt(self*self.transpose())
		return(l[0,0])
V1 = Vector([1,2,2])
V2 = Vector([5,0,4])
print abs(V2-2*V1)
prints 5.0, as it should.
It is very crude (no check on dimensions!), but works.
Martijn
On Thu, 2011年09月22日 at 23:54 +0200, Martijn wrote:
> Hi,
> I am trying to create an ndarry subclass for vector calculations. The
> result is not what I intent:
> 
> import numpy as np
> 
> class Vector(np.ndarray):
> 	def __abs__(self):
> 		return(np.sqrt(sum(self**2)))
> 
> V = Vector([1,2,3])
> 
> print np.sqrt(sum(self**2))
> print abs(V)
> 
> I do not understand the docs at http://www.scipy.org/Subclasses but it
> is late now.
> 
> 
> Martijn
> 
> 
> P.S. I know this is not strictly matplotlib related, but since MP uses
> numpy so heavily, I felt free to ask.
> 
> 
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Kurt M. <kur...@gm...> - 2011年09月23日 06:58:17
Am 17.09.2011 18:49, schrieb Kurt Mueller:
> Am 17.09.2011 um 15:38 schrieb Jae-Joon Lee:
>> Thanks for reporting this.
>> I opened a pull request that I believe fixes this problem.
>> https://github.com/matplotlib/matplotlib/pull/472
> Thank you very much!
>> Please test this if you can.
> I hope next week.
I did a brief test.
(I added the three "if ax. ..." to the file gridspec.py in the matplotlib library.)
(matplotlib 1.0.1)
As far as I can tell is, that the unexpected effect did not occur any more.
I did not test it with shared axis.
>> Depending on your need, you may work around this by calling all the
>> set_position method always after all the GridSpec.update call.
In my programs I will use this approach until we move to a more recent matplotlib version.
Thanks
-- 
Kurt Mueller
From: gary r. <gr...@bi...> - 2011年09月23日 06:28:37
The dpi value, which can be overridden, will determine the size of the
output image. It looks to me like you just want the output to always
be the same size as your input image, so use imsave() instead of
imshow() followed by savefig() for this:
i.e. just do
map = Basemap(......)
pilImg = Image.open('bkgmap.gif')
rgba = pil_to_array(pilImg)
pyplot.imsave('outimg.png', rgba)
On Fri, Sep 23, 2011 at 9:10 AM, Isidora <is...@ju...> wrote:
> Hi,
>
> I am new to matplotlib so I may not have found the right answer because I am looking in the wrong places.
>
> I wrote a script to draw lines on a 800x600 pixels GIF background map. The output image I get is 620x450. Could someone let me know what I am doing wrong?
>
> Code Snippet:
>
> map = Basemap(......)
> pilImg = Image.open('bkgmap.gif')
> rgba = pil_to_array(pilImg)
> map.imshow(rgba)
> # Plot some lines and labels here
> ....
> pyplot.savefig('outimg.png',format='PNG',bbox_inches='tight',pad_inches=0)
>
>
> Thank you
>
>
>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure contains a
> definitive record of customers, application performance, security
> threats, fraudulent activity and more. Splunk takes this data and makes
> sense of it. Business sense. IT sense. Common sense.
> http://p.sf.net/sfu/splunk-d2dcopy1
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: William R. t. L. <me...@li...> - 2011年09月23日 02:36:45
LinkedIn
------------
 William Ratcliff ha chiesto di aggiungerti ai suoi collegamenti su LinkedIn:
 
------------------------------------------
Vorrei aggiungerti alla mia rete professionale su LinkedIn.
Accetta l'invito di William Ratcliff
http://www.linkedin.com/e/-b7qixr-gswk7oea-2f/_dML4GcZf3-2F5VO_wzm4ASVf0JrnPVO-ObO4eeHsZV8OPkmQwLeZN8i/blk/I3137892780_2/1BpC5vrmRLoRZcjkkZt5YCpnlOt3RApnhMpmdzgmhxrSNBszYOnP0UdP8Ve3sPcjd9bSF4qlhiemtBbPsQejAQcz4OcPgLrCBxbOYWrSlI/EML_comm_afe/?hs=false&tok=0Wg_wQR1SsTkU1
Visualizza l'invito di William Ratcliff
http://www.linkedin.com/e/-b7qixr-gswk7oea-2f/_dML4GcZf3-2F5VO_wzm4ASVf0JrnPVO-ObO4eeHsZV8OPkmQwLeZN8i/blk/I3137892780_2/39vc3wTczAUdPcNcQALqnpPbOYWrSlI/svi/?hs=false&tok=04ZxCHkESsTkU1 
------------------------------------------
SAPEVI CHE puoi usare il profilo di LinkedIn come se fosse il tuo sito Web? Seleziona un URL di reindirizzamento a un microsito e promuovi questo indirizzo sui tuoi biglietti da visita, nella firma di posta elettronica, sul tuo sito Web, ecc.
http://www.linkedin.com/e/-b7qixr-gswk7oea-2f/ewp/inv-21/?hs=false&tok=2AAzpjUy6sTkU1
 
-- 
(c) 2011, LinkedIn Corporation

Showing 14 results of 14

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