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





Showing results of 181

<< < 1 .. 3 4 5 6 7 8 > >> (Page 5 of 8)
From: John H. <jdh...@ac...> - 2005年01月15日 22:38:13
>>>>> "Carol" == Carol Leger <car...@sr...> writes:
 Carol> This is how I modified poormans_contour.py:
It's a bug; in the matplotlib/pylab.py function "colorbar", replace
the line that reads
 N = 200
with
 N = cmap.N
No need to tweak the clim....
Should cure what ails ya,
JDH
From: John H. <jdh...@ac...> - 2005年01月15日 20:00:34
>>>>> "Alan" == Alan G Isaac <ai...@am...> writes:
 Alan> Did you make full matplotlib and/or scipy language
 Alan> definitions? If so, are they available? Alan Isaac
I did, as you found in your PS, but I choose not to emphasize them
because I found all the extra color distracting. So I made the emph
color "black", ie the same as the color of plain text, but left the
wordlist there in case I changed my mind
 emphstyle = \color{black}, % color for matplotlib funcs
What do you think? Would it be useful to colorize the matplotlib
functions in the guide?
JDH
From: Alan G I. <ai...@am...> - 2005年01月15日 17:42:59
On 2005年1月15日, John Hunter apparently wrote:
> I'm using latex with the excellent listings package-
> http://www.atscire.de/index.php?nav=products/listings. It knows
> python syntax, and can do string, comment, keyword highlighting and
> more.
Did you make full matplotlib and/or scipy language definitions?
If so, are they available?
Alan Isaac
PS I found this list in the docs,
which is of course part of the answer to my question.
{axes, axis, bar, cla, clf, clim, close, cohere, colorbar,
 colors, csd, draw, errorbar, figimage, figlegend, figtext, figure,
 fill, gca, gcf, gci, get, get_current_fig_manager,
 get_plot_commands, gray, grid, hist, hlines, hold, imshow, jet,
 legend, load, loglog, pcolor, pcolor_classic, plot, plot_date,
 plotting, psd, raise_msg_to_str, rc, rcdefaults, save, savefig,
 scatter, scatter_classic, semilogx, semilogy, set, specgram, stem,
 subplot, table, text, title, vlines, xlabel, ylabel},
From: John H. <jdh...@ac...> - 2005年01月15日 16:49:36
>>>>> "Gary" == Gary <pa...@in...> writes:
 Gary> John, I've been meaning to ask you ... how did you produce
 Gary> the very fine User Guide? Is that TeXmacs? LyX? raw
 Gary> LaTeX? ConTeXt? emacs magic?
I'm using latex with the excellent listings package-
http://www.atscire.de/index.php?nav=products/listings. It knows
python syntax, and can do string, comment, keyword highlighting and
more. 
You can see the latex src that created the user's guide by checking
out users_guide from matplotlib CVS, or visiting
http://cvs.sourceforge.net/viewcvs.py/matplotlib/users_guide . The
README file in that directory contains more information.
For much of the user's guide, I keep the python code in external files
and include them in a special verbatim environment that does syntax
highlighting with , eg
\lstinputlisting[linerange=1-12,caption={Wild and wonderful ways to specify colors;
 see Figure~\ref{fig:color_demo}},
label=lst:color_demo]{code/color_demo.py}
The linerange is used to leave some boilerplate at the beginning and
end of the file (eg some savefig calls to generate the accompanying
figures in eps and png). This helps insure that the python code in
the manual actually runs, since it is the same code used to generate
the figures for the guide.
 Gary> Is there some slick way of getting the listings from the
 Gary> command line window into the document, especially with the
 Gary> comments colorized? I'm writing a small local guide, and
 Gary> was wondering ...
By "the command line window" do you mean the python shell? If so,
you'll have to do some special tweaks to handle the >>> prompt, but
the listings packages is very sophisticated, and can ignore prefixes
or add them, etc.... There is a fairly comprehensive manual. Or did
you mean something else?
JDH 
From: Gary <pa...@in...> - 2005年01月14日 19:59:14
John,
I've been meaning to ask you ... how did you produce the very fine User 
Guide? Is that TeXmacs? LyX? raw LaTeX? ConTeXt? emacs magic?
Is there some slick way of getting the listings from the command line 
window into the document, especially with the comments colorized? I'm 
writing a small local guide, and was wondering ...
-gary
From: John H. <jdh...@ac...> - 2005年01月14日 17:44:22
>>>>> "James" == James Boyle <bo...@ll...> writes:
 James> Is there anyway to place the tick marks so that they are
 James> located outside the axes, i.e. on the same side of the axis
 James> line as the axis labels?
 James> With plots such as imshow and pcolor and even some busy
 James> line plots, the interior minor ticks are completely
 James> obscured and the exact location of the major ticks is
 James> ambiguous.
 James> It would be nice to be able to specify the ticks as inside
 James> or outside (or both), right or left (or both), top or
 James> bottom (or both). This functionality may already be present
 James> but I cannot figure out how to invoke it if it is.
I would like to make tick placement more flexible, for example to
support a detachable tick line so the axis line, tick lines and labels
float below the axes boundary. In addition, I would like the ability
to position ticks along this line as above, centered or below, as you
suggest. But for now this doesn't exist, but you can hack an
approximation.
The tick markers are TICKUP, TICKDOWN, TICKLEFT, and TICKRIGHT,
and these are constants in matplotlib.lines. You can set the tick
markers, for example, to be TICKDOWN. But you'll have to manually
adjust the y position of the labels to be below them. 
The second hack is this only works in interactive mode. ticks are
generated dynamically (eg for panning and zooming) and the ticks
aren't generated until the plot is show. In non-interactive mode, the
change of the default tick's line style is not propogating to the new
ticks that are dynamically generated when the line is shown. This
appears to be a bug so I'll look into it. For now, though, you should
be able to get something that works in non-interactive mode.
import matplotlib
matplotlib.interactive(True)
import matplotlib.lines as mpllines
import pylab as pl
ax = pl.subplot(111)
pl.plot([1,2,3])
lines = ax.get_xticklines()
labels = ax.get_xticklabels()
for line in lines:
 line.set_marker(mpllines.TICKDOWN)
# labels are in axes coords, where 0,0 is lower left of axes rectangle
# and 1,1 is upper right
for label in labels:
 label.set_y(-0.02)
pl.show()
From: John H. <jdh...@ac...> - 2005年01月14日 17:12:43
>>>>> "seberino" == seberino <seb...@sp...> writes:
 seberino> Imagine your arrays had points (Cartesian position
 seberino> vectors) all over the place at completely random points
 seberino> in space. The 'shape' of this plot depends on max and
 seberino> min values of each coordinate. I believe Mathematica
 seberino> plotting would automagically calculate these max and min
 seberino> values and set plot ranges for you. This is why 'shape'
 seberino> attribute of Matplotlib/Numarray seems awkward and
 seberino> unnecessary to me unless I'm missing something.
There are a variety of issues here. 
 - The "shape" attribute comes form Numeric/numarray and is outside
 the realm of matplotlib. matplotlib plots numerix arrays. 
 - The pcolor interface is determined by matlab. matlab has a pcolor
 function which I have tried to implement faithfully. To the
 extent that matplotlib has been successful, this is due in part
 because matlab has a good interface for plotting and replicating
 it generally, is a good thing.
 - Storing the "shape" of a data set allows for memory and efficiency
 savings. To take your example of a set of x,y,z points, you are
 right you cold reconstruct rectilinear grid from this data -- one
 might have to use interpolation but it can be done -- but it would
 require a lot of unnecessary computation for data which already
 lives on a grid. So pcolor assumes your data are on a rectilinear
 grid and it is incumbent upon you to get it into that form.
 
 The meshgrid function takes regularly sampled vector data and
 turns it into a rectilinear grid (this is also a matlab function).
 The matlab griddata function (which is not yet implemented in
 matplotlib) does the same for irregularly sampled data.
JDH
From: Dominique O. <Dom...@po...> - 2005年01月14日 16:49:08
Hi,
When trying to plot the contours of the famous Rosenbrock function:
----------------------------------------
from matplotlib.pylab import *
def rosenbrock(x,y):
 return 10.0 * (y-x**2)**2 + (x-1)**2
x = arange( -1.5, 1.5, 0.01 )
y = arange( -0.5, 1.5, 0.01 )
[X,Y] = meshgrid( x, y )
Z = rosenbrock( X, Y )
contour( Z, x=X, y=Y, levels = 50 )
show()
----------------------------------------
I notice some spurious zigzagging lines towards the top of the plot. Any 
idea where those might be coming from?
Also, the figure produced by the above script is flipped horizontally. 
The corresponding Matlab script produces the correct plot.
Thanks,
Dominique
From: James B. <bo...@ll...> - 2005年01月13日 18:53:03
Is there anyway to place the tick marks so that they are located 
outside the axes, i.e. on the same side of the axis line as the axis 
labels?
With plots such as imshow and pcolor and even some busy line plots, the 
interior minor ticks are completely obscured and the exact location of 
the major ticks is ambiguous.
It would be nice to be able to specify the ticks as inside or outside 
(or both), right or left (or both), top or bottom (or both). This 
functionality may already be present but I cannot figure out how to 
invoke it if it is.
--Jim
From: James B. <bo...@ll...> - 2005年01月13日 17:53:46
To reply to my own post:
On question (1):
I modified the call to colorbar in pylab.py to accept a color map and 
norm keyword arguments. It was this functionality that was needed from 
the mappable image. So if the keywords are provided colorbar uses them, 
otherwise it looks for a mappable image.
This modification disables the observer feature for now if the color 
map is a keyword, a bit more work should get this going.
It looks like it would be easily doable, but I need something for the 
exigencies of work and will get back to this later.
This also would allow for a colorbar key for coloring contours and 
vectors.
I would also like to code up a floating color bar. Often I make 4/5 
images per page with a common colormap and normalization. It is
handy just to plop the reference colorbar in a central location not 
attached to a particular figure.
On question (2):
Alan Isaac pointed out that using the same edgecolor as the fillcolor 
would make the borders invisible.
--Jim
On Jan 12, 2005, at 12:55 PM, James Boyle wrote:
> I have a mesh of irregular polygons, like a finite element mesh. Each 
> polygon has an associated value.
> So, I have defined a color map with a appropriate normalization to 
> define a color for each value and then
> built a collection consisting of the polygon vertices and colors.
> The resulting plot looks pretty good. This technique would seem to be 
> useful for FE grids and Delaunay triangles.
>
> Two questions:
> (1) I want to attach a colorbar to the figure, but as of yet I have 
> not worked out how to do it.
> images such as scatter, imshow, pcolor are mappable and will accept a 
> color bar but my simple polygon fill will not.
>
> (2) How do I eliminate the edge lines about each polygon? I can make 
> them very thin but a width of zero does not appear to work.
> I recall this being discussed on the list, but now I cannot find the 
> reference.
>
> Thanks for any help.
>
> --Jim
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
As you know you must set 'shape' attribute
of your coordinate arrays used to generate a pcolor plot.
Imagine your arrays had points (Cartesian position vectors)
all over the place at completely random points in space.
The 'shape' of this plot depends on max and min values
of each coordinate. I believe Mathematica plotting
would automagically calculate these max and min values
and set plot ranges for you. This is why 'shape'
attribute of Matplotlib/Numarray seems awkward
and unnecessary to me unless I'm missing something.
You should not have ability to set 'shape' your self.
It seems it wouldn't make any sense to *change* the
shape since that is decided by range of your values
already.
Chris
--
_______________________________________
Christian Seberino, Ph.D.
SPAWAR Systems Center San Diego
Code 2872
49258 Mills Street, Room 158
San Diego, CA 92152-5385
U.S.A.
Phone: (619) 553-9973
Fax : (619) 553-6521
Email: seb...@sp...
_______________________________________
From: <seb...@sp...> - 2005年01月13日 05:05:26
I'm still confused about 'shape' attribute of
arrays used to make a pcolor plot.
Suppose you have xarray, yarray and zarray.
The 'shape' of the plot is determined by
the max and min values of each dimension.
Hence you can't really change the 'shape'
of a plot drastically.
Therefore, what does it mean when we set and
later change the 'shape' attribute of these
data arrays?
It seems you should not be allowed to do this
and/or perhaps shape should be calculated
automatically.
Chris
--
_______________________________________
Christian Seberino, Ph.D.
SPAWAR Systems Center San Diego
Code 2872
49258 Mills Street, Room 158
San Diego, CA 92152-5385
U.S.A.
Phone: (619) 553-9973
Fax : (619) 553-6521
Email: seb...@sp...
_______________________________________
From: Alan G I. <ai...@am...> - 2005年01月13日 00:57:19
On 2005年1月12日, James Boyle apparently wrote: 
> (2) How do I eliminate the edge lines about each polygon? I can make
> them very thin but a width of zero does not appear to work.
> I recall this being discussed on the list, but now I cannot find the
> reference.
I recall John suggesting to also set the edge color (to the
same color, of course). I hope a true zero width will
implemented.
However note that interpreting a linewidth of zero as a 1
pixel wide line is what PostScript does. So the only way to
get a true zero width for PostScript output is to fill the
polygon without stroking it.
hth,
Alan Isaac
From: James B. <bo...@ll...> - 2005年01月12日 20:56:04
I have a mesh of irregular polygons, like a finite element mesh. Each 
polygon has an associated value.
So, I have defined a color map with a appropriate normalization to 
define a color for each value and then
built a collection consisting of the polygon vertices and colors.
The resulting plot looks pretty good. This technique would seem to be 
useful for FE grids and Delaunay triangles.
Two questions:
(1) I want to attach a colorbar to the figure, but as of yet I have not 
worked out how to do it.
images such as scatter, imshow, pcolor are mappable and will accept a 
color bar but my simple polygon fill will not.
(2) How do I eliminate the edge lines about each polygon? I can make 
them very thin but a width of zero does not appear to work.
I recall this being discussed on the list, but now I cannot find the 
reference.
Thanks for any help.
--Jim
From: Carol L. <car...@sr...> - 2005年01月12日 20:04:32
I am confused about what is happening when I add a color bar to an image 
using discrete colors. I took the example code for poormans_contour.py 
and added a color bar to it.
The color bar show 9, not 10, equal sized pieces. I figured that the 
10th color could be just a strip on top which was never used in the 
plot. Therefor I set the limits of the plot to -0.1 and 0.1 to ensure 
that parts of the image were below the minimum and parts were above the 
maximum. Now I can clearly see 10 colors on the plot, but only 9 on the 
color bar. Was this the intention? Is there another method of putting 
a color bar on a contour plot of this type?
This is how I modified poormans_contour.py:
After the call to imshow in line 34, I added
clim(vmin = -0.1, vmax = 0.1)
colorbar()
-- 
Ms. Carol A. Leger
SRI International			Phone: (650) 859-4114
333 Ravenswood Avenue G-273
Menlo Park, CA 94025 e-mail: le...@sr...
From: John H. <jdh...@ac...> - 2005年01月12日 15:49:15
>>>>> "Edward" == Edward Abraham <Edw...@da...> writes:
 Edward> At present, the clip_on property needs to be set manually,
 Edward> rather than from within the plot command Cheers,
OK, I believe I fixed this in CVS. In artist.py, replace set_clip_on
with 
 def set_clip_on(self, b):
 """
Set whether artist uses clipping
ACCEPTS: [True | False]
"""
 self._clipon = b
 if not b: self.clipbox = None
And let me know if this fixes your problem.
Thanks for the report,
JDH
From: Eric E. <ems...@ob...> - 2005年01月12日 12:08:21
Hi John,
first: please enjoy your vacation! don't worry about the bugs and 
annoying emails,
I know this is not a hotline!!
As for the second question about the ''illegal'' axis position: in fact 
I would like
VERY much that you are allowed to have your plots outside the window.
I know this sounds strange, but it is indeed very useful to analyse data,
although I am not intending to produce a scientific plot with axes outside
the window of course...
At some point I could send you the small wrapper/functions I wrote to 
display images using
imshow where I put some more options like: scaling, maximum axis, 
offsets etc....
This would then show you what I am trying to reach and in fact could
lead to a very different solution (within matplotlib instead).
Eric
John Hunter wrote:
>>>>>>"Eric" == Eric Emsellem <ems...@ob...> writes:
>>>>>> 
>>>>>>
>
> Eric> 1/ just to remind you that I am still looking for a solution
> Eric> to the previously mentioned bug in imshow (in terms of
> Eric> aspect='preserve').
>
>Hi Eric, thanks for the reminder. Just to let you know, I'm away on
>vacation until next week. Because I am staying with my sister in an
>apartment with an internet connection, I am tempted back to my old
>ways and occasionally respond on the list. But for the more difficult
>questions and bugs, of which yours is one, which require more serious
>coding and testing, I'm deferring until I have a proper setup to work
>with.
>
>Rest assured that I have flagged these many emails and will pick them
>off as I can.
>
>Cheers,
>JDH
>
> 
>
-- 
===============================================================
Observatoire de Lyon ems...@ob...
9 av. Charles-Andre tel: +33 4 78 86 83 84
69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86
France http://www-obs.univ-lyon1.fr/eric.emsellem
===============================================================
From: John H. <jdh...@ac...> - 2005年01月12日 11:51:03
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes:
 Eric> 2/ I have another problem with imshow:
 Eric> When I do for example:
 Eric> figure(1) axes([-0.1,0,0.8,0.8]) myima = rand(50,50)
 Eric> imshow(myima)
 Eric> then it works and shows me the array with the axes partly
 Eric> outside the window since the origin for the X axis is < 0
Hmm, it never occurred to me that someone would be placing the axes
outside the figure! You example appears to indicate that in the
imshow code I am missing a check somewhere for illegal y values but
getting it right for illegal x values. My inclination is to disallow
axes borders outside the figure boundary. Am I correct that you are
only driven to this extreme because you are trying to work around the
preserve bug? If so, perhaps it will be an acceptable solution to
just fix that bug and raise an exception if someone uses left,bottom<0
or right,top>1. 
JDH
From: John H. <jdh...@ac...> - 2005年01月12日 11:34:32
>>>>> "Eric" == Eric Emsellem <ems...@ob...> writes:
 Eric> 1/ just to remind you that I am still looking for a solution
 Eric> to the previously mentioned bug in imshow (in terms of
 Eric> aspect='preserve').
Hi Eric, thanks for the reminder. Just to let you know, I'm away on
vacation until next week. Because I am staying with my sister in an
apartment with an internet connection, I am tempted back to my old
ways and occasionally respond on the list. But for the more difficult
questions and bugs, of which yours is one, which require more serious
coding and testing, I'm deferring until I have a proper setup to work
with.
Rest assured that I have flagged these many emails and will pick them
off as I can.
Cheers,
JDH
From: Eric E. <ems...@ob...> - 2005年01月12日 08:07:36
Hi,
I think what you sent me may help although what you describe looks very much
like I have done in the piece of code I sent. It is not a first priority 
since what I wrote is
''kind of working'' (if I reload things everytime I display) but indeed 
an ''easy''
solution to this problem would be most welcome. The worry I have is that 
at the
moment we cannot load the lut without describing the datad keys and so on
so that it looks like a never ending story if people ask the developers 
everytime
to update the cm/colors files. (otherwise it crashes when you do imshow 
repeatedly)
As for the Question 3:
- I wish to load my array in LINEAR but then load a lut in LOG, so that 
the sampling of
the SAME lut is done but in LOG instead of LINEAR (so the fact that it 
is in log
would only appear when you load the color bar). This is used often when 
I need
to display a set of images side by side, some being in LIN, others in LOG.
My idea is the following:
- it is I think (may be wrong) feasible to add a functionality during 
the mapping of the lut
(when the LinearSegmented array is sampled on 256 levels) so that it 
takes the
LOG10, LN, EXP, or '-' (* -1 to invert a lut) of the abscissa so that the
required effect appears. This would create a smashed lut, or an inverted 
one. etc...
See what I mean?
Eric
Perry Greenfield wrote:
>
> On Jan 11, 2005, at 10:25 AM, Eric Emsellem wrote:
>
>> HI again,
>>
>> I have questions of how to generate new LUTs outside matplotlib.
>>
>> 3 main issues:
>>
>> 1/ how to create a new lut in the same way that cm.py/colors.py is 
>> doing it
>> in matplotlib
>> 2/ how to create a new lut which is given by a set of e.g., 256 
>> colours levels (R, G, B)
>> but not as a segmented array as in cm/colors
>> 3/ How do you rescale a lut without rescaling the array itself?
>> (so an equivalent to load/itt log for example in Midas for those who 
>> know).
>> For example I would like to use the jet lut but with a log increase
>> of the lut so that e.g. displaying the color bar shows it is in ''log''
>>
>> For 1, I am not so sure what to do, and for 2/ I give below
>> what I am doing at the moment. To be frank, it looks quite ugly
>> (mainly because I am a bad programmer and don't know so much about
>> python/matplotlib).
>>
>> I got inspired by cm and colors.py and Midas lut
>> but really this is probably not the way to go.
>> In order to change the lut I just then do:
>>
>> lut('mylut')
>>
>> where 'mylut.lasc' is then the ascii file where the 256 colours are 
>> given in 3 columns
>> (R G B) of 256 rows
>>
>> The problem is that since I do not have the corresponding segmented 
>> array for each
>> lut (and I don't want it to be that way) I need to define a ''dummy'' 
>> array.
>> Then each time I use imshow I must reload the lut (otherwise it uses 
>> this dummy segmented
>> array which is here a gray lut).
>>
>> I am not sure this is all clear, but basically what I am trying to do 
>> here is to just
>> answer questions 1, 2, 3 above and below is an ugly solution for 2 
>> (but incomplete).
>>
>
> I think it is important to realize that you don't need to base it on 
> the existing colormapping mechanism, you just need to duplicate the 
> interface of colormaps, namely that it has N, and name attributes, and 
> that when the object is called with an array or scalar as an argument, 
> it will return the appropriate array (or tuple) as the result. How you 
> convert the array to rgba values is entirely up to you. But I think 
> there is enough similarity to what LinearSegmentColormap that 
> effectively its __call__ method can be resused without changed. You 
> would only override the __init__ to create the _red_lut,
> _green_lut, _blue_lut attribute directly from array arguments (if I 
> remember what MIDAS does; it's been nearly 20 years since I've used it!).
>
> That is something like this (untested, untried!)
>
> class ArrayColormap(LinearSegmentColormap):
> """ really, it seems that linear should inherit from Array 
> instead!""" def __init__(name, r,g,b):
> """create color map from supplied r,g,b arrays"""
> # put checks on r,g,b arrays here...
> self._red_lut = r
> self._green_lut = g
> self._blue_lut = b
> self.N = len(r)
> self.name = name
>
> This is something we should add but you can try this in the meantime.
>
> The second part is how to set the lut to this. You can provide the new 
> colormap instance as a keyword (cmap) argument to imshow or figimage. 
> But I understand you would like a functional way to update an existing 
> display. There doesn't appear to be a function to do this, but a new 
> one is easily defined. Something like this ought to work (again 
> untested, and again, we should supply this in the next version)
>
> from
> def loadcm(cm):
> """change the default colormap to cm"""
> rc('image', cmap='yourcmname')
> im = gci()
> if im is not None:
> im.set_cmap(cm)
> draw_if_interactive()
>
> But the problem with this is that default mechanism won't work since 
> this eventually calls cm.get_cmap, which then looks for the named cm 
> in the cm.datad array to construct a LinearSegmentedColormap instance. 
> I think the solution here may need to have some sort of caching 
> mechanism so that user defined colormaps can be used as a default 
> (perhaps John can think of some other mechanism).
>
> I agree that it should be simple to define your own on the fly and be 
> able to use these. So we'll see how this is best handled.
>
> I'm not sure what you mean by 3. If you are changing the lut (i.e., 
> which colors map to which image intensity levels, the rescaling the 
> image is required when displaying it (in the "old days" when image 
> displays were only 8-bit and had hardware luts, one didn't have to do 
> that). If all you mean is that you already had transformed the data to 
> log format but want to show the lut as though the data were linearly 
> displayed, I suppose one would display a colorbar where the 
> intensities were suitably transformed from a linear ramp. But please 
> elaborate.
>
> Perry
>
>
>
>
>
-- 
===============================================================
Observatoire de Lyon ems...@ob...
9 av. Charles-Andre tel: +33 4 78 86 83 84
69561 Saint-Genis Laval Cedex fax: +33 4 78 86 83 86
France http://www-obs.univ-lyon1.fr/eric.emsellem
===============================================================
From: Perry G. <pe...@st...> - 2005年01月11日 22:35:28
On Jan 11, 2005, at 10:25 AM, Eric Emsellem wrote:
> HI again,
>
> I have questions of how to generate new LUTs outside matplotlib.
>
> 3 main issues:
>
> 1/ how to create a new lut in the same way that cm.py/colors.py is 
> doing it
> in matplotlib
> 2/ how to create a new lut which is given by a set of e.g., 256 
> colours levels (R, G, B)
> but not as a segmented array as in cm/colors
> 3/ How do you rescale a lut without rescaling the array itself?
> (so an equivalent to load/itt log for example in Midas for those who 
> know).
> For example I would like to use the jet lut but with a log increase
> of the lut so that e.g. displaying the color bar shows it is in 
> ''log''
>
> For 1, I am not so sure what to do, and for 2/ I give below
> what I am doing at the moment. To be frank, it looks quite ugly
> (mainly because I am a bad programmer and don't know so much about
> python/matplotlib).
>
> I got inspired by cm and colors.py and Midas lut
> but really this is probably not the way to go.
> In order to change the lut I just then do:
>
> lut('mylut')
>
> where 'mylut.lasc' is then the ascii file where the 256 colours are 
> given in 3 columns
> (R G B) of 256 rows
>
> The problem is that since I do not have the corresponding segmented 
> array for each
> lut (and I don't want it to be that way) I need to define a ''dummy'' 
> array.
> Then each time I use imshow I must reload the lut (otherwise it uses 
> this dummy segmented
> array which is here a gray lut).
>
> I am not sure this is all clear, but basically what I am trying to do 
> here is to just
> answer questions 1, 2, 3 above and below is an ugly solution for 2 
> (but incomplete).
>
I think it is important to realize that you don't need to base it on 
the existing colormapping mechanism, you just need to duplicate the 
interface of colormaps, namely that it has N, and name attributes, and 
that when the object is called with an array or scalar as an argument, 
it will return the appropriate array (or tuple) as the result. How you 
convert the array to rgba values is entirely up to you. But I think 
there is enough similarity to what LinearSegmentColormap that 
effectively its __call__ method can be resused without changed. You 
would only override the __init__ to create the _red_lut,
_green_lut, _blue_lut attribute directly from array arguments (if I 
remember what MIDAS does; it's been nearly 20 years since I've used 
it!).
That is something like this (untested, untried!)
class ArrayColormap(LinearSegmentColormap):
	""" really, it seems that linear should inherit from Array 
instead!"""	def __init__(name, r,g,b):
		"""create color map from supplied r,g,b arrays"""
 # put checks on r,g,b arrays here...
 self._red_lut = r
 self._green_lut = g
 self._blue_lut = b
 self.N = len(r)
 self.name = name
This is something we should add but you can try this in the meantime.
The second part is how to set the lut to this. You can provide the new 
colormap instance as a keyword (cmap) argument to imshow or figimage. 
But I understand you would like a functional way to update an existing 
display. There doesn't appear to be a function to do this, but a new 
one is easily defined. Something like this ought to work (again 
untested, and again, we should supply this in the next version)
from
def loadcm(cm):
 """change the default colormap to cm"""
 rc('image', cmap='yourcmname')
 im = gci()
 if im is not None:
 im.set_cmap(cm)
 draw_if_interactive()
But the problem with this is that default mechanism won't work since 
this eventually calls cm.get_cmap, which then looks for the named cm in 
the cm.datad array to construct a LinearSegmentedColormap instance. I 
think the solution here may need to have some sort of caching mechanism 
so that user defined colormaps can be used as a default (perhaps John 
can think of some other mechanism).
I agree that it should be simple to define your own on the fly and be 
able to use these. So we'll see how this is best handled.
I'm not sure what you mean by 3. If you are changing the lut (i.e., 
which colors map to which image intensity levels, the rescaling the 
image is required when displaying it (in the "old days" when image 
displays were only 8-bit and had hardware luts, one didn't have to do 
that). If all you mean is that you already had transformed the data to 
log format but want to show the lut as though the data were linearly 
displayed, I suppose one would display a colorbar where the intensities 
were suitably transformed from a linear ramp. But please elaborate.
Perry
From: Hans F. <H.F...@so...> - 2005年01月11日 21:44:37
John,
>>>>>> "Hans" == Hans Fangohr <H.F...@so...> writes:
>
> Hans> Hm. Done that. A figure window pops up immediately but is
> Hans> not being updated correctly: a part of the graph is visible,
> Hans> the other part of the figure (which was underneath another
> Hans> window initially) appears white. The titel of the figure
> Hans> says "Figure 1 (Not responding)". IDLE, however, responds
> Hans> happily ;-) T
>
> Todd, many moons ago you wrote me and said I had inadvertently screwed
> up something in tkagg show that broke the idle -n behavior. If I
> recall correctly, we never reverted, since I didn't understand exactly
> what to do. Perhaps you could revisit the current tkagg versus the
> old one to make sure it is right.
>
> Hans, does it make a difference if you uncomment
>
> #os.environ['PYTHONINSPECT'] = '1'
>
> in the show method of
> site-packages/matplotlib/backends/backend_tkagg.py? You should set
> 'interactive : True' as Todd suggested. Do not use show, as it is not
> designed for interactive use. I suggest carefully testing all 4
> combinations: with and without the PYTHONINSPECTmline, and with and
> without -n.
Setting 'interactive=True' in .matplotlibrc
IDLE #os.environ['PYTHONINSPECT'] = '1' -> fail
IDLE -n #os.environ['PYTHONINSPECT'] = '1' -> fail
IDLE os.environ['PYTHONINSPECT'] = '1' -> fail
IDLE -n os.environ['PYTHONINSPECT'] = '1' -> success
So that's good. However, notice that also
setting 'interactive=False'
IDLE os.environ['PYTHONINSPECT'] = '1'
seems to work! (Which is what I wanted initially and what didn't work.)
So from my naive perspective the line "environ['PYTHONINSPECT'] = '1' " 
should not be commented.
Thanks for you help -- hope this is useful,
Hans
From: Todd M. <jm...@st...> - 2005年01月11日 21:34:10
On Tue, 2005年01月11日 at 16:17, Hans Fangohr wrote:
> Hi Todd,
> 
> thanks for the quick response.
> 
> > I just tried this out and found that setting "interactive" to "True" in
> > C:\python23\share\matplotlib\.matplotlibrc obviated the need to use the
> > show() command. The plot then comes up as soon as you issue the plot()
> > command.
> Hm. Done that. A figure window pops up immediately but is not being 
> updated correctly: a part of the graph is visible, the other part of the 
> figure (which was underneath another window initially) appears white. The 
> titel of the figure says "Figure 1 (Not responding)".
> IDLE, however, responds happily ;-) T
> 
> > Multiple plotting-closing cycles worked fine in the same Idle
> > session.
> Good -- so this works at your machine, not at mine. The strange thing is 
> that I installed WinXP from scratch just a few days ago on that machine, 
> so it should be a fairly 'clean' environment.
> 
> I take it there is no more recent version of matplotlib for windows 
> (and Python 2.3) than 0.70.1?
No. Just to be clear: I set interactive to True, and used "idle -n"
from Python-2.3.4 and it worked fine for me on Windows 2000 Pro. Idle
should be reporting "No Subprocess" when it starts up.
Regards,
Todd
> Thanks,
> 
> Hans
> 
> 
> >
> > Regards,
> > Todd
> >
> > On Tue, 2005年01月11日 at 14:29, Hans Fangohr wrote:
> >> Dear all,
> >>
> >> I tried to make matplotlib work with IDLE on Windows. I have settled for
> >> the Enthough Python Edition and the latest matplotlib (both executables
> >> can be found in www.soton.ac.uk/~fangohr/download/python).
> >>
> >> I have prepared the exercises on linux and am now trying to run them in
> >> windows. This is where I realised that matplotlib doesn't work well with
> >> IDLE.
> >>
> >> More particularly, it is known that the default backend TkAgg doesn't work
> >> with IDLE (see here http://matplotlib.sourceforge.net/backends.html#TkAgg)
> >> but it appears to work with "IDLE -n" (as it says on that web page).
> >>
> >> The problem I experience is this:
> >>
> >> -start idle
> >> -execute these commands:
> >>
> >> import pylab
> >> pylab.plot(range(10))
> >> pylab.show()
> >>
> >> This produces a figure window which seems to work fine.
> >>
> >> At this point when closing the figure window, I can't get the IDLE
> >> prompt active again. (It seems that IDLE thinks the program and the figure
> >> process are still running, and is waiting for control to return.)
> >>
> >> This, in itself, is maybe not suprising. However, the idle -n switch
> >> doesn't seem to solve the problem for me (see below).
> >>
> >> The same problem is observed when I execute a program in the IDLE editor
> >> (by pressing F5).
> >>
> >> Maybe this is the problem:
> >>
> >> I have tried to tell IDLE to start with the "-n" by modifying the properties for the
> >> IDLE link in the start menu from
> >>
> >> C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw"
> >>
> >> to
> >>
> >> C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw" "-n"
> >>
> >> but this doesn't seem to solve the problem: I get exactly the same
> >> behaviour as described above. Am I doing the right thing?
> >>
> >> Can anyone give me some advice?
> >>
> >> Many thanks,
> >>
> >> Hans
> >>
> >>
> >> P.S. Funnily enough, there are two Windows machines with a very similar
> >> software setup, i.e. enthought python plus matplotlib, where the default
> >> TkAgg interface seems to work happily togethe with IDLE. Unfortunately,
> >> these are not the ones I am trying to get to work :-|
> >>
> >>
> >>
> >>
> >>
> >> -------------------------------------------------
> >> Dr Hans Fangohr
> >>
> >> Computational Engineering & Design Research Group
> >> School of Engineering Sciences
> >> University of Southampton
> >> Southampton, SO17 1BJ
> >> United Kingdom
> >>
> >> Location: Building 25, Room 1027
> >> phone : +44 (0) 23 8059 8345
> >> fax : +44 (0) 23 8059 7082
> >> email : fa...@so...
> >> -------------------------------------------------
> >>
> >>
> >>
> >> -------------------------------------------------------
> >> The SF.Net email is sponsored by: Beat the post-holiday blues
> >> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> >> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> >> _______________________________________________
> >> Matplotlib-users mailing list
> >> Mat...@li...
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> > -- 
> >
> >
> >
> > -------------------------------------------------------
> > The SF.Net email is sponsored by: Beat the post-holiday blues
> > Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> > It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
> 
> -------------------------------------------------
> Dr Hans Fangohr
> 
> Computational Engineering & Design Research Group
> School of Engineering Sciences
> University of Southampton
> Southampton, SO17 1BJ
> United Kingdom
> 
> Location: Building 25, Room 1027
> phone : +44 (0) 23 8059 8345
> fax : +44 (0) 23 8059 7082
> email : fa...@so...
> -------------------------------------------------
> 
> 
> 
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
From: John H. <jdh...@ac...> - 2005年01月11日 21:26:44
>>>>> "Hans" == Hans Fangohr <H.F...@so...> writes:
 Hans> Hm. Done that. A figure window pops up immediately but is
 Hans> not being updated correctly: a part of the graph is visible,
 Hans> the other part of the figure (which was underneath another
 Hans> window initially) appears white. The titel of the figure
 Hans> says "Figure 1 (Not responding)". IDLE, however, responds
 Hans> happily ;-) T
Todd, many moons ago you wrote me and said I had inadvertently screwed
up something in tkagg show that broke the idle -n behavior. If I
recall correctly, we never reverted, since I didn't understand exactly
what to do. Perhaps you could revisit the current tkagg versus the
old one to make sure it is right.
Hans, does it make a difference if you uncomment
 #os.environ['PYTHONINSPECT'] = '1'
in the show method of
site-packages/matplotlib/backends/backend_tkagg.py? You should set
'interactive : True' as Todd suggested. Do not use show, as it is not
designed for interactive use. I suggest carefully testing all 4
combinations: with and without the PYTHONINSPECTmline, and with and
without -n. As you probably know, you'll need to restart idle after
every change to the module source code, or at least reload the module
if you know how to do that.
Some bugs refuse to die. Let us know...
 Hans> I take it there is no more recent version of matplotlib for
 Hans> windows (and Python 2.3) than 0.70.1?
That's the latest.
Good luck!
JDH
From: Hans F. <H.F...@so...> - 2005年01月11日 21:17:16
Hi Todd,
thanks for the quick response.
> I just tried this out and found that setting "interactive" to "True" in
> C:\python23\share\matplotlib\.matplotlibrc obviated the need to use the
> show() command. The plot then comes up as soon as you issue the plot()
> command.
Hm. Done that. A figure window pops up immediately but is not being 
updated correctly: a part of the graph is visible, the other part of the 
figure (which was underneath another window initially) appears white. The 
titel of the figure says "Figure 1 (Not responding)".
IDLE, however, responds happily ;-) T
> Multiple plotting-closing cycles worked fine in the same Idle
> session.
Good -- so this works at your machine, not at mine. The strange thing is 
that I installed WinXP from scratch just a few days ago on that machine, 
so it should be a fairly 'clean' environment.
I take it there is no more recent version of matplotlib for windows 
(and Python 2.3) than 0.70.1?
Thanks,
Hans
>
> Regards,
> Todd
>
> On Tue, 2005年01月11日 at 14:29, Hans Fangohr wrote:
>> Dear all,
>>
>> I tried to make matplotlib work with IDLE on Windows. I have settled for
>> the Enthough Python Edition and the latest matplotlib (both executables
>> can be found in www.soton.ac.uk/~fangohr/download/python).
>>
>> I have prepared the exercises on linux and am now trying to run them in
>> windows. This is where I realised that matplotlib doesn't work well with
>> IDLE.
>>
>> More particularly, it is known that the default backend TkAgg doesn't work
>> with IDLE (see here http://matplotlib.sourceforge.net/backends.html#TkAgg)
>> but it appears to work with "IDLE -n" (as it says on that web page).
>>
>> The problem I experience is this:
>>
>> -start idle
>> -execute these commands:
>>
>> import pylab
>> pylab.plot(range(10))
>> pylab.show()
>>
>> This produces a figure window which seems to work fine.
>>
>> At this point when closing the figure window, I can't get the IDLE
>> prompt active again. (It seems that IDLE thinks the program and the figure
>> process are still running, and is waiting for control to return.)
>>
>> This, in itself, is maybe not suprising. However, the idle -n switch
>> doesn't seem to solve the problem for me (see below).
>>
>> The same problem is observed when I execute a program in the IDLE editor
>> (by pressing F5).
>>
>> Maybe this is the problem:
>>
>> I have tried to tell IDLE to start with the "-n" by modifying the properties for the
>> IDLE link in the start menu from
>>
>> C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw"
>>
>> to
>>
>> C:\Python23\pythonw.exe "C:\Python23\Lib\idlelib\idle.pyw" "-n"
>>
>> but this doesn't seem to solve the problem: I get exactly the same
>> behaviour as described above. Am I doing the right thing?
>>
>> Can anyone give me some advice?
>>
>> Many thanks,
>>
>> Hans
>>
>>
>> P.S. Funnily enough, there are two Windows machines with a very similar
>> software setup, i.e. enthought python plus matplotlib, where the default
>> TkAgg interface seems to work happily togethe with IDLE. Unfortunately,
>> these are not the ones I am trying to get to work :-|
>>
>>
>>
>>
>>
>> -------------------------------------------------
>> Dr Hans Fangohr
>>
>> Computational Engineering & Design Research Group
>> School of Engineering Sciences
>> University of Southampton
>> Southampton, SO17 1BJ
>> United Kingdom
>>
>> Location: Building 25, Room 1027
>> phone : +44 (0) 23 8059 8345
>> fax : +44 (0) 23 8059 7082
>> email : fa...@so...
>> -------------------------------------------------
>>
>>
>>
>> -------------------------------------------------------
>> The SF.Net email is sponsored by: Beat the post-holiday blues
>> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
>> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> -- 
>
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-------------------------------------------------
Dr Hans Fangohr
Computational Engineering & Design Research Group
School of Engineering Sciences
University of Southampton
Southampton, SO17 1BJ
United Kingdom
Location: Building 25, Room 1027
phone : +44 (0) 23 8059 8345
fax : +44 (0) 23 8059 7082
email : fa...@so...
-------------------------------------------------
3 messages has been excluded from this view by a project administrator.

Showing results of 181

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