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



Showing 7 results of 7

From: Friedrich R. <fri...@gm...> - 2010年03月27日 22:29:07
2010年3月27日 Ariel Rokem <ar...@be...>:
> I am trying to make a color-map which will respond to the range of values in
> the data itself. That is - I want to take one of the mpl colormaps and use
> parts of it, depending on the range of the data.
>
> In particular, I am interested in using the plt.cm.RdYlBu_r colormap. If the
> data has both negative and positive values, I want 0 to map to the central
> value of this colormap (a pale whitish yellow) and I want negative values to
> be in blue and positive numbers to be in red. Also - I would want to use the
> parts of the colormap that represent how far away the smallest and largest
> values in the data are from 0. So - if my data is in the range [x1,x2] I
> would want to use the part of the colormap in indices
> 127-127*abs(x1)/(x2-x1) through 127+127*x2/(x2-x1). If the data only
> includes positive numbers, I would want to only use the blue part of the
> colormap and if there are negative numbers, I would want to only use the red
> part of the colormap (in these cases, I would also want to take only a
> portion of the colormap which represents the size of the interval [x1,x2]
> relative to the interval [0,x1] or [x2,0], as the case may be).
>
> I think that this might be useful when comparing matrices generated from
> different data, but with the same computation, such as correlation or
> coherence (see http://nipy.sourceforge.net/nitime/examples/fmri.html to get
> an idea of what I mean).
I might miss something important, but why not use pcolor() with kwargs
vmin and vmax,
http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.pcolor,
e.g.:
maxval = numpy.abs(C).max()
pcolor(C, vmin = -maxval, vmax = maxval)
As far as I can judge, this should have the desired effect.
Friedrich
From: Ariel R. <ar...@be...> - 2010年03月27日 19:28:25
Hi Brian,
Thanks for the code - this is definitely in the direction of what I want to
make!
The RdYlBu_r colormap is one of the built-in colormaps available in
matplotlib.pyplot.cm (you can see all of them here:
http://www.scipy.org/Cookbook/Matplotlib/Show_colormaps). I think that using
the built-in colormaps might give nicer transitions between the colors, so
instead of transitioning linearily between red and white and white and blue,
it transitions in a slightly non-linear way, along several segments.
Compare:
plot(plt.cm.RdYlBu_r(arange(256)))
with
plot(my_cmap(arange(256)))
I think that the more nonlinear one might look a little bit nicer (and might
be less perceptually misleading in interpreting color differences in the
result). But I need to figure out how many segments there are in there.
Thanks - Ariel
On Sat, Mar 27, 2010 at 4:14 AM, Brian Blais <bb...@br...> wrote:
> On Mar 27, 2010, at 1:13 , Ariel Rokem wrote:
>
> In particular, I am interested in using the plt.cm.RdYlBu_r colormap. If
> the data has both negative and positive values, I want 0 to map to the
> central value of this colormap (a pale whitish yellow) and I want negative
> values to be in blue and positive numbers to be in red.
>
>
> not sure if this is what you want (I'd never heard of RdYlBu_r...I need to
> go read up!), but I've used a similar colormap with the code posted below.
> You might be able to modify it for your case.
>
>
> hope this helps!
>
> bb
>
> from pylab import *
>
> def bluewhitered(a,N=256):
> bottom = [0, 0, 0.5]
> botmiddle = [0, 0.5, 1]
> middle = [1, 1, 1]
> topmiddle = [1, 0, 0]
> top = [0.5, 0, 0]
>
> lims=[a.min(),a.max()]
>
> if lims[0]<0 and lims[1]>0:
> ratio=abs(lims[0])/(abs(lims[0])+lims[1])
>
> cdict={}
> cdict['red']=[]
> cdict['green']=[]
> cdict['blue']=[]
>
> # negative part
> red=[(0.0, 0.0, 0.0),
> (ratio/2, 0.0, 0.0),
> (ratio, 1.0, 1.0)]
> green=[(0.0, 0.0, 0.0),
> (ratio/2, 0.5, 0.5),
> (ratio, 1.0, 1.0)]
> blue=[(0.0, 0.5, 0.5),
> (ratio/2, 1, 1),
> (ratio, 1.0, 1.0)]
>
> cdict['red'].extend(red)
> cdict['green'].extend(green)
> cdict['blue'].extend(blue)
>
> nratio=1-(1-ratio)/2.0
> # positive part
> red=[(ratio, 1.0, 1.0),
> (nratio, 1.0, 1.0),
> (1, 0.5, 0.5)]
> green=[(ratio, 1.0, 1.0),
> (nratio, 0., 0.),
> (1, 0.0, 0.0)]
> blue=[(ratio, 1., 1.),
> (nratio, 0, 0),
> (1, 0, 0)]
>
> cdict['red'].extend(red)
> cdict['green'].extend(green)
> cdict['blue'].extend(blue)
>
>
>
>
> elif lims[0]>=0: # all positive
> cdict={}
> cdict['red']=[]
> cdict['green']=[]
> cdict['blue']=[]
>
> ratio=0.0
> nratio=0.5
>
> # positive part
> red=[(ratio, 1.0, 1.0),
> (nratio, 1.0, 1.0),
> (1, 0.5, 0.5)]
> green=[(ratio, 1.0, 1.0),
> (nratio, 0., 0.),
> (1, 0.0, 0.0)]
> blue=[(ratio, 1., 1.),
> (nratio, 0, 0),
> (1, 0, 0)]
>
> cdict['red'].extend(red)
> cdict['green'].extend(green)
> cdict['blue'].extend(blue)
>
> else: # all negative
> cdict={}
> cdict['red']=[]
> cdict['green']=[]
> cdict['blue']=[]
>
> ratio=1.0
>
> # negative part
> red=[(0.0, 0.0, 0.0),
> (ratio/2, 0.0, 0.0),
> (ratio, 1.0, 1.0)]
> green=[(0.0, 0.0, 0.0),
> (ratio/2, 0.5, 0.5),
> (ratio, 1.0, 1.0)]
> blue=[(0.0, 0.5, 0.5),
> (ratio/2, 1, 1),
> (ratio, 1.0, 1.0)]
>
> cdict['red'].extend(red)
> cdict['green'].extend(green)
> cdict['blue'].extend(blue)
>
> my_cmap =
> matplotlib.colors.LinearSegmentedColormap('my_colormap',cdict,N)
>
>
> return my_cmap
>
> if __name__=="__main__":
>
> a=randn(20,20)
> my_cmap=bluewhitered(a,256)
>
>
>
> clf()
> pcolor(a,cmap=my_cmap)
> colorbar()
>
>
>
>
>
>
>
> --
> Brian Blais
> bb...@br...
> http://web.bryant.edu/~bblais <http://web.bryant.edu/%7Ebblais>
> http://bblais.blogspot.com/
>
>
>
>
-- 
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
From: Ken D. <kp...@ve...> - 2010年03月27日 14:13:35
Hi,
thanks for the suggestion. They do have multiple versions but I checked 
that everything is using 2.5
regards,
Ken Dere
Rune V. Sjøen wrote:
> Hi,
> 
> Does the box have multiple python versions installed, and are you sure
> that apache is using the
> same version and/or site packages as when you run it from the command line
> ?
> 
> Regards,
> Rune V. Sjøen
> 
> On Fri, Mar 26, 2010 at 8:07 PM, Ken Dere
> <kp...@ve...> wrote:
> 
>> Hi,
>>
>> I am trying to import pylab into an application running under an Apache
>> wsgi
>> server. The error I get is that if it tries to import matplotlib.cbook.
>> The application can import numpy, scipy etc just fine.
>>
>> the error message is that matplotlib has no module cbook.
>>
>> I can import matplotlib OK but if a do a dir(matplolib) it does indeed
>> not include cbook.
>>
>> If I try to import pylab from the command line it works fine and
>> pylab.cbook
>> is found.
>>
>> Any suggestions would be appreciated.
>>
>>
>> K. Dere
>>
>>
>>
>> 
------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
-- 
K. Dere
From: Brian B. <bb...@br...> - 2010年03月27日 12:17:20
On Mar 27, 2010, at 1:13 , Ariel Rokem wrote:
> In particular, I am interested in using the plt.cm.RdYlBu_r 
> colormap. If the data has both negative and positive values, I want 
> 0 to map to the central value of this colormap (a pale whitish 
> yellow) and I want negative values to be in blue and positive 
> numbers to be in red.
not sure if this is what you want (I'd never heard of RdYlBu_r...I 
need to go read up!), but I've used a similar colormap with the code 
posted below. You might be able to modify it for your case.
		hope this helps!
			bb
from pylab import *
def bluewhitered(a,N=256):
 bottom = [0, 0, 0.5]
 botmiddle = [0, 0.5, 1]
 middle = [1, 1, 1]
 topmiddle = [1, 0, 0]
 top = [0.5, 0, 0]
 lims=[a.min(),a.max()]
 if lims[0]<0 and lims[1]>0:
 ratio=abs(lims[0])/(abs(lims[0])+lims[1])
 cdict={}
 cdict['red']=[]
 cdict['green']=[]
 cdict['blue']=[]
 # negative part
 red=[(0.0, 0.0, 0.0),
 (ratio/2, 0.0, 0.0),
 (ratio, 1.0, 1.0)]
 green=[(0.0, 0.0, 0.0),
 (ratio/2, 0.5, 0.5),
 (ratio, 1.0, 1.0)]
 blue=[(0.0, 0.5, 0.5),
 (ratio/2, 1, 1),
 (ratio, 1.0, 1.0)]
 cdict['red'].extend(red)
 cdict['green'].extend(green)
 cdict['blue'].extend(blue)
 nratio=1-(1-ratio)/2.0
 # positive part
 red=[(ratio, 1.0, 1.0),
 (nratio, 1.0, 1.0),
 (1, 0.5, 0.5)]
 green=[(ratio, 1.0, 1.0),
 (nratio, 0., 0.),
 (1, 0.0, 0.0)]
 blue=[(ratio, 1., 1.),
 (nratio, 0, 0),
 (1, 0, 0)]
 cdict['red'].extend(red)
 cdict['green'].extend(green)
 cdict['blue'].extend(blue)
 elif lims[0]>=0: # all positive
 cdict={}
 cdict['red']=[]
 cdict['green']=[]
 cdict['blue']=[]
 ratio=0.0
 nratio=0.5
 # positive part
 red=[(ratio, 1.0, 1.0),
 (nratio, 1.0, 1.0),
 (1, 0.5, 0.5)]
 green=[(ratio, 1.0, 1.0),
 (nratio, 0., 0.),
 (1, 0.0, 0.0)]
 blue=[(ratio, 1., 1.),
 (nratio, 0, 0),
 (1, 0, 0)]
 cdict['red'].extend(red)
 cdict['green'].extend(green)
 cdict['blue'].extend(blue)
 else: # all negative
 cdict={}
 cdict['red']=[]
 cdict['green']=[]
 cdict['blue']=[]
 ratio=1.0
 # negative part
 red=[(0.0, 0.0, 0.0),
 (ratio/2, 0.0, 0.0),
 (ratio, 1.0, 1.0)]
 green=[(0.0, 0.0, 0.0),
 (ratio/2, 0.5, 0.5),
 (ratio, 1.0, 1.0)]
 blue=[(0.0, 0.5, 0.5),
 (ratio/2, 1, 1),
 (ratio, 1.0, 1.0)]
 cdict['red'].extend(red)
 cdict['green'].extend(green)
 cdict['blue'].extend(blue)
 my_cmap = matplotlib.colors.LinearSegmentedColormap 
('my_colormap',cdict,N)
 return my_cmap
if __name__=="__main__":
 a=randn(20,20)
 my_cmap=bluewhitered(a,256)
 clf()
 pcolor(a,cmap=my_cmap)
 colorbar()
-- 
Brian Blais
bb...@br...
http://web.bryant.edu/~bblais
http://bblais.blogspot.com/
From: Ariel R. <ar...@be...> - 2010年03月27日 05:14:32
Hi everyone,
I am trying to make a color-map which will respond to the range of values in
the data itself. That is - I want to take one of the mpl colormaps and use
parts of it, depending on the range of the data.
In particular, I am interested in using the plt.cm.RdYlBu_r colormap. If the
data has both negative and positive values, I want 0 to map to the central
value of this colormap (a pale whitish yellow) and I want negative values to
be in blue and positive numbers to be in red. Also - I would want to use the
parts of the colormap that represent how far away the smallest and largest
values in the data are from 0. So - if my data is in the range [x1,x2] I
would want to use the part of the colormap in indices
127-127*abs(x1)/(x2-x1) through 127+127*x2/(x2-x1). If the data only
includes positive numbers, I would want to only use the blue part of the
colormap and if there are negative numbers, I would want to only use the red
part of the colormap (in these cases, I would also want to take only a
portion of the colormap which represents the size of the interval [x1,x2]
relative to the interval [0,x1] or [x2,0], as the case may be).
I think that this might be useful when comparing matrices generated from
different data, but with the same computation, such as correlation or
coherence (see http://nipy.sourceforge.net/nitime/examples/fmri.html to get
an idea of what I mean).
First of all - is this a good idea? Or in other words - is there any reason
I am not thinking of why this idea is a really bad idea?
Second - the technical questions. I think that I can make this happen by
using matplotlib.colors.LinearSegmentedColormap, after fiddling with the
values of the color-map a bit (as described above), but in order to do
that, I need to know what segmentdata was used in order to generate the
original colormap (for example, how many lines did each of the entries in
the cdict have? Looking at a plot of the cmap it looks like there must have
been 8 or 9 for RdYlBu_r, but I can't be sure). I could analyze it in more
detail to get that out empirically, but I am guessing that someone around
here might be able to spare me that lunacy (if not others...).
Thanks in advance,
Ariel
-- 
Ariel Rokem
Helen Wills Neuroscience Institute
University of California, Berkeley
http://argentum.ucbso.berkeley.edu/ariel
From: Brian G. <ell...@gm...> - 2010年03月27日 04:23:12
Greetings everyone,
This year, there will be two days of tutorials (June 28th and 29th) before the
main SciPy 2010 conference. Each of the two tutorial tracks (intro, advanced)
will have a 3-4 hour morning and afternoon session both days, for a total of 4
intro sessions and 4 advanced sessions.
The main tutorial web page for SciPy 2010 is here:
http://conference.scipy.org/scipy2010/tutorials.html
We are currently in the process of planning the tutorial sessions. You
can help us in two ways:
Brainstorm/vote on potential tutorial topics
============================================
To help us plan the tutorials, we have setup a web site that allow everyone in
the community to brainstorm and vote on tutorial ideas/topics.
The website for brainstorming/voting is here:
http://conference.scipy.org/scipy2010/tutorialsUV.html
The tutorial committee will use this information to help select the tutorials.
Please jump in and let us know what tutorial topics you would like to see.
Tutorial proposal submissions
=============================
We are now accepting tutorial proposals from individuals or teams that would
like to present a tutorial. Tutorials should be focused on covering a well
defined topic in a hands on manner. We want to see tutorial attendees coding!
We are pleased to offer tutorial presenters stipends this year for the first
time:
 * 1 Session: 1,000ドル (half day)
 * 2 Sessions: 1,500ドル (full day)
Optionally, part of this stipend can be applied to the presenter's
registration costs.
To submit a tutorial proposal please submit the following materials
to 201...@sc... by April 15:
* A short bio of the presenter or team members.
* Which track the tutorial would be in (intro or advanced).
* A short description and/or outline of the tutorial content.
* A list of Python packages that attendees will need to have installed to
 follow along.
From: Friedrich R. <fri...@gm...> - 2010年03月27日 00:23:43
2010年3月26日 timothee cezard <tc...@st...>:
> does it make sense to use something like
> plt.bar(bins, nb_per_bin, width=(max(bins)-min(bins)) / (1.5*len(bins)))
I think that should work, although you should use (max(bins) -
min(bins) / 1.5 / (len(bins) - 1), but I would suggest:
bounds = {some N + 1 array}
center = 0.5 * (bounds[1:] + bounds[:-1])
width = 0.9 * (bounds[1:] - bounds[:-1])
offset = 0.5 * width
plt.bar(center - offset, {some N array}, width = width)
but I haven't tested it. bar() does accept an iterable as *width* argument.
Friedrich

Showing 7 results of 7

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