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

Showing results of 335

<< < 1 .. 3 4 5 6 7 .. 14 > >> (Page 5 of 14)
From: Jesper L. <jl...@dm...> - 2007年03月26日 07:34:22
Hi matplotlib users,
I'm using matplotlib for a long running process. Unfortunately the memory 
usage continue to grow as the process runs. I have appended a simple example 
which illustrates this at the end of this mail. Unfortunately I haven't 
figured out how to use the information obtainable from gc for anything useful 
in this regards.
Kind regards,
Jesper
My system is:
> uname -a
Linux sea 2.6.15-28-686 #1 SMP PREEMPT Thu Feb 1 16:14:07 UTC 2007 i686 
GNU/Linux
> python
Python 2.4.4 (#1, Nov 16 2006, 13:39:46)
[GCC 3.3.3 (Debian)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> print matplotlib.__version__
0.87.6
>>> from matplotlib.toolkits import basemap
>>> print basemap.__version__
0.9.4
Test code:
import os, gc
import PyNGL.Nio as Nio
from matplotlib.toolkits import basemap
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
import pylab
def report_memory(i):
 pid = os.getpid()
 a2 = os.popen('ps -p %d -o rss,vsz,%%mem' % pid).readlines()
 print i, ' ', a2[1],
 return int(a2[1].split()[1])
def plot():
 #gc.set_debug(gc.DEBUG_LEAK)
 lon = pylab.linspace(-4.08300018311, 30.25, 207)
 lat = pylab.linspace(48.5499992371, 65.8499984741, 174)
 xo, yo = pylab.meshgrid(lon, lat)
 bmap = basemap.Basemap(-4, 48, 30, 66)
 xlon, ylat = bmap(xo,yo)
 fig = pylab.Figure()
 canvas = FigureCanvas(fig)
 i = 0
 while True:
 report_memory(i)
 fig.clear()
 cs = bmap.contourf(xlon, ylat, xo)
 del cs
 i += 1
if __name__ == '__main__': plot()
From: Richard B. <rg...@gm...> - 2007年03月26日 01:05:01
On 23/03/07, Eric Firing <ef...@ha...> wrote:
> Richard,
>
> I have made the requested change to imshow, so it is consistent with the
> new matshow, and I think it makes much more sense this way--but note
> that it depends on your rc value for image.origin. So, whenever you get
> mpl from svn, or the next release (whenever that occurs--not very soon,
> I suspect), I think you will find both matshow and imshow more to your
> liking.
>
Hi Eric
Thanks heaps - that was exactly what I was hoping for.
A small thing - I think the change might have induced a slight problem
in matshow - e.g. for a 3x3 image, the pixels are in the right place,
but the axis limits need to change from 0...3 to -0.5...2.5.
I'm impressed with the speed of the change - seems like a very helpful
community here.
cheers,
Richard
From: Andrew S. <str...@as...> - 2007年03月25日 19:18:10
Try installing the numpy-ext debian package.
ro...@yo... wrote:
> Hello:
>
> I am using kanotix which is a very stable debian sid system. I intalled the
> matplotlib package from the debian database successfully. It may have
> pulled in python 2.4 as well. Please see what happens when I use the
> command "from pylab import *" within python.
>
> Can someone please help me with this?
>
> Kind regards,
>
> Angelo
>
> rossi@KanotixBox:~$ python
> Python 2.4.4 (#2, Jan 13 2007, 17:50:26)
> [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> 
>>>> from pylab import *
>>>> 
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.4/site-packages/pylab.py", line 1, in ?
> from matplotlib.pylab import *
> File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 197, in
> ?
> import cm
> File "/usr/lib/python2.4/site-packages/matplotlib/cm.py", line 5, in ?
> import colors
> File "/usr/lib/python2.4/site-packages/matplotlib/colors.py", line 33, in
> ?
> from numerix import array, arange, take, put, Float, Int, where, \
> File "/usr/lib/python2.4/site-packages/matplotlib/numerix/__init__.py",
> line 73, in ?
> import numpy
> File "/usr/lib/python2.4/site-packages/numpy/__init__.py", line 40, in ?
> import linalg
> File "/usr/lib/python2.4/site-packages/numpy/linalg/__init__.py", line 4,
> in ?
> from linalg import *
> File "/usr/lib/python2.4/site-packages/numpy/linalg/linalg.py", line 25,
> in ?
> from numpy.linalg import lapack_lite
> ImportError: /usr/lib/atlas/liblapack.so.3: undefined symbol: ATL_ctbmv
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: Darren D. <dd...@co...> - 2007年03月25日 17:14:38
On Sunday 25 March 2007 12:25:50 pm ro...@yo... wrote:
> Hello:
>
> I am using kanotix which is a very stable debian sid system. I intalled
> the matplotlib package from the debian database successfully. It may have
> pulled in python 2.4 as well. Please see what happens when I use the
> command "from pylab import *" within python.
>
> Can someone please help me with this?
Looks like a problem with your numpy installation, not matplotlib.
Darren
> >>> from pylab import *
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> File "/usr/lib/python2.4/site-packages/pylab.py", line 1, in ?
> from matplotlib.pylab import *
> File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 197, in
> ?
> import cm
> File "/usr/lib/python2.4/site-packages/matplotlib/cm.py", line 5, in ?
> import colors
> File "/usr/lib/python2.4/site-packages/matplotlib/colors.py", line 33, in
> ?
> from numerix import array, arange, take, put, Float, Int, where, \
> File "/usr/lib/python2.4/site-packages/matplotlib/numerix/__init__.py",
> line 73, in ?
> import numpy
> File "/usr/lib/python2.4/site-packages/numpy/__init__.py", line 40, in ?
> import linalg
> File "/usr/lib/python2.4/site-packages/numpy/linalg/__init__.py", line 4,
> in ?
> from linalg import *
> File "/usr/lib/python2.4/site-packages/numpy/linalg/linalg.py", line 25,
> in ?
> from numpy.linalg import lapack_lite
> ImportError: /usr/lib/atlas/liblapack.so.3: undefined symbol: ATL_ctbmv
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share
> your opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
Darren S. Dale, Ph.D.
dd...@co...
Hello:
I am using kanotix which is a very stable debian sid system. I intalled the
 matplotlib package from the debian database successfully. It may have
pulled in python 2.4 as well. Please see what happens when I use the
command "from pylab import *" within python.
Can someone please help me with this?
Kind regards,
Angelo
rossi@KanotixBox:~$ python
Python 2.4.4 (#2, Jan 13 2007, 17:50:26)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pylab import *
Traceback (most recent call last):
 File "<stdin>", line 1, in ?
 File "/usr/lib/python2.4/site-packages/pylab.py", line 1, in ?
 from matplotlib.pylab import *
 File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 197, in
?
 import cm
 File "/usr/lib/python2.4/site-packages/matplotlib/cm.py", line 5, in ?
 import colors
 File "/usr/lib/python2.4/site-packages/matplotlib/colors.py", line 33, in
?
 from numerix import array, arange, take, put, Float, Int, where, \
 File "/usr/lib/python2.4/site-packages/matplotlib/numerix/__init__.py",
line 73, in ?
 import numpy
 File "/usr/lib/python2.4/site-packages/numpy/__init__.py", line 40, in ?
 import linalg
 File "/usr/lib/python2.4/site-packages/numpy/linalg/__init__.py", line 4,
in ?
 from linalg import *
 File "/usr/lib/python2.4/site-packages/numpy/linalg/linalg.py", line 25,
in ?
 from numpy.linalg import lapack_lite
ImportError: /usr/lib/atlas/liblapack.so.3: undefined symbol: ATL_ctbmv
From: Matthew C. <mat...@gm...> - 2007年03月24日 13:45:19
Hi David,
How about:
import pylab as P
dist = P.rand(100)
x=P.arange(0.,1.,0.01)
fx=10.*x**4
P.hist(dist)
P.plot(x,fx,'r-')
P.axis([0.,1.,0.,20.])
P.show()
From: David <da...@gm...> - 2007年03月24日 13:21:55
I would like to plot a function on top of a histogram, using the same 
coordinate axes. Is this possible? Or alternatively, is it possible 
to plot a function with an image as the background (so that I can 
save the histogram as an image and then use it as a background).
Thank you in advance,
/David
From: Bill B. <wb...@gm...> - 2007年03月24日 03:16:58
Did you guys make a conscious decision to have the matplotlib list
send replies only to the sender of the message rather than the list?
This seems to be the default at SourceForge, so it's conceivable you
just haven't bothered to change it. I've been on at least 10
different mailing lists in the past 2 years or so, and of those
matplotlib's is the only one I can recall being set up with default
reply-to-sender rather than reply-to-list.
I keep accidentally replying to senders only, so I thought I'd mention
it. In the admin section on sourceforge there's a checkbox you can
set to change the list from reply-to-sender to reply-to-list as the
default.
--bb
From: Bill B. <wb...@gm...> - 2007年03月24日 03:10:24
gah! bitten by reply to sender once again.
--bb
---------- Forwarded message ----------
From: Bill Baxter <wb...@gm...>
Date: Mar 24, 2007 12:09 PM
Subject: Re: [Matplotlib-users] interactive plots again
To: Robert Cimrman <cim...@nt...>
Are you sure that's threadsafe?
With most windowing toolkits it's not safe to do GUI things from
threads other than the main one. Other threads can only post a
message to the main GUI thread. Depending on how fig.canvas.draw is
implemented, calling it from another thread might not be kosher. But
I take it you haven't seen any meltdowns so far, so maybe its
implementation does the threadsafe message posting thing.
--bb
On 3/22/07, Robert Cimrman <cim...@nt...> wrote:
> Maybe I have reinvented the wheel, but I find the attached code snippet
> very useful.
> I have modified a bit the recipe at
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65222
> to be used in the following situation:
>
> You plot (interactively) something in a main program, which than works
> heavily. Normally, when the figure window gets obscured, it will not
> redraw. The attached code shows how to make a thread that periodically
> redraws the figure.
>
> r.
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
From: Angus M. <am...@gm...> - 2007年03月24日 01:12:02
On 24/03/07, belinda thom <bt...@cs...> wrote:
> Hi,
>
> I'm trying to write a very simple GUI using matplotlib and have
> gotten stuck. Hopefully someone out there has done something similar
> and can point me on my way.
>
> First, I should mention that the examples provided with matplotlib
> weren't immediately helpful to me, because when I try to run various
> demos (like pick_event_demo or object_picker) it fails b/c I'm
> relying on (and have to rely on) TkAgg. Sadly, I'm too new to
> understand what I would need to do to get those demos working. So I
> found someone processing mouseclicks using a Mac online and started
> there.
>
> I ended up with something like this:
>
> from pylab import *
> class gui :
> def __init__(self) :
> self.f = figure()
> self.data = None # valid mouse click hasn't yet happened
> def clicker(event):
> self.data = event.xdata
> self.f.canvas.mpl_connect("button_press_event",clicker)
>
> def getNextValidClick(self) :
> (data, self.data) = (None, None)
> while True :
> print "Waiting for valid mouse click..."
> while self.data == None :
> pass # keep polling
> if 1 <= self.data <= 3 :
> # consider this a valid next mouse click
> (data, self.data) = (self.data, None)
> break
> return data
>
> With which I tried:
>
> g = gui()
> x = g.getNextValidClick()
>
> but the latter line caused me to experience the spinning wheel of
> dead that we mac users so enjoy.
>
> I have the feeling I need to explicitly yield or some such in the
> poll loop, but I don't know how to do that.
>
> Advice greatly appreciated, both on the code I've provided, and on if
> there is a better way altogether to provide an app with data obtained
> via a matplotlib mouse click callback.
>
> Thanks,
>
> --b
It's the polling that's the problem. Why not use a slightly different
approach, like this:
---------------------------
from pylab import figure
class gui :
 def __init__(self, callback) :
 self.f = figure()
 self.ax = self.f.add_subplot(111)
 self.ax.plot([1,2,3])
 self.data = None # valid mouse click hasn't yet happened
 def clicker(event):
 self.data = event.xdata
 if 1 <= self.data <= 3:
 callback(self.data)
 self.f.canvas.mpl_connect("button_press_event",clicker)
 print "Waiting for valid mouse click..."
----------------------------
then in your application (or shell):
def my_cb(inp):
 # processing here
 print inp
g = gui(my_cb)
No polling required, and you only get the valid clicks calling your
routine. I hope that helps,
A.
-- 
AJC McMorland, PhD Student
Physiology, University of Auckland
From: belinda t. <bt...@cs...> - 2007年03月23日 22:44:40
Hi,
I'm trying to write a very simple GUI using matplotlib and have 
gotten stuck. Hopefully someone out there has done something similar 
and can point me on my way.
First, I should mention that the examples provided with matplotlib 
weren't immediately helpful to me, because when I try to run various 
demos (like pick_event_demo or object_picker) it fails b/c I'm 
relying on (and have to rely on) TkAgg. Sadly, I'm too new to 
understand what I would need to do to get those demos working. So I 
found someone processing mouseclicks using a Mac online and started 
there.
I ended up with something like this:
 from pylab import *
 class gui :
 	def __init__(self) :
	 	self.f = figure()
		self.data = None # valid mouse click hasn't yet happened
	 def clicker(event):
			self.data = event.xdata
 	self.f.canvas.mpl_connect("button_press_event",clicker)
	def getNextValidClick(self) :
	 (data, self.data) = (None, None)
	 while True :
 		print "Waiting for valid mouse click..."
	 	while self.data == None :
 		pass # keep polling
			if 1 <= self.data <= 3 :
				# consider this a valid next mouse click
				(data, self.data) = (self.data, None)
 				break
		return data
With which I tried:
g = gui()
x = g.getNextValidClick()
but the latter line caused me to experience the spinning wheel of 
dead that we mac users so enjoy.
I have the feeling I need to explicitly yield or some such in the 
poll loop, but I don't know how to do that.
Advice greatly appreciated, both on the code I've provided, and on if 
there is a better way altogether to provide an app with data obtained 
via a matplotlib mouse click callback.
Thanks,
--b
From: belinda t. <bt...@cs...> - 2007年03月23日 22:30:27
Eric,
This is great; much thanks!
--b
On Mar 23, 2007, at 3:16 PM, Eric Firing wrote:
> belinda thom wrote:
>> Hi,
>> I'm wondering if there's an easy way to reverse an axis in a plot.
>
> Using methods:
>
> bottom, top = ax.get_ylim()
> ax.set_ylim(top, bottom)
>
> Or using pylab functions:
>
> bottom, top = ylim()
> ylim(top, bottom)
>
> Eric
>
>> For instance, suppose I wanted to create a plot that had its 
>> "origin" in the upper left hand corner, so that x would range 
>> from, say 0 to 1 moving right, and y would range from, say 0 to 
>> 1, moving down.
>> Thanks!
>> --b
>> --------------------------------------------------------------------- 
>> ----
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to 
>> share your
>> opinions on IT & business topics through brief surveys-and earn cash
>> http://www.techsay.com/default.php? 
>> page=join.php&p=sourceforge&CID=DEVDEV
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Eric F. <ef...@ha...> - 2007年03月23日 22:17:15
belinda thom wrote:
> Hi,
> 
> I'm wondering if there's an easy way to reverse an axis in a plot.
Using methods:
bottom, top = ax.get_ylim()
ax.set_ylim(top, bottom)
Or using pylab functions:
bottom, top = ylim()
ylim(top, bottom)
Eric
> 
> For instance, suppose I wanted to create a plot that had its "origin" 
> in the upper left hand corner, so that x would range from, say 0 to 1 
> moving right, and y would range from, say 0 to 1, moving down.
> 
> Thanks!
> 
> --b
> 
> 
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: belinda t. <bt...@cs...> - 2007年03月23日 21:48:38
Hi,
I'm wondering if there's an easy way to reverse an axis in a plot.
For instance, suppose I wanted to create a plot that had its "origin" 
in the upper left hand corner, so that x would range from, say 0 to 1 
moving right, and y would range from, say 0 to 1, moving down.
Thanks!
--b
From: Eric F. <ef...@ha...> - 2007年03月23日 08:23:48
Richard,
I have made the requested change to imshow, so it is consistent with the 
new matshow, and I think it makes much more sense this way--but note 
that it depends on your rc value for image.origin. So, whenever you get 
mpl from svn, or the next release (whenever that occurs--not very soon, 
I suspect), I think you will find both matshow and imshow more to your 
liking.
I also changed the docstring explanation for the extent kwarg, noting 
that it gives (left, right, bottom, top) data limits of the axes.
More doc changes and other tweaks for this class of functions will be in 
order, when I get back to it.
Eric
Richard Brown wrote:
> On 22/03/07, Eric Firing <ef...@ha...> wrote:
>> Richard Brown wrote:
>> > Hi there,
>> >
>> > I'm pretty new to python; I'm in the process of switching from Matlab.
>> > I do quite a bit of image processing in my research, and while
>> > pylab/matplotlib seems to be a great plotting library, some of the
>> > quirks seem just a little bit frustrating - I'm hoping for some
>> > enlightenment :)
>> >
>> > When I use imshow or matshow to display an array, the points with
>> > index (m, n) are displayed with the pixels centred at (0.5 + m, 0.5 +
>> > n). Is there a setting somewhere to make it so that the centres of the
>> > pixels are at the index values rather than their bottom left corners?
>> > Or must I be always adding 0.5 to things to make them appear in the
>> > right places?
>>
>> Coincidentally, a few days ago I made this change for matshow; I had
>> made it in spy some time ago. I have so far left imshow alone; isn't
>> its present behavior consistent with Matlab? That is not necessarily a
>> good reason for leaving it the way it is, but it is reason for some
>> caution. I suspect quite a few people may prefer it the way it is;
>> let's see who responds, and what opinions are voiced.
> 
> Thanks for your timely response. Let me give you a few examples to
> clarify the things which I think might be relevant issues to address.
> (numpy and pylab imported)
> 
> PRELIMINARIES
> # Create a 6x6 logical array with a 2x2 square near the to left
> xx = zeros((6, 6), dtype='Bool')
> xx[1:3, 1:3] = True
> 
> 
> EXAMPLE 1 - imshow
> Trying to plot a point which should appear on the square:
>>>> imshow(xx, interpolation='nearest')
>>>> plot([2],[2], 'y.', markersize=20)
> 
> The image looks correct, with the square in the top left, but the y
> axis is labelled backwards. Therefore when I try to plot a point in
> the middle of it, it misses altogether
> 
> EXAMPLE 2 - matshow (not your new version)
>>>> matshow(xx)
> So far so good - the y axis is the right way around
>>>> plot([2],[2], 'y.', markersize=20)
> Oops - the y axis flipped, there is a block of white at the top, and
> the image is now upside-down. The point has showed up in the right
> place w.r.t the image though.
> 
> EXAMPLE 3 - off by 0.5 problem - relevant to imshow too
>>>> matshow(xx)
> Let's say I want to compute the centroid of the square blob. IMO a
> natural way to do this is:
>>>> cen = mean(where(xx), 1)
>>>> plot([cen[0]], [cen[1]], 'y.')
> 
> This is off by 0.5 in both directions. This kind of thing is my
> argument for why the coordinate system should be aligned with the
> array indices.
> 
> Matlab behaviour:
> In Matlab, the pixels are centred on integer coordinates corresponding
> to their array index. Matlab indexing is ones based, so a 2x2 image
> will have axes limits of 0.5-2.5 in each direction, with the pixel
> centres at (1,1), (1,2) etc.
> imshow in Matlab plots the array with the (1,1) coordinate in the top
> left, and the y axis increasing from the top down (like what matshow
> does here)
> 
> cheers,
> 
> Richard
From: Stephen G. <ste...@op...> - 2007年03月23日 01:50:59
Creating a 'simplified' example (not really) to demonstrate the problem
Zoom in on one of the constant speed movements.(upper graph)
psd (lower graph) will still be showing spectrum of whole data file.
click 'n release any mouse button in the upper graph, and only then 
will the lower graph redraw with the new limits.
zoom out, try again on other constant speed movement.
how to get lower graph to redraw on new limits after the zoom, without 
having to click the upper graph again?
Steve
> I have two plots.
>
> first one is velocity data from servo controller (freq) - plant 
> reciprocates back and forth so we got turn data in there as well
> second one is psd (power spectral density) so we can see where we got 
> resonances etc.
>
> When we zoom in on on section of first plot (say the forward movement), 
> I'd like to recalc the psd with only the data that's been zoomed in on.
>
> Everything kind of works except for somewhere to trigger from.
>
> I had thought of trying resize_event - however I cannot get this 
> working- see other post.
>
> I played with button_release_event to get the code basically working, 
> however that event occurs before the first graph gets resized, so the 
> region I am calculating the psd on is wrong, maybe because I am using
> xlim = myAxis.get_xlim()
> to find the limits of the first graph (which hasn't been re-drawn yet)
>
> Is there some way I can hook the re-calc/draw of psd to the zooming of 
> first graph?
>
> Previously with 2 plot commands, I have used subplot(212, sharex=p1), to 
> hook the two graphs together on the xaxis
> however as the second graph is a psd I don't know how to hook the psd 
> input data to the xaxis of the first graph.
>
>
> Thanks
> Ste
> 
From: Richard B. <rg...@gm...> - 2007年03月23日 00:18:29
On 22/03/07, Eric Firing <ef...@ha...> wrote:
> Richard Brown wrote:
> > Hi there,
> >
> > I'm pretty new to python; I'm in the process of switching from Matlab.
> > I do quite a bit of image processing in my research, and while
> > pylab/matplotlib seems to be a great plotting library, some of the
> > quirks seem just a little bit frustrating - I'm hoping for some
> > enlightenment :)
> >
> > When I use imshow or matshow to display an array, the points with
> > index (m, n) are displayed with the pixels centred at (0.5 + m, 0.5 +
> > n). Is there a setting somewhere to make it so that the centres of the
> > pixels are at the index values rather than their bottom left corners?
> > Or must I be always adding 0.5 to things to make them appear in the
> > right places?
>
> Coincidentally, a few days ago I made this change for matshow; I had
> made it in spy some time ago. I have so far left imshow alone; isn't
> its present behavior consistent with Matlab? That is not necessarily a
> good reason for leaving it the way it is, but it is reason for some
> caution. I suspect quite a few people may prefer it the way it is;
> let's see who responds, and what opinions are voiced.
Thanks for your timely response. Let me give you a few examples to
clarify the things which I think might be relevant issues to address.
(numpy and pylab imported)
PRELIMINARIES
# Create a 6x6 logical array with a 2x2 square near the to left
xx = zeros((6, 6), dtype='Bool')
xx[1:3, 1:3] = True
EXAMPLE 1 - imshow
Trying to plot a point which should appear on the square:
>>> imshow(xx, interpolation='nearest')
>>> plot([2],[2], 'y.', markersize=20)
The image looks correct, with the square in the top left, but the y
axis is labelled backwards. Therefore when I try to plot a point in
the middle of it, it misses altogether
EXAMPLE 2 - matshow (not your new version)
>>> matshow(xx)
So far so good - the y axis is the right way around
>>> plot([2],[2], 'y.', markersize=20)
Oops - the y axis flipped, there is a block of white at the top, and
the image is now upside-down. The point has showed up in the right
place w.r.t the image though.
EXAMPLE 3 - off by 0.5 problem - relevant to imshow too
>>> matshow(xx)
Let's say I want to compute the centroid of the square blob. IMO a
natural way to do this is:
>>> cen = mean(where(xx), 1)
>>> plot([cen[0]], [cen[1]], 'y.')
This is off by 0.5 in both directions. This kind of thing is my
argument for why the coordinate system should be aligned with the
array indices.
Matlab behaviour:
In Matlab, the pixels are centred on integer coordinates corresponding
to their array index. Matlab indexing is ones based, so a 2x2 image
will have axes limits of 0.5-2.5 in each direction, with the pixel
centres at (1,1), (1,2) etc.
imshow in Matlab plots the array with the (1,1) coordinate in the top
left, and the y axis increasing from the top down (like what matshow
does here)
cheers,
Richard
From: Robert C. <cim...@nt...> - 2007年03月22日 14:03:10
Attachments: tasks.py
Maybe I have reinvented the wheel, but I find the attached code snippet
very useful.
I have modified a bit the recipe at
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65222
to be used in the following situation:
You plot (interactively) something in a main program, which than works
heavily. Normally, when the figure window gets obscured, it will not
redraw. The attached code shows how to make a thread that periodically
redraws the figure.
r.
From: Robert C. <cim...@nt...> - 2007年03月22日 09:49:59
Attachments: image.png
Hello,
I am using the OO interface to plot some data in logarithmic y-scale.
The data displayed are almost constant but not entirely, see the
attached image. In order to see the details, I would like to do
something like 'axis( 'image' )' for the yaxis. I have tried to play
with axes.set_ylim(), axes.yaxis.set_ticks() but failed utterly.
Can anyone help me?
For linear scaling, there is no problem - the axes limits are well
adjusted without any intervention.
thanks,
r.
From: Mark B. <ma...@gm...> - 2007年03月22日 09:05:48
This will give you a smooth line for your cumulative distribution function:
x = randn(10000)
y = sort(x)
plot(y,linspace(0,1,10000))
Mark
From: Stephen G. <ste...@op...> - 2007年03月22日 06:56:29
I have two plots.
first one is velocity data from servo controller (freq) - plant 
reciprocates back and forth so we got turn data in there as well
second one is psd (power spectral density) so we can see where we got 
resonances etc.
When we zoom in on on section of first plot (say the forward movement), 
I'd like to recalc the psd with only the data that's been zoomed in on.
Everything kind of works except for somewhere to trigger from.
I had thought of trying resize_event - however I cannot get this 
working- see other post.
I played with button_release_event to get the code basically working, 
however that event occurs before the first graph gets resized, so the 
region I am calculating the psd on is wrong, maybe because I am using
xlim = myAxis.get_xlim()
to find the limits of the first graph (which hasn't been re-drawn yet)
Is there some way I can hook the re-calc/draw of psd to the zooming of 
first graph?
Previously with 2 plot commands, I have used subplot(212, sharex=p1), to 
hook the two graphs together on the xaxis
however as the second graph is a psd I don't know how to hook the psd 
input data to the xaxis of the first graph.
Thanks
Steve
From: Eric F. <ef...@ha...> - 2007年03月22日 04:43:49
Richard Brown wrote:
> Hi there,
> 
> I'm pretty new to python; I'm in the process of switching from Matlab.
> I do quite a bit of image processing in my research, and while
> pylab/matplotlib seems to be a great plotting library, some of the
> quirks seem just a little bit frustrating - I'm hoping for some
> enlightenment :)
> 
> When I use imshow or matshow to display an array, the points with
> index (m, n) are displayed with the pixels centred at (0.5 + m, 0.5 +
> n). Is there a setting somewhere to make it so that the centres of the
> pixels are at the index values rather than their bottom left corners?
> Or must I be always adding 0.5 to things to make them appear in the
> right places?
Coincidentally, a few days ago I made this change for matshow; I had 
made it in spy some time ago. I have so far left imshow alone; isn't 
its present behavior consistent with Matlab? That is not necessarily a 
good reason for leaving it the way it is, but it is reason for some 
caution. I suspect quite a few people may prefer it the way it is; 
let's see who responds, and what opinions are voiced.
One way of maintaining compatibility (if it is indeed compatible now, 
and if this is judged desirable) would be to add a kwarg and/or rc 
option. But if there is a consensus that imshow should by default put 
index ticks at cell centers, then I will be happy to make that change.
Eric
> 
> Thanks, I appreciate any help
> 
> Richard
From: Richard B. <rg...@gm...> - 2007年03月22日 03:54:30
Hi there,
I'm pretty new to python; I'm in the process of switching from Matlab.
I do quite a bit of image processing in my research, and while
pylab/matplotlib seems to be a great plotting library, some of the
quirks seem just a little bit frustrating - I'm hoping for some
enlightenment :)
When I use imshow or matshow to display an array, the points with
index (m, n) are displayed with the pixels centred at (0.5 + m, 0.5 +
n). Is there a setting somewhere to make it so that the centres of the
pixels are at the index values rather than their bottom left corners?
Or must I be always adding 0.5 to things to make them appear in the
right places?
Thanks, I appreciate any help
Richard
-- 
Richard Brown
Ph.D. Candidate
Dept. of Mechanical Engineering
University of Canterbury, NZ
From: Stephen G. <ste...@op...> - 2007年03月22日 01:47:33
Trying to get resize event to work, but either I don't understand the 
definition of when resize_event should work, or it's broken.
for example
=======================
from matplotlib import pylab , numerix
def GotResizeEvent( event ):
 print 'Resize event detected'
def GotDrawEvent( event ):
 print 'Draw event detected'
X = range(0, 200)
Y = pylab.sin(X)
r = pylab.plot(X,Y)
pylab.connect( 'resize_event', GotResizeEvent)
pylab.connect( 'draw_event', GotDrawEvent)
pylab.show()
=========================
Will only get draw_events as I zoom in on the data, never a resize event?
I also get draw_events as I resize the window itself, but never a 
resize_event.
So my question, .. what user activity triggers a resize event?
Numerix Version: numpy 1.0
MatPlotLib Version: 0.87.7
Steve
From: Eric F. <ef...@ha...> - 2007年03月21日 21:36:30
John Hunter wrote:
> On 3/21/07, Michael Lerner <mgl...@gm...> wrote:
>> Hi,
>>
>> I want to make a figure that has three subplots. The top one should
>> be a big, mostly square thing. The bottom two should be rectangular
>> things. That is, I want it to look like this:
>>
>> XXXXX
>> XXXXX
>> XXXXX
>> XXXXX
>>
>> XXXXX
>> XXXXX
>>
>> XXXXX
>> XXXXX
>>
>> so, I'm using subplot(311), subplot(312), subplot(313). But, things
>> are getting resized so that each of the rows has the same height.
>> That really messes up the aspect ratio for my top row.
> 
> The following might hrlp:
> 
> ax1 = subplot(211)
> ax2 = subplot(413)
> ax3 = subplot(414)
> 
> JDH
And if you want to tweak the positions you can use, e.g., oldpos = 
ax1.get_position() to find out the present position, and 
ax1.set_position(newpos) to change it. The position rectangles are 
[left, bottom, width, height] in relative coordinates--that is, 
fractions of the figure width and height.
If you want to control the aspect ratio of the data without changing the 
position rectangle (e.g. after adjusting it as above), use
ax1.set_aspect(aspect, adjustable='datalim').
Eric
5 messages has been excluded from this view by a project administrator.

Showing results of 335

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