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 25 results of 25

From: Ken M. <mc...@ii...> - 2007年03月28日 23:38:52
On Mar 28, 2007, at 6:03 PM, Antonino Ingargiola wrote:
> On 3/28/07, Ken McIvor <mc...@ii...> wrote:
>> You should probably do the acquisition asynchronously by running it
>> in a separate thread.
<snip>
>
> That's exactly what I'd like to do. The problem is that if I run
> gtk.main() (the gtk main GUI loop) in a separate thread the program
> stops until I do something on the GUI (for example passing the mouse
> on it).
Does it do this if you run gtk.main() in the main thread (e.g. the 
interpreter prompt) while doing something else in a background thread?
> My understanding so far is the following. When the function
> that execute gtk.main() is executed, python doesn't switch thread
> until either 100 bytecode instructions are executed or since an I/O
> (potentially) blocking operation in executed.
I think you're more or less correct but are unaware of one important 
factor. Here's my understanding of how multithreading works in 
Python...
Thread switching is controlled by something called the Global 
Interpreter Lock, which is implemented in an abstract way on top of 
an OS lock/mutex object. Only one Python thread runs at a time 
because the Python interpreter requires a thread to hold the GIL 
before it can execute bytecode instructions. The running thread 
holds the GIL while is executes 100 instructions. During this time 
other Python threads block waiting to acquire the GIL. After it has 
executed its 100 instructions, the running thread releases the GIL 
and then attempts to reacquire it. The OS ensures that things are 
fair by preventing one thread from reacquiring the GIL over and over 
again when other threads are also waiting for it.
Python doesn't actually detect you do something that will block the 
thread, like an I/O operation. Instead, the C code implementing an I/ 
O operation like file.write() releases the GIL before performing the 
operation. This allows a different thread to acquire it and run some 
more bytecode instructions while the first thread performs its I/O 
operation.
> When I'm doing nothing on the GUI application, neither 100 byte 
> code instructions are executed in the thread neither an I/O call is 
> performed, so the whole program (including the *other* threads) 
> stalls.
I'm not sure on the details, but the C code that implements gtk.main 
() almost certainly releases the GIL before running the GUI event 
loop. Otherwise things like iPython wouldn't be able to run the GUI 
in a separate thread. So, that's probably not the problem.
It's possible that there's another lock that's used to protect access 
to the gtk module. If that's the case you could be causing deadlock 
by calling making gtk calls from multiple threads. In my experience 
it's best to stick to the one-thread rule: the thread that runs the 
GUI's event loop is the only thread that's allowed to do anything 
related to the GUI.
> Basically, I don't know which is the right way to put a Gtk GUI in
> background, while another thread get the data asynchronously.
You probably want to put the GUI in the main thread. The main thread 
is the only thread in a Python program that receives the 
KeyboardInterrupt exception when the process receives a SIGINT (i.e. 
when the user hits ^C in the shell). Also, most Python GUI toolkits 
require their event loops run from the thread that originally 
imported the module.
> BTW, the timer idea is good and eliminates the need to call
> asynchronously the GUI thread to update the plot, which seems (the
> latter case) not very simple to do.
Yep. It's impossible to inject arbitrary code into a Python thread; 
the thread has to figure out what it's supposed to do by periodically 
polling something or retrieving some kind of message by blocking on a 
queue. Blocking on a queue isn't an option for the GUI thread.
You might be able to trigger Gtk signals from a separate thread but 
in my experience tricks like that can be, well, tricky.
> Thanks to your suggestion to use the image.set_data method I've
> created a simplified script (pasted at the end) that demonstrate how
> to do live-update while acquiring (jep!).
Glad I could help! :-)
> The last think I'm not yet able to do is to update the colorbar to
> autoscale with the new incoming data. The the script that follows
> tries to update the colorbar too but it does not work (on matplotlib
> 0.87 at least).
I have no idea if this will help, but you might need to call 
AxesImage.changed() after calling AxesImage.set_data().
Ken
From: Eric F. <ef...@ha...> - 2007年03月28日 23:18:25
I forgot "reply to all".
From: Antonino I. <tri...@gm...> - 2007年03月28日 23:03:47
On 3/28/07, Ken McIvor <mc...@ii...> wrote:
> On Mar 27, 2007, at 12:35 PM, Antonino Ingargiola wrote:
[cut]
> You should probably do the acquisition asynchronously by running it
> in a separate thread. That thread would read in the data one point
> at a time, perform any pre-processing, and post the results to a
> place that's shared between it and the main plotting thread. The
> main thread would periodically check and see if the shared data has
> changed and redraw the plot if needed. I'm not sure how hard this is
> to do in a reasonable way in pylab, but I've used this approach
> before in wxPython GUIs.
That's exactly what I'd like to do. The problem is that if I run
gtk.main() (the gtk main GUI loop) in a separate thread the program
stops until I do something on the GUI (for example passing the mouse
on it). My understanding so far is the following. When the function
that execute gtk.main() is executed, python doesn't switch thread
until either 100 bytecode instructions are executed or since an I/O
(potentially) blocking operation in executed. When I'm doing nothing
on the GUI application, neither 100 byte code instructions are
executed in the thread neither an I/O call is performed, so the whole
program (including the *other* threads) stalls.
Basically, I don't know which is the right way to put a Gtk GUI in
background, while another thread get the data asynchronously.
BTW, the timer idea is good and eliminates the need to call
asynchronously the GUI thread to update the plot, which seems (the
latter case) not very simple to do.
> > Furthermore, this function plot the new data above the
> > old one, so the plot becomes slower and slower while the acquisition
> > goes on. If I uncommented the cla() line, I get a plot that is blank
> > most of the time and that shows the data only for a fraction of second
> > while the new plot is performed.
> `
> You might want to consider create a mock data source that generates a
> stream of values from some pre-collected data or Python's "random"
> module. That would let you work on debugging the plotting end of
> things first. It would also make it easier for you to share your
> code with the list.
Thanks to your suggestion to use the image.set_data method I've
created a simplified script (pasted at the end) that demonstrate how
to do live-update while acquiring (jep!).
The last think I'm not yet able to do is to update the colorbar to
autoscale with the new incoming data. The the script that follows
tries to update the colorbar too but it does not work (on matplotlib
0.87 at least).
Any hints?
Many thanks so far...
Ciao,
 ~ Antono
PS: Here it is the script:
from time import sleep
from random import randint
from pylab import *
N = 5
def fake_data_generator():
 sleep(randint(1,3)/10.0)
 return rand()*100
def data_aquisition_loop():
 data = zeros((N,N))
 for j in range(N):
 for i in range(N):
 print ' - Acquiring pixel (',i,',',j,') ... '
 data[j,i] = fake_data_generator()
 plot_update(data)
 return data
def setup_plot(data):
 global image, color_bar
 title('Scanning Data')
 image = imshow(data, interpolation='nearest', origin='upper',
 extent=[0,N,N,0])
 color_bar = colorbar()
def plot_update(data):
 image.set_data(data)
 color_bar.set_array(data)
 color_bar.autoscale()
 draw()
if __name__ == '__main__':
 ion()
 setup_plot(rand(N*N).reshape(N,N))
 data_aquisition_loop()
From: Ken M. <mc...@ii...> - 2007年03月28日 20:52:15
On Mar 28, 2007, at 3:41 PM, Dav...@no... wrote:
>
> Hi! I have a wxmpl.PlotPanel object with a cross-hair style cursor
> (without the full screen crosshairs). When I select a rectangle w/ 
> this
> cursor it zooms in to that rectangle - great! Now, how do I get the
> rectangle coordinates (preferably in data coords.) from the rectangle
> selection event? Thanks!
You can subscribe to region selection events using 
wxmpl.EVT_SELECTION, which is a wxPython event. See `demos/ 
picking_points.py' for a detailed example.
Due to a failure of imagination you can currently have region 
selections zoom or emit events. If you need to do both it'll take 
some jiggery-pokery. Let me know if this is the case and I'll write 
something up.
Ken
From: <Dav...@no...> - 2007年03月28日 20:42:05
Hi! I have a wxmpl.PlotPanel object with a cross-hair style cursor
(without the full screen crosshairs). When I select a rectangle w/ this
cursor it zooms in to that rectangle - great! Now, how do I get the
rectangle coordinates (preferably in data coords.) from the rectangle
selection event? Thanks!
DG 
From: Matthew K. G. <mk...@cs...> - 2007年03月28日 19:56:21
jens haemmerling wrote:
> ----------------------------------------------------------------------
>
> Message: 1
> Date: 2007年3月28日 12:39:05 +0200
> From: "jens haemmerling" <jha...@gm...>
> Subject: [Matplotlib-users] surface plot...
> To: mat...@li...
> Message-ID: <200...@gm...>
> Content-Type: text/plain; charset="us-ascii"
>
>
> hello 
>
> I have problems to plot surfaces like f(x,y)=x*y...
> for example "plot_surface([1,2,3], [4,5,6], [7,8,9])" doesn't work either...
>
> I imported the following:
>
> from numpy import *
> import pylab as p
> import matplotlib.axes3d as p3
>
> does anybody have an advice?
>
> 
See "simple3d.py" in the examples:
http://matplotlib.sourceforge.net/matplotlib_examples_0.90.0.zip
-- Matt
From: Niklas S. <nik...@gm...> - 2007年03月28日 19:35:38
Hi guys,
I'm trying to make a specgram() for some wave samples that I have 
read into 'data' using pyaudiolab's read_frames() (put into wavread())
When I do
from wavread import *
from pylab import *
from statistics import *
data, datasize, samplerate, channels = wavread("myfile.wav")
specgram(data)
I get:
Warning: divide by zero encountered in log10
(array([[ 2.26730611e-02, 1.51890672e-02, 7.78123371e-03, ...,
 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
 [ 9.11969843e-03, 2.81931459e-03, 3.13995580e-03, ...,
 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
 [ 7.25346631e-04, 4.83291216e-05, 2.59076878e-04, ...,
 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
 ...,
 [ 5.19279887e-08, 1.53242938e-07, 1.46461798e-07, ...,
 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
 [ 1.00769359e-07, 2.00314891e-07, 3.04618029e-07, ...,
 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],
 [ 2.86252093e-08, 5.42052713e-07, 1.50494595e-07, ...,
 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]]), 
array([ 0. , 0.0078125, 0.015625 , 0.0234375, 0.03125 ,
 0.0390625, 0.046875 , 0.0546875, 0.0625 , 0.0703125,
 0.078125 , 0.0859375, 0.09375 , 0.1015625, 0.109375 ,
 0.1171875, 0.125 , 0.1328125, 0.140625 , 0.1484375,
 0.15625 , 0.1640625, 0.171875 , 0.1796875, 0.1875 ,
 0.1953125, 0.203125 , 0.2109375, 0.21875 , 0.2265625,
 0.234375 , 0.2421875, 0.25 , 0.2578125, 0.265625 ,
 0.2734375, 0.28125 , 0.2890625, 0.296875 , 0.3046875,
 0.3125 , 0.3203125, 0.328125 , 0.3359375, 0.34375 ,
 0.3515625, 0.359375 , 0.3671875, 0.375 , 0.3828125,
 0.390625 , 0.3984375, 0.40625 , 0.4140625, 0.421875 ,
 0.4296875, 0.4375 , 0.4453125, 0.453125 , 0.4609375,
 0.46875 , 0.4765625, 0.484375 , 0.4921875, 0.5 ,
 0.5078125, 0.515625 , 0.5234375, 0.53125 , 0.5390625,
 0.546875 , 0.5546875, 0.5625 , 0.5703125, 0.578125 ,
 0.5859375, 0.59375 , 0.6015625, 0.609375 , 0.6171875,
 0.625 , 0.6328125, 0.640625 , 0.6484375, 0.65625 ,
 0.6640625, 0.671875 , 0.6796875, 0.6875 , 0.6953125,
 0.703125 , 0.7109375, 0.71875 , 0.7265625, 0.734375 ,
 0.7421875, 0.75 , 0.7578125, 0.765625 , 0.7734375,
 0.78125 , 0.7890625, 0.796875 , 0.8046875, 0.8125 ,
 0.8203125, 0.828125 , 0.8359375, 0.84375 , 0.8515625,
 0.859375 , 0.8671875, 0.875 , 0.8828125, 0.890625 ,
 0.8984375, 0.90625 , 0.9140625, 0.921875 , 0.9296875,
 0.9375 , 0.9453125, 0.953125 , 0.9609375, 0.96875 ,
 0.9765625, 0.984375 , 0.9921875, 1. ]), array 
([ 6.40000000e+01, 1.28000000e+02, 1.92000000e+02, ...,
 9.73440000e+04, 9.74080000e+04, 9.74720000e+04]), 
<matplotlib.image.AxesImage instance at 0x3324fa8>)
For another sample, I get a nice spectrogram. What can it be about my 
sample that would give me such an error? What is the error caused by? 
A Google on the error message provided me with nothing.
Sincerely yours
	Niklas Saers
From: Eric F. <ef...@ha...> - 2007年03月28日 18:45:09
Suresh Pillai wrote:
> The new matshow() seems to like ticks every 4 units (or multiples of 4 
> for larger scales) rather than the normal, more desirable every 5 units.
> 
> Compare:
> 
> import pylab
> matrix = pylab.rand(30,30)
> pylab.matshow(matrix)
> pylab.show()
> 
> with
> 
> import pylab
> matrix = pylab.rand(30,30)
> pylab.imshow(matrix)
> pylab.show()
> 
> Looking at the code right now, but since matshow() calls imshow(), it is 
> not obvious to me. I presume it has something to do with the line
> 
> ax = fig.add_axes([0.15, 0.09, 0.775, 0.775])
No, this determines where in the figure window the axes will be located.
> 
> in matshow(). Still learning the internals of mpl ...
It is a question of the tick locator that is used.
imshow is using the default MaxNLocator, which generally does a nice job 
but will sometimes put ticks on non-integer locations. Therefore, for 
matshow, I added a kwarg to guarantee use of integer locations. I 
should be able to tweak it so that its results differ from the default 
MaxNLocator only when the latter would produce non-integers. That was 
the intention.
> 
> Also, as mentioned in a previous thread, the new matshow() is missing tick 
> marks on the lower x-axis.
I thought I fixed that in svn, but it looks like I was foiled by a bug 
somewhere in axis.py. I'll have to track it down. To be continued...
Eric
> 
> Cheers,
> Suresh
From: Bill B. <wb...@gm...> - 2007年03月28日 18:16:26
On 3/29/07, John Hunter <jd...@gm...> wrote:
> On 3/28/07, Giorgio F. Gilestro <gil...@gm...> wrote:
> > Hi,
> > I have to question that will help some colleagues/friends of mine to switch
> > to python from matlab.
> >
> > 1 - is there an automatic translator of code from matlab to
> > python/numpy/matplotlib? I believe it would be very easy to implement due
> > the similar syntax between the two. I could do something similar myself but
> > first I better make sure it doesn't exist yet.
>
> None that I know of, and it probably wouldn't be easy. For one thing,
> matlab uses parentheses for function calls and indexing, and it is
> probably not always obvious which is which for a translator. One
> could write something that got it mostly right and flagged
> ambiguities, but I think you should expect that a human would have to
> clean it up afterwards unless you attempt something ambitious and not
> easy. Prove me wrong!
Another thing that is maybe even more problematic is that matlab uses
call-by-value and value-based assignment while Python/Numpy uses
call-by-reference and reference-based assignment. So in matlab
 A = B;
 A(3,2) = 22;
will not modify B, but the equivalent numpy code
 A = B
 A[2,1] = 22
will modify both A and B. That means for a translator to create
efficient code it really needs to analyze if each copy created is ever
modified, and if so whether that matters. So I think you'd need to do
a full parsing of the matlab code. No regexp tricks are going to cut
it.
Another very tricky thing is that the indexing rules are very
different. Any time you see something like A(idx) in matlab you have
to really know what type of thing idx is exactly in order to translate
it properly. And then there's the issue with matlab code that calls
"SomeNonTrivialToolboxRoutine(x)". Even if it does exist in SciPy,
often the parameters are very different. And there's the one-based vs
zero-based thing. But that's probably the least of one's worries.
So there are a lot of challenges. But none of it seems impossible,
and there are some shortcuts you could take to get something that
would still be a useful first-pass, but require hand touch-up.
On the plus side, it's probably easier to translate from a
pass-by-value language to pass-by-reference than the other way around.
--bb
From: Suresh P. <sto...@ya...> - 2007年03月28日 17:43:53
The new matshow() seems to like ticks every 4 units (or multiples of 4 
for larger scales) rather than the normal, more desirable every 5 units.
Compare:
import pylab
matrix = pylab.rand(30,30)
pylab.matshow(matrix)
pylab.show()
with
import pylab
matrix = pylab.rand(30,30)
pylab.imshow(matrix)
pylab.show()
Looking at the code right now, but since matshow() calls imshow(), it is 
not obvious to me. I presume it has something to do with the line
ax = fig.add_axes([0.15, 0.09, 0.775, 0.775])
in matshow(). Still learning the internals of mpl ...
Also, as mentioned in a previous thread, the new matshow() is missing tick 
marks on the lower x-axis.
Cheers,
Suresh
From: Suresh P. <sto...@ya...> - 2007年03月28日 17:30:47
Continuing from a previous thread re the new matshow(), adding a 
colorbar() causes the matrix to shrink relative to the colorbar. 
Furthermore this colorbar overlaps with the figure title.
For those like me who need a colorbar as a legend and/or who do not want 
the matrix visualisation in a new figure with aspect ratio constrained, 
all that needs to be done is to replace line 1424 in pylab.py for 
matshow() as follows
 # OLD LINE: fig = figure(fignum, figsize=figaspect(A))
 fig = gcf()
You're probably best off to create a new function matshowB() in case you 
ever need the default functionality.
Cheers,
Suresh
From: John H. <jd...@gm...> - 2007年03月28日 17:04:01
On 3/28/07, Giorgio F. Gilestro <gil...@gm...> wrote:
> Hi,
> I have to question that will help some colleagues/friends of mine to switch
> to python from matlab.
>
> 1 - is there an automatic translator of code from matlab to
> python/numpy/matplotlib? I believe it would be very easy to implement due
> the similar syntax between the two. I could do something similar myself but
> first I better make sure it doesn't exist yet.
None that I know of, and it probably wouldn't be easy. For one thing,
matlab uses parentheses for function calls and indexing, and it is
probably not always obvious which is which for a translator. One
could write something that got it mostly right and flagged
ambiguities, but I think you should expect that a human would have to
clean it up afterwards unless you attempt something ambitious and not
easy. Prove me wrong!
> 2 - Is there a python/numpy/mpl equivalent of EEGlab? see:
> http://www.sccn.ucsd.edu/eeglab/
There is pbrain, which is not and does not attempt to be an equivalent
of EEGLab, but it is an EEG viewer/analysis package in python, which
uses matplotlib (and VTK). It is specialized for spectral analysis,
but could be extended to do other things.
 http://neuroimaging.scipy.org/pbrain/
I first wrote an EEG analysis package in matlab, and after becoming
frustrated with the lack of good support for complex data structures,
networking, and programming paradigms, I jettisoned it for python and
wrote pbrain. I wrote matplotlib in support of the pbrain
application, so some of the work has already been done :-)
JDH
From: Giorgio F. G. <gil...@gm...> - 2007年03月28日 16:49:21
Hi,
I have to question that will help some colleagues/friends of mine to switch
to python from matlab.
1 - is there an automatic translator of code from matlab to
python/numpy/matplotlib? I believe it would be very easy to implement due
the similar syntax between the two. I could do something similar myself but
first I better make sure it doesn't exist yet.
2 - Is there a python/numpy/mpl equivalent of EEGlab? see:
http://www.sccn.ucsd.edu/eeglab/
thanks
Giorgio
From: Fernando P. <fpe...@gm...> - 2007年03月28日 15:14:49
On 3/28/07, Ken McIvor <mc...@ii...> wrote:
> You'd almost certainly be happier doing things the other way around.
> Most GUI toolkits are extremely fussy about what thread the GUI event
> loop runs in. For example, wxPython requires App.MainLoop() be
> called from the thread that first imported the wxPython module. That
> being said, it's possible to run the GUI thread in the background --
> the iPython wizards might be able to help you figure it out.
No, the limitation you describe is there just as much. What we do in
ipython is push the *user code* execution into the secondary thread,
to make sure we keep the GUI toolkits happy for the very reasons you
outline.
Cheers,
f
From: Ken M. <mc...@ii...> - 2007年03月28日 15:10:34
On Mar 27, 2007, at 12:35 PM, Antonino Ingargiola wrote:
>
> I'm searching to display in realtime some data read serial port. The
> data is a 2D matrix and is read element wise from the serial, one
> pixel each one (or more) seconds.
You shouldn't have any problems making this happen, although it 
requires a lot more legwork than creating normal interactive plots.
> I'm running the script from "ipython -pylab" using the command "run
> scriptname". After "loading" the script I interactively launch the
> function that start the data acquisition and I would like to see the
> acquired data so far.
I've never tried to do something like this using pylab before, so I 
probably can't be of much help there. However, I can point you 
toward an example of how to do it from within wxPython using a timer.
> In the loop that perform the data acquisition I'm currently calling 
> this function to plot data:
>
> def plot_data_in_itinere(data, **kwargs):
> global first_plot
> d = data.ravel()[find(data.ravel() > 0)]
> m = d.mean()
> vr = round(5*d.std() / m, 3)
> #clf()
> title('Scanning Data')
> xlabel('Mean Value: '+str(int(round(m)))+' -- Relative 
> Variation: '+str(vr))
> b,t = ylim()
> ylim(t,b)
> imshow(data.astype(float),
> interpolation='nearest',
> vmin=0,
> origin='lower', **kwargs)
> if first_plot:
> colorbar()
> first_plot = False
>
> However the call to the function is "blocking". So the acquisition
> time is longer (not only I have to wait the data but I have to wait
> the plot too).
You should probably do the acquisition asynchronously by running it 
in a separate thread. That thread would read in the data one point 
at a time, perform any pre-processing, and post the results to a 
place that's shared between it and the main plotting thread. The 
main thread would periodically check and see if the shared data has 
changed and redraw the plot if needed. I'm not sure how hard this is 
to do in a reasonable way in pylab, but I've used this approach 
before in wxPython GUIs.
> Furthermore, this function plot the new data above the
> old one, so the plot becomes slower and slower while the acquisition
> goes on. If I uncommented the cla() line, I get a plot that is blank
> most of the time and that shows the data only for a fraction of second
> while the new plot is performed.
`
You might want to consider create a mock data source that generates a 
stream of values from some pre-collected data or Python's "random" 
module. That would let you work on debugging the plotting end of 
things first. It would also make it easier for you to share your 
code with the list.
> Is there a way to update (or substitute) the current showed matrix
> data, deleting the old plots (in the axis). I have to confess that
> I've have not understand well how the pylab interactive mode works.
pylab.imshow() returns a matplotlib.image.AxesImage object. It looks 
like you can update the data array using its set_data() method. The 
class documentation is available on the matplotlib website:
	http://matplotlib.sourceforge.net/matplotlib.image.html#AxesImage
> Ideally the plot should be performed in background, while the script
> goes on and wait the next data arrival.
You'd almost certainly be happier doing things the other way around. 
Most GUI toolkits are extremely fussy about what thread the GUI event 
loop runs in. For example, wxPython requires App.MainLoop() be 
called from the thread that first imported the wxPython module. That 
being said, it's possible to run the GUI thread in the background -- 
the iPython wizards might be able to help you figure it out.
> I've tried to do this with a simple gtk app that embeds a 
> matplotlib plot. Hoever, I don't know how to send the application 
> in background. I've tried to do something like this:
>
<snip>
>
> the PlotScanApp implement the gui (full files attached). Running the
> script the image should be updated with random data each 1 sec. but
> only the first image is showed. I suppose this is not the way to put a
> gui drawing app in background...
Well, using pylab from within a GUI application is a bit dodgy to 
begin with. I can see a few potential problems. The first is that 
you're calling plotting commands from within the main thread, 
although the GUI is running in a background thread. You might try 
doing the plotting from within the GUI thread by having a timer fire 
once a second to redraw the plot. The second problem is that you're 
not calling pylab.draw(), which forces the current figure to redraw 
itself. Whether or not pylab is running in interactive mode might be 
a factor here. There's some documentation about interactive mode and 
the ion()/ioff() commands here:
	http://matplotlib.sourceforge.net/interactive.html
Ken
From: Giorgio L. <gio...@ch...> - 2007年03月28日 14:59:20
Hello to all,
I've thread that apperead some time ago on this list about matlab and 
teaching.
I've discovered python recently and translated part of the routine I 
use in python (www.chemometrics.it).
Some of my collegue asked me if I could show them how to use python. For 
matlab user I guess the first problem is to setup everything, but I just 
fixed it preparing a directory with all the package I need and a 
matplotlibrc file for interactive mode + a shortcut for idle -n use.
The second problem is that people now wants some bells and whistles of 
matlab that I have to admit sometime can be very helpful for saving 
time. The bells and whistles are about the workspace.
It's difficult to cut and paste from gnumeric/excel (I generally use txt 
file but it's no so immediate) and also there is no "visual" workspace. 
I cannot succeed also in saving workspace (I know there is a function so 
iosave.mat but I didn't manage easily hot to use it)
For overpass this problems I've tried to use QME-DEV which is in early 
stage of development (alpha) but promise well.
What people like of python/matplot/scipy
-its free ;)
-they like a lot the plotting style and capabilities (they find the png 
and svg file very clear and accurate)
-they like IDLE as editor (ehy it's has the same color of matlab ;) ! )
So my question is . Do you have a similar experience ?
How do you help people in moving the first step ?
do you use (and also does it exist) a more friendly environment than 
IDLE except from QME-DEV.
I know that this question may look silly, but in my opinion also how 
much is user friendly a software is very important for getting new users.
Cheers to all
Giorgio
From: John H. <jd...@gm...> - 2007年03月28日 13:52:42
On 3/28/07, Nadia Dencheva <den...@st...> wrote:
> Numarray does not work with Python 2.5 on 64 bit Linux.
> If this is a 64 bit Linux machine try using numpy instead.
If this doesn't help, here are the generic "segfault" instructions::
# How to diagnose where a segfault is occurring
First thing to try is simply rm -rf the site-packages/matplotlib and
build subdirs and get a clean install. Installing a new version over
a pretty old version has been known to cause trouble, segfault, etc.
Try importing these packages individually
 import matplotlib._image
 import matplotlib._transforms
 #one of these three depending on which numerix package you are using
 import matplotlib.backends._na_backend_agg # for numarray
 import matplotlib.backends._nc_backend_agg # for Numeric
 import matplotlib.backends._ns_backend_agg # for numpy
 import matplotlib.backends._tkagg
 import matplotlib._agg
If the last two work and the others don't, it is likely you need to
upgrade your gcc, because on some platforms (OS X for sure) old
versions of gcc cannot compile new versions of pycxx, which matplotlib
uses for building some but not all of it's extensions. Report back
which if any work or segfault or raise tracebacks,
If that shed additional light, again flush the build and install dirs,
and try setting VERBOSE=True in setup.py before doing a clean install.
The VERBOSE setting will generate lots of extra output and may help
indicate where the segfault is occurring
From: John H. <jd...@gm...> - 2007年03月28日 13:46:59
On 3/28/07, jens haemmerling <jha...@gm...> wrote:
> I have problems to plot surfaces like f(x,y)=x*y...
> for example "plot_surface([1,2,3], [4,5,6], [7,8,9])" doesn't work either...
>
> I imported the following:
>
> from numpy import *
> import pylab as p
> import matplotlib.axes3d as p3
>
> does anybody have an advice?
You can do surface plots with axe3d, but mpl isn't really suited for
3d plotting since 3d plotting is nascent and not supported. We
include it in hopes that someone else will ike it and improve it but
that hasn't happened yet.
Personally, unless you are doing interactive stuff like rotating your
figure, surface plots don't help much, and mpl 3d is really too slow
for interactive 3d. I use imshow or pcolor with colormapping, which
will give you just about all the information you can get out of a
non-interactive 3d plot.
JDH
From: John H. <jd...@gm...> - 2007年03月28日 13:44:24
On 3/28/07, Mark Bakker <ma...@gm...> wrote:
> Hello List -
>
> A while back, the default font changed in the matplotlibrc file.
> Does anybody recall what the old default font was?
> I kinda liked it better than the current font, but I don't recall what it
> was.
The default font listing was
#font.serif : Bitstream Vera Serif, New Century Schoolbook,
Century Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9
L, Times New Roman, Times, Palatino, Charter, serif
#font.sans-serif : Bitstream Vera Sans, Lucida Grande, Verdana,
Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
#font.cursive : Apple Chancery, Textile, Zapf Chancery, Sand, cursive
#font.fantasy : Comic Sans MS, Chicago, Charcoal, Impact,
Western, fantasy
#font.monospace : Bitstream Vera Sans Mono, Andale Mono, Nimbus
Mono L, Courier New, Courier, Fixed, Terminal, monospace
in the rc file. In the last release, we decided to go with a
"commented out" rc file and rely on internal defaults unless user
explicitly uncommented something. This makes it easier for us to
change the default ors rc settings and not generate as many warnings
to naive users. But when we went to the internal default, for some
reason this listing was not preserved internally. I just readded it
and committed it.
Before this, there was a different ordering but I would have to dig
through the svn archive to find it. I decided to make bitstream the
default since we ship it. If you are referring to the "pre bitstream"
default, I suggest you start poking through older revisions of the
matplotlibrc.template file in svn.
JDH
From: Nadia D. <den...@st...> - 2007年03月28日 12:41:46
Numarray does not work with Python 2.5 on 64 bit Linux.
If this is a 64 bit Linux machine try using numpy instead.
Nadia Dencheva
Matt Beal wrote:
> Having upgraded to 2.5, I get a segfault when running a very simple plot 
> script (test.py) at the show() function. Prior to show() I can save to 
> file and the result looks good. The GUI is crashing on show().
> 
> Any suggestions to fix welcome (I'm guessing many of you know the 
> solution to this problem).
> 
> "Annoying" debug information below:
> 
> Thanks!
> -Matt
> 
> hostname:~/.matplotlib>cat test.py
> from pylab import *
> plot([1,2,3])
> show()
> 
> hostname:~/.matplotlib>python test.py --verbose-debug-annoying -dTkAgg
> matplotlib data path ..../python2.5/site-packages/matplotlib/mpl-data
> $HOME=/home/username
> loaded rc file /home/username/.matplotlib/matplotlibrc
> matplotlib version 0.90.0
> verbose.level debug-annoying
> interactive is False
> platform is linux2
> loaded modules: ['_bisect', '_sha512', 'pylab', 'datetime', 
> 'matplotlib.tempfile ', 'distutils.sysconfig', 'encodings.encodings', 'str
> uct', 'tempfile', 'pytz.os', 'zipimport', 'string', 
> 'matplotlib.__future__', 'pytz.tzinfo', ' pytz.datetime', 'distutils.re 
> <http://distutils.re>', 'bisect'
> , 'signal', 'random', 'matplotlib.pytz', 'locale', 'encodings', 
> 'dateutil', ' matplotlib.warnings', 'pytz.pytz', 'matplotlib.sys', 're
> ', 'math', 'fcntl', 'UserDict', 'distutils.os', 'matplotlib', 'codecs', 
> 'md5', '_locale', ' matplotlib.os', 'thread', 'itertools', 'di
> stutils.sys', 'os', '__future__', '_sre', '__builtin__', 'matplotlib.re 
> <http://matplotlib.re>', 'operator', ' distutils.string', 
> 'matplotlib.datetime', 'pos
> ixpath', 'errno', 'binascii', 'sre_constants', '_sha256', 
> 'matplotlib.md5', 'types', 'pytz.sys', '_codecs', 'pytz', 'copy', '_struct'
> , '_types', 'matplotlib.dateutil', 'hashlib', 'distutils', 'posix', 
> 'encodings.aliases', 'exceptions', 'sre_parse', 'pytz.bisect', 'd
> istutils.distutils ', 'copy_reg', 'sre_compile', '_hashlib', '_random', 
> 'site', '__main__', 'shutil', 'strop', 'encodings.codecs', 'ge
> ttext', 'pytz.sets ', 'stat', 'warnings', 'encodings.types', 
> 'encodings.ascii', 'sys', 'os.path', 'pytz.gettext', 'matplotlib.distutil
> s', 'distutils.errors', 'linecache', ' matplotlib.shutil', 'sets']
> numerix numarray 1.5.2
> font search path ['..../python2.5/site-packages/matplotlib/mpl-data']
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/cmtt10.ttf
> trying fontname 
> ..../python2.5/site-packages/matplotlib/mpl-data/VeraMoIt.ttf
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/cmex10.ttf
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/VeraBI.ttf
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/VeraBd.ttf
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/cmmi10.ttf
> trying fontname 
> ..../python2.5/site-packages/matplotlib/mpl-data/VeraSeBd.ttf
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/cmr10.ttf
> trying fontname 
> ..../python2.5/site-packages/matplotlib/mpl-data/VeraMono.ttf
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/cmsy10.ttf
> trying fontname ..../python2.5/site-packages/matplotlib/mpl-data/Vera.ttf
> CONFIGDIR=/home/username/.matplotlib
> loaded ttfcache file /home/username/.matplotlib/ttffont.cache
> backend TkAgg version 8.5
> FigureCanvasAgg.draw
> RendererAgg.__init__
> RendererAgg.__init__ width=650.0, height=490.0
> RendererAgg.__init__ _RendererAgg done
> RendererAgg.__init__ done
> RendererAgg._get_agg_font
> findfont found sans-serif, normal, normal 400, normal, 12.0
> findfont returning ..../python2.5/site-packages/matplotlib/mpl-data/Vera.ttf
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg.points_to_pixels
> RendererAgg.points_to_pixels
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg.points_to_pixels
> RendererAgg.points_to_pixels
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg.points_to_pixels
> RendererAgg.points_to_pixels
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg.points_to_pixels
> RendererAgg.points_to_pixels
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg.points_to_pixels
> RendererAgg.points_to_pixels
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg.points_to_pixels
> RendererAgg.points_to_pixels
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg._get_agg_font
> RendererAgg.draw_text
> RendererAgg._get_agg_font
> Segmentation fault (core dumped)
> 
> hostname:~/.matplotlib>
> 
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> 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: Mark B. <ma...@gm...> - 2007年03月28日 12:22:30
Hello List -
A while back, the default font changed in the matplotlibrc file.
Does anybody recall what the old default font was?
I kinda liked it better than the current font, but I don't recall what it
was.
Thanks,
Mark
From: jens h. <jha...@gm...> - 2007年03月28日 10:39:54
hello 
I have problems to plot surfaces like f(x,y)=x*y...
for example "plot_surface([1,2,3], [4,5,6], [7,8,9])" doesn't work either...
I imported the following:
from numpy import *
import pylab as p
import matplotlib.axes3d as p3
does anybody have an advice?
-- 
"Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ...
Jetzt GMX ProMail testen: http://www.gmx.net/de/go/promail
From: Evan M. <eva...@gm...> - 2007年03月28日 01:23:10
Thanks, Eric,
Yes, that works for the stripped down version, but not for what I am trying
to do. The examples I have given have the range of one of the plots nicely
fitting inside that of the other (ie, plot 1 range 15 to 26, plot 2 range 17
to 23), but sometimes with what I am doing I have, for example, plot 1
range 15 to 23 and plot 2 range 17 to 25. In this case, passing the levels
from plot 1 to plot 2 means that levels 24 and 25 of plot 2 are stripped
away; this, at least, is what I think is happening because I have white
areas of my plot that weren't there before. It seems to me that it would be
quite useful to have the option to override the colorbar range, setting it
to be the same as defined by clim, or some other values.
As a solution for now, I think I will just use one colorbar for the two
plots. Thanks for your help with this, and the tip about being explicit in
my programs!
-Evan
On 3/27/07, Eric Firing <ef...@ha...> wrote:
>
> Evan,
>
> OK, I see what the problem is: you need to tell the second contour
> command to use the same contour levels as the first one is using.
> Something like this:
>
> figure(1)
> CS1 = contourf(x)
> clim(cmin, cmax)
> colorbar()
> figure(2)
> CS2 = contourf(y, levels=CS1.levels)
> clim(cmin, cmax)
> colorbar()
>
> Does this give the desired result?
>
> The big difference between pcolor and contourf in this context is that
> pcolor is automatically generating a colormap with 256 colors, and may
> use any or all of those colors, so the colorbar is effectively
> continuous. Contourf works with a small discrete set of colors taken
> from such a colormap, so colorbar shows the same discrete set. The
> boundaries are either generated automatically in contourf, or set via
> the levels kwarg. Colorbar gets the boundaries from the output of the
> contourf call, which pylab saves and passes along to colorbar even if
> you don't do so explicitly yourself. But pylab has no way of knowing
> that you want the contour levels in the second figure to match the
> first, so you have to be explicit.
>
> Usually at this point someone chimes in to point out the virtues of
> being explicit in your program even when you don't have to...
>
> Eric
>
>
>
> Evan Mason wrote:
> > Hi Eric, the following lines below will show this. Interestingly, the
> > correct (or, at least, what I want) behaviour results from using pcolor,
> > but not with contourf.
> >
> >
> > a = arange(12, 27, .5)
> > b = arange(17, 23, .5)
> > x, y = meshgrid(a, b)
> >
> > # get max and min for clim
> > cmin = min(x.min(), y.min()) # cmin = 12
> > cmax = max(x.max(), y.max()) # cmax = 26.5
> >
> > figure(1)
> > contourf(x)
> > #pcolor(x)
> > clim([cmin, cmax])
> > colorbar()
> > figure(2)
> > contourf(y)
> > #pcolor(y)
> > clim([cmin, cmax])
> > colorbar()
> >
> >
> > -Evan
> >
> >
> >
> >
> > On 3/27/07, *Eric Firing* < ef...@ha...
> > <mailto:ef...@ha...>> wrote:
> >
> > Evan,
> >
> > That is getting clearer, but it still seems to me that no override
> > should be needed in this case; it should "just work", so if it
> doesn't,
> > either there is a bug in mpl or a bug in the code. It would be most
> > helpful if you would write a stripped-down simplest-possible script
> > that
> > illustrates the problem. Then I can either show how to fix the
> script,
> > or I can use the script to help me track down the mpl bug, if that
> is
> > the problem.
> >
> > Eric
> >
> > Evan Mason wrote:
> > > Hi Eric
> > >
> > > I am using matplotlib-0.90.0.
> > >
> > > I am making 2 contourf subplots of temperature values which have
> > similar
> > > but not equal ranges. In subplot1 the range is 15-25; in
> > subplot2 it is
> > > 16 to 24. I use clim, giving it the max and min values obtained
> > from a
> > > comparison of subplot1 and 2; i.e., I use clim([15, 25]) on both
> > > subplots. The two subplots display exactly as I want them to.
> > >
> > > Next, I want 2 colorbars to go with the two subplots. I want the
> > range
> > > of each colorbar to be the same, set as the clim values (15 and
> 25).
> > > This happens for subplot1, but not for subplot2, which shows the
> > range
> > > 16-24, following its input data range and not the clim values.
> > >
> > > So what I want to know is if it is possible to overide the
> colorbar
> > > limits, setting them to 15-25?
> > >
> > > I hope that's clearer now, thanks, Evan
> > >
> > >
> > >
> > > On 3/27/07, * Eric Firing* < ef...@ha...
> > <mailto:ef...@ha...>
> > > <mailto:ef...@ha... <mailto:ef...@ha...>>> wrote:
> > >
> > > Evan,
> > >
> > > It is still not quite clear to me what you want versus what
> > you are
> > > getting. With recent versions of mpl, the colorbar
> > automatically uses
> > > the same color boundaries as contourf, if that is what the
> > colorbar is
> > > tracking. What version of mpl are you using?
> > >
> > > (With the most recent mpl I see that there is a strange bug
> > such that
> > > setting clim clobbers the axis tick labeling for the
> > colorbar--yet
> > > another thing that needs to be figured out and fixed.)
> > >
> > >
> >
> >
>
>
From: Eric F. <ef...@ha...> - 2007年03月28日 00:43:29
Evan,
OK, I see what the problem is: you need to tell the second contour 
command to use the same contour levels as the first one is using. 
Something like this:
figure(1)
CS1 = contourf(x)
clim(cmin, cmax)
colorbar()
figure(2)
CS2 = contourf(y, levels=CS1.levels)
clim(cmin, cmax)
colorbar()
Does this give the desired result?
The big difference between pcolor and contourf in this context is that 
pcolor is automatically generating a colormap with 256 colors, and may 
use any or all of those colors, so the colorbar is effectively 
continuous. Contourf works with a small discrete set of colors taken 
from such a colormap, so colorbar shows the same discrete set. The 
boundaries are either generated automatically in contourf, or set via 
the levels kwarg. Colorbar gets the boundaries from the output of the 
contourf call, which pylab saves and passes along to colorbar even if 
you don't do so explicitly yourself. But pylab has no way of knowing 
that you want the contour levels in the second figure to match the 
first, so you have to be explicit.
Usually at this point someone chimes in to point out the virtues of 
being explicit in your program even when you don't have to...
Eric
Evan Mason wrote:
> Hi Eric, the following lines below will show this. Interestingly, the 
> correct (or, at least, what I want) behaviour results from using pcolor, 
> but not with contourf.
> 
> 
> a = arange(12, 27, .5)
> b = arange(17, 23, .5)
> x, y = meshgrid(a, b)
> 
> # get max and min for clim
> cmin = min(x.min(), y.min()) # cmin = 12
> cmax = max(x.max(), y.max()) # cmax = 26.5
> 
> figure(1)
> contourf(x)
> #pcolor(x)
> clim([cmin, cmax])
> colorbar()
> figure(2)
> contourf(y)
> #pcolor(y)
> clim([cmin, cmax])
> colorbar()
> 
> 
> -Evan
> 
> 
> 
> 
> On 3/27/07, *Eric Firing* < ef...@ha... 
> <mailto:ef...@ha...>> wrote:
> 
> Evan,
> 
> That is getting clearer, but it still seems to me that no override
> should be needed in this case; it should "just work", so if it doesn't,
> either there is a bug in mpl or a bug in the code. It would be most
> helpful if you would write a stripped-down simplest-possible script
> that
> illustrates the problem. Then I can either show how to fix the script,
> or I can use the script to help me track down the mpl bug, if that is
> the problem.
> 
> Eric
> 
> Evan Mason wrote:
> > Hi Eric
> >
> > I am using matplotlib-0.90.0.
> >
> > I am making 2 contourf subplots of temperature values which have
> similar
> > but not equal ranges. In subplot1 the range is 15-25; in
> subplot2 it is
> > 16 to 24. I use clim, giving it the max and min values obtained
> from a
> > comparison of subplot1 and 2; i.e., I use clim([15, 25]) on both
> > subplots. The two subplots display exactly as I want them to.
> >
> > Next, I want 2 colorbars to go with the two subplots. I want the
> range
> > of each colorbar to be the same, set as the clim values (15 and 25).
> > This happens for subplot1, but not for subplot2, which shows the
> range
> > 16-24, following its input data range and not the clim values.
> >
> > So what I want to know is if it is possible to overide the colorbar
> > limits, setting them to 15-25?
> >
> > I hope that's clearer now, thanks, Evan
> >
> >
> >
> > On 3/27/07, * Eric Firing* < ef...@ha...
> <mailto:ef...@ha...>
> > <mailto:ef...@ha... <mailto:ef...@ha...>>> wrote:
> >
> > Evan,
> >
> > It is still not quite clear to me what you want versus what
> you are
> > getting. With recent versions of mpl, the colorbar
> automatically uses
> > the same color boundaries as contourf, if that is what the
> colorbar is
> > tracking. What version of mpl are you using?
> >
> > (With the most recent mpl I see that there is a strange bug
> such that
> > setting clim clobbers the axis tick labeling for the
> colorbar--yet
> > another thing that needs to be figured out and fixed.)
> >
> >
> 
> 
From: Evan M. <eva...@gm...> - 2007年03月28日 00:20:04
Hi Eric, the following lines below will show this. Interestingly, the
correct (or, at least, what I want) behaviour results from using pcolor, but
not with contourf.
a = arange(12, 27, .5)
b = arange(17, 23, .5)
x, y = meshgrid(a, b)
# get max and min for clim
cmin = min(x.min(), y.min()) # cmin = 12
cmax = max(x.max(), y.max()) # cmax = 26.5
figure(1)
contourf(x)
#pcolor(x)
clim([cmin, cmax])
colorbar()
figure(2)
contourf(y)
#pcolor(y)
clim([cmin, cmax])
colorbar()
-Evan
On 3/27/07, Eric Firing <ef...@ha...> wrote:
>
> Evan,
>
> That is getting clearer, but it still seems to me that no override
> should be needed in this case; it should "just work", so if it doesn't,
> either there is a bug in mpl or a bug in the code. It would be most
> helpful if you would write a stripped-down simplest-possible script that
> illustrates the problem. Then I can either show how to fix the script,
> or I can use the script to help me track down the mpl bug, if that is
> the problem.
>
> Eric
>
> Evan Mason wrote:
> > Hi Eric
> >
> > I am using matplotlib-0.90.0.
> >
> > I am making 2 contourf subplots of temperature values which have similar
> > but not equal ranges. In subplot1 the range is 15-25; in subplot2 it is
> > 16 to 24. I use clim, giving it the max and min values obtained from a
> > comparison of subplot1 and 2; i.e., I use clim([15, 25]) on both
> > subplots. The two subplots display exactly as I want them to.
> >
> > Next, I want 2 colorbars to go with the two subplots. I want the range
> > of each colorbar to be the same, set as the clim values (15 and 25).
> > This happens for subplot1, but not for subplot2, which shows the range
> > 16-24, following its input data range and not the clim values.
> >
> > So what I want to know is if it is possible to overide the colorbar
> > limits, setting them to 15-25?
> >
> > I hope that's clearer now, thanks, Evan
> >
> >
> >
> > On 3/27/07, * Eric Firing* <ef...@ha...
> > <mailto:ef...@ha...>> wrote:
> >
> > Evan,
> >
> > It is still not quite clear to me what you want versus what you are
> > getting. With recent versions of mpl, the colorbar automatically
> uses
> > the same color boundaries as contourf, if that is what the colorbar
> is
> > tracking. What version of mpl are you using?
> >
> > (With the most recent mpl I see that there is a strange bug such
> that
> > setting clim clobbers the axis tick labeling for the colorbar--yet
> > another thing that needs to be figured out and fixed.)
> >
> >
>
>

Showing 25 results of 25

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