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
|
2
(2) |
3
(16) |
4
(22) |
5
(7) |
6
|
7
(9) |
8
(2) |
9
|
10
(7) |
11
(15) |
12
(7) |
13
(4) |
14
(7) |
15
(3) |
16
(6) |
17
(20) |
18
(18) |
19
(15) |
20
(27) |
21
(14) |
22
|
23
(1) |
24
(18) |
25
(22) |
26
(36) |
27
(17) |
28
(6) |
29
(2) |
30
(3) |
31
(6) |
|
|
|
|
|
From: Oz N. <na...@gm...> - 2010-05-31 23:58:20
|
Hi, I wanted to be more clear: the numbers on my figure's color bar range from 0 to 1.7, but mpl writes the following numbers: 0.0000, 0.000250,0.000050,0.000750, etc. This is totally not somthing I can use, it looks horrible. I'm also attaching the image ... -- Oz Nahum Graduate Student Zentrum für Angewandte Geologie Universität Tübingen --- Imagine there's no countries it isn't hard to do Nothing to kill or die for And no religion too Imagine all the people Living life in peace |
From: Craig M. <mcq...@ed...> - 2010-05-31 23:54:12
|
Christoph Gohlke wrote: > > On 5/31/2010 1:53 AM, Craig McQueen wrote: >> I just installed matplotlib-0.99.3.win32-py2.6.exe on this Win2000 PC. >> When I try: >> from matplotlib import pyplot as plt >> >> it crashes Python with an apparent NULL-pointer reference. If I run >> python -v >> >> then it crashes just after: >> # c:\python26\lib\site-packages\matplotlib\transforms.pyc matches >> c:\python26\li >> b\site-packages\matplotlib\transforms.py >> import matplotlib.transforms # precompiled from >> c:\python26\lib\site-packages\ma >> tplotlib\transforms.pyc >> >> matplotlib-0.99.1.win32-py2.6.exe worked fine on this PC. >> >> Regards, >> Craig McQueen > > > I can not reproduce the crash in a Virtual Machine with Windows 2000 > SP4, Python 2.6.5, numpy 1.4.1, and matplotlib 0.99.3. > > Exactly which versions are you using, and how did you install Python > (for all users?). What is your CPU? > > matplotlib-0.99.3.win32-py2.6 was built against numpy 1.4.1, libpng > 1.4.2 and zlib 1.2.5, while matplotlib-0.99.1.win32-py2.6 was built > against numpy 1.3.0, libpng 1.2.3x, and zlib 1.2.3. > > Christoph > Ah--installing numpy 1.4.1 fixed the issue. I had numpy 1.3.0 installed before that. Thanks for such a helpful response. I wasn't aware that matplotlib is "built against" a particular version of numpy (not quite sure what that means either, unless numpy provides a direct C API as well as the Python API; please excuse my ignorance). (To answer your questions in case that's still useful somehow... I'm using Windows 2000 SP4, Python 2.6.5, on a Pentium 4 PC. I installed Python for all users.) Thanks and regards, Craig McQueen |
From: rugspin <pie...@we...> - 2010-05-31 23:49:35
|
I have a small problem how to convert an image from matplotlib to PIL right now doing somthing like this: ------------------------------------------ from scipy import * from pylab import * from PIL import Image a = arange(16384).reshape(128,128) imsave( "test.png", a, cmap=cm.summer,vmin=0,vmax=16383) b = Image.open("test.png" ) ------------------------------------------ so I have a 128x128 array, get a 128x128 size png by making use of a colormap and get a 128x128 size PIL image. But so far I could figure out a way to do this directly without writing a temporary png and reading it again, which is quite slow. My important point here is to keep the the pixel resolution. I would be glad about some help Regards Hans -- View this message in context: http://old.nabble.com/imshow%2C-imsave-to-PIL-image-conversion-tp28736246p28736246.html Sent from the matplotlib - users mailing list archive at Nabble.com. |
From: Oz N. <na...@gm...> - 2010-05-31 23:18:39
|
Hi Guys, I'm breaking my head how to use scientific numbering on color bar: I use the following code to plot data from multiple files, would be great if someone could direct me, becuase the numbers I have are 0.0013 et. and what ever I do, the number just go over each other: for i in xrange(len(data)): x,z,som=data[i]["x"],data[i]["z"],data[i]['ch2o'] som=som*MwSOM som=som*1000 x=N.unique(x) z=N.unique(z) p_w=N.unique(som) fig = plt.figure(len(data)+1+i) ax1 = fig.add_subplot(111) som=resize(som,(z.size,x.size)) v=N.arange(1.15,1.18,0.002) CS=contourf(x,z,som,cmap=cm.pink_r) cb=colorbar(CS, orientation='horizontal', shrink=1.0,aspect=33) ax1.set_title("SOM "+titles[i]) savefig('Fig'+str(i)+'.png') Thanks in advance ! -- Oz Nahum Graduate Student Zentrum für Angewandte Geologie Universität Tübingen --- Imagine there's no countries it isn't hard to do Nothing to kill or die for And no religion too Imagine all the people Living life in peace |
From: Christoph G. <cg...@uc...> - 2010-05-31 17:50:15
|
On 5/31/2010 1:53 AM, Craig McQueen wrote: > I just installed matplotlib-0.99.3.win32-py2.6.exe on this Win2000 PC. > When I try: > from matplotlib import pyplot as plt > > it crashes Python with an apparent NULL-pointer reference. If I run > python -v > > then it crashes just after: > # c:\python26\lib\site-packages\matplotlib\transforms.pyc matches > c:\python26\li > b\site-packages\matplotlib\transforms.py > import matplotlib.transforms # precompiled from > c:\python26\lib\site-packages\ma > tplotlib\transforms.pyc > > matplotlib-0.99.1.win32-py2.6.exe worked fine on this PC. > > Regards, > Craig McQueen I can not reproduce the crash in a Virtual Machine with Windows 2000 SP4, Python 2.6.5, numpy 1.4.1, and matplotlib 0.99.3. Exactly which versions are you using, and how did you install Python (for all users?). What is your CPU? matplotlib-0.99.3.win32-py2.6 was built against numpy 1.4.1, libpng 1.4.2 and zlib 1.2.5, while matplotlib-0.99.1.win32-py2.6 was built against numpy 1.3.0, libpng 1.2.3x, and zlib 1.2.3. Christoph |
From: Craig M. <mcq...@ed...> - 2010-05-31 09:10:57
|
I just installed matplotlib-0.99.3.win32-py2.6.exe on this Win2000 PC. When I try: from matplotlib import pyplot as plt it crashes Python with an apparent NULL-pointer reference. If I run python -v then it crashes just after: # c:\python26\lib\site-packages\matplotlib\transforms.pyc matches c:\python26\li b\site-packages\matplotlib\transforms.py import matplotlib.transforms # precompiled from c:\python26\lib\site-packages\ma tplotlib\transforms.pyc matplotlib-0.99.1.win32-py2.6.exe worked fine on this PC. Regards, Craig McQueen |
From: Christoph G. <cg...@uc...> - 2010-05-30 22:40:59
|
Hello, consider the following simple code: import matplotlib from matplotlib import pyplot pyplot.text(0, 0, " <--", family='monospace') pyplot.show() Using matplotlib-0.99.3.win32-py2.6, the text '<--' is drawn with an x-offset from the y-axis, as expected from the presence of leading whitespace. Using matplotlib-1.0.svn.win32-py2.6 rev 8347, the leading whitespace is apparently removed from the text and '<--' is drawn right at the y-axis with no x-offset. In both cases the font is monospace. Is this change intended or a regression in 1.0svn? Thank you. -- Christoph |
From: Alan G I. <ala...@gm...> - 2010-05-30 11:42:00
|
On 5/30/2010 6:42 AM, Florian Lindner wrote: > I want to plot a simple vector arrow with a specified starting point and end > point (or direction and length). > http://matplotlib.sourceforge.net/users/annotations_guide.html#annotating-with-arrow http://matplotlib.sourceforge.net/users/annotations.html hth, Alan Isaac |
From: Florian L. <mai...@xg...> - 2010-05-30 10:59:18
|
Hello, I want to plot a simple vector arrow with a specified starting point and end point (or direction and length). I've found http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.quiver but I don't see a way to set the length of the vector. Though discussions about this topic recommend quiver. Thanks, Florian |
From: Mark B. <ma...@gm...> - 2010-05-29 20:29:00
|
Hello List, Is there anybody who has tried to convert a Axes3D figure to U3D so it can be imbedded in a pdf file? It would be exceedingly cool. If anybody has code that can do this, that would be most excellent. If not, does anybody have any other thoughts on getting a 3D image in an interactive pdf file? Thanks, Mark |
From: Jouni K. S. <jk...@ik...> - 2010-05-29 19:27:02
|
alex arsenovic <ai...@vi...> writes: > the main error is > > Error: /nocurrentpoint in --lineto-- Sounds like this bug: http://sourceforge.net/tracker/index.php?func=detail&aid=2879910&group_id=80706&atid=560720 It's fixed in svn, but I don't think there has been a release after the fix. One way to test if it is indeed the same bug is to apply the following change (svn revision 7899) and try saving a pdf file - it should exit with an error. |
From: Eric F. <ef...@ha...> - 2010-05-28 20:57:35
|
On 05/28/2010 09:10 AM, Richard Ree wrote: > On Fri, May 28, 2010 at 12:02 PM, Eric Firing wrote: >> On 05/28/2010 06:31 AM, Richard Ree wrote: >>> To visualize trees, I'm creating Path objects that draw horizontal and >>> vertical lines between connected nodes. I make sure to end these >>> paths with a MOVETO code and the final vertex, and a STOP code and the >>> final vertex. But I consistently see an anomalous line segment >>> getting rendered, angling between two disconnected nodes. The problem >>> is intermittent - if I pan or zoom, the anomalous segment might go >>> away or change position. It's also consistent - if I create two plots >>> of the same tree structure, the anomalous segment appears in the same >>> way. I've tried different backends, all the same. The attached >>> screenshots illustrate the problem. In each case, a detail of the >>> tree is shown in the right pane. path-artefact.png shows the >>> anomalous segment angling across the view. Any ideas on why this >>> occurs? I'm using the latest matplotlib release. >> >> Does it still happen if you turn off path simplification? E.g. >> >> rcParams['path.simplify'] = False > > Yes, this seems to fix it. Thanks! > > -Rick Good. I think this is one of the path simplification problems that has already been fixed in svn by Mike D. If you can build from svn and try your program without turning path simplification off, then we could be sure. Eric |
From: Richard R. <rr...@fi...> - 2010-05-28 19:10:37
|
On Fri, May 28, 2010 at 12:02 PM, Eric Firing wrote: > On 05/28/2010 06:31 AM, Richard Ree wrote: >> To visualize trees, I'm creating Path objects that draw horizontal and >> vertical lines between connected nodes. I make sure to end these >> paths with a MOVETO code and the final vertex, and a STOP code and the >> final vertex. But I consistently see an anomalous line segment >> getting rendered, angling between two disconnected nodes. The problem >> is intermittent - if I pan or zoom, the anomalous segment might go >> away or change position. It's also consistent - if I create two plots >> of the same tree structure, the anomalous segment appears in the same >> way. I've tried different backends, all the same. The attached >> screenshots illustrate the problem. In each case, a detail of the >> tree is shown in the right pane. path-artefact.png shows the >> anomalous segment angling across the view. Any ideas on why this >> occurs? I'm using the latest matplotlib release. > > Does it still happen if you turn off path simplification? E.g. > > rcParams['path.simplify'] = False Yes, this seems to fix it. Thanks! -Rick > > Eric > >> >> Thanks >> -Rick >> >> >> >> ------------------------------------------------------------------------------ >> >> >> >> >> _______________________________________________ >> Matplotlib-users mailing list >> Mat...@li... >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > |
From: Eric F. <ef...@ha...> - 2010-05-28 17:03:07
|
On 05/28/2010 06:31 AM, Richard Ree wrote: > To visualize trees, I'm creating Path objects that draw horizontal and > vertical lines between connected nodes. I make sure to end these > paths with a MOVETO code and the final vertex, and a STOP code and the > final vertex. But I consistently see an anomalous line segment > getting rendered, angling between two disconnected nodes. The problem > is intermittent - if I pan or zoom, the anomalous segment might go > away or change position. It's also consistent - if I create two plots > of the same tree structure, the anomalous segment appears in the same > way. I've tried different backends, all the same. The attached > screenshots illustrate the problem. In each case, a detail of the > tree is shown in the right pane. path-artefact.png shows the > anomalous segment angling across the view. Any ideas on why this > occurs? I'm using the latest matplotlib release. Does it still happen if you turn off path simplification? E.g. rcParams['path.simplify'] = False Eric > > Thanks > -Rick > > > > ------------------------------------------------------------------------------ > > > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Richard R. <rr...@fi...> - 2010-05-28 16:54:03
|
To visualize trees, I'm creating Path objects that draw horizontal and vertical lines between connected nodes. I make sure to end these paths with a MOVETO code and the final vertex, and a STOP code and the final vertex. But I consistently see an anomalous line segment getting rendered, angling between two disconnected nodes. The problem is intermittent - if I pan or zoom, the anomalous segment might go away or change position. It's also consistent - if I create two plots of the same tree structure, the anomalous segment appears in the same way. I've tried different backends, all the same. The attached screenshots illustrate the problem. In each case, a detail of the tree is shown in the right pane. path-artefact.png shows the anomalous segment angling across the view. Any ideas on why this occurs? I'm using the latest matplotlib release. Thanks -Rick |
From: T J <tj...@gm...> - 2010-05-28 08:16:11
|
On Thu, May 27, 2010 at 5:44 PM, Eric Firing <ef...@ha...> wrote: > You can't do this via any manipulation of the colormap, or any fancier > colormap specification--instead, you have to manipulate the data value. For > example, you could identify the "over" values in your data, and then use 2-D > interpolation to replace them with the values you want. > > Basemap includes a 2-D interpolation routine: > > from mpl_toolkits.basemap import interp > Thanks! >> >> This is partially achieved with "white" (and I suppose I could pick >> "grey" or "black"), but I think it might be nicer if it were a pure >> mixture, rather than a mixture of the surrounding colors and the >> "over" color. >> >> The script is attached below. Sorry it is a bit long, but I needed a >> discrete colormap. Can we get cmap_discrete() into matplotlib? > > No, because it doesn't make much sense, given the mpl paradigm in which a > colormap and a norm work together. If you want 4 colors, make a colormap > with 4 colors, and use a norm that maps your data to those 4 colors. > > For example: > > cm4 = get_cmap('jet', 4) > cm4a = mpl.colors.ListedColormap(get_cmap('jet', 256)([20, 70, 150, 200])) > > You can select any discrete set of colors you want using ListedColormap. > > Then you can use the default Normalize, or a custom BoundaryNorm, to map > data ranges to the colors. You just don't need a lookup table with 1024 > entries to specify 4 colors--it doesn't gain you anything. > Wonderful. Definitely makes the cookbook entry seem unnecessary |
From: Eric F. <ef...@ha...> - 2010-05-28 00:44:22
|
On 05/27/2010 01:58 PM, T J wrote: > On Thu, May 27, 2010 at 3:23 PM, Eric Firing<ef...@ha...> wrote: >> >> I'm not sure I understand the problem; could you provide a tiny example >> to illustrate? >> > > Sure, let me focus just on the interpolation and I'll leave the > filtering issue out. > > In the script below, I plot a 3x3 array with the center element having > an "over" value. In the default case, because its value is over, the > colormap will assign it the maximum color. I also plot the case when > the "over" color is explicitly set to the minimum color and also to > white. What I want is this: > > The center element should be an equal mixture of the 4 elements around it. You can't do this via any manipulation of the colormap, or any fancier colormap specification--instead, you have to manipulate the data value. For example, you could identify the "over" values in your data, and then use 2-D interpolation to replace them with the values you want. Basemap includes a 2-D interpolation routine: from mpl_toolkits.basemap import interp > > This is partially achieved with "white" (and I suppose I could pick > "grey" or "black"), but I think it might be nicer if it were a pure > mixture, rather than a mixture of the surrounding colors and the > "over" color. > > The script is attached below. Sorry it is a bit long, but I needed a > discrete colormap. Can we get cmap_discrete() into matplotlib? No, because it doesn't make much sense, given the mpl paradigm in which a colormap and a norm work together. If you want 4 colors, make a colormap with 4 colors, and use a norm that maps your data to those 4 colors. For example: cm4 = get_cmap('jet', 4) cm4a = mpl.colors.ListedColormap(get_cmap('jet', 256)([20, 70, 150, 200])) You can select any discrete set of colors you want using ListedColormap. Then you can use the default Normalize, or a custom BoundaryNorm, to map data ranges to the colors. You just don't need a lookup table with 1024 entries to specify 4 colors--it doesn't gain you anything. Eric > > ------------------ > > import matplotlib.pyplot as plt > import matplotlib.colors > > import numpy as np > from scipy import interpolate > > #### http://www.scipy.org/Cookbook/Matplotlib/ColormapTransformations > #### Can this be added to matplotlib? > def cmap_discretize(cmap, N): > """Return a discrete colormap from the continuous colormap cmap. > > cmap: colormap instance, eg. cm.jet. > N: Number of colors. > > Example > x = resize(arange(100), (5,100)) > djet = cmap_discretize(cm.jet, 5) > imshow(x, cmap=djet) > """ > > cdict = cmap._segmentdata.copy() > # N colors > colors_i = np.linspace(0,1.,N) > # N+1 indices > indices = np.linspace(0,1.,N+1) > for key in ('red','green','blue'): > # Find the N colors > D = np.array(cdict[key]) > I = interpolate.interp1d(D[:,0], D[:,1]) > colors = I(colors_i) > # Place these colors at the correct indices. > A = np.zeros((N+1,3), float) > A[:,0] = indices > A[1:,1] = colors > A[:-1,2] = colors > # Create a tuple for the dictionary. > L = [] > for l in A: > L.append(tuple(l)) > cdict[key] = tuple(L) > # Return colormap object. > return matplotlib.colors.LinearSegmentedColormap('colormap',cdict,1024) > > def draw(m, cm, norm, ncolors): > ax = plt.gca() > ai = ax.imshow(m, cmap=cm, norm=norm, interpolation='gaussian') > cb = ax.figure.colorbar(ai) > cb.set_ticks(np.linspace(.5, ncolors-.5, ncolors)) > cb.set_ticklabels(['$%s$' % (i,) for i in np.arange(ncolors)]) > return ai, cb > > if __name__ == '__main__': > ncolors = 4 > norm = plt.Normalize(vmax=ncolors) > m = np.array([[0, 0, 1], > [3, 10, 1], > [3, 2, 2]]) > > for over in [None, 'min', (1,1,1,1)]: > f = plt.figure() > cm = cmap_discretize(plt.cm.jet, ncolors) > if over == 'min': > cm.set_over(cm(0.0)) > elif over is not None: > cm.set_over(over) > ai, cb = draw(m, cm, norm, ncolors) > > plt.show() |
From: T J <tj...@gm...> - 2010-05-27 23:58:40
|
On Thu, May 27, 2010 at 3:23 PM, Eric Firing <ef...@ha...> wrote: > > I'm not sure I understand the problem; could you provide a tiny example > to illustrate? > Sure, let me focus just on the interpolation and I'll leave the filtering issue out. In the script below, I plot a 3x3 array with the center element having an "over" value. In the default case, because its value is over, the colormap will assign it the maximum color. I also plot the case when the "over" color is explicitly set to the minimum color and also to white. What I want is this: The center element should be an equal mixture of the 4 elements around it. This is partially achieved with "white" (and I suppose I could pick "grey" or "black"), but I think it might be nicer if it were a pure mixture, rather than a mixture of the surrounding colors and the "over" color. The script is attached below. Sorry it is a bit long, but I needed a discrete colormap. Can we get cmap_discrete() into matplotlib? ------------------ import matplotlib.pyplot as plt import matplotlib.colors import numpy as np from scipy import interpolate #### http://www.scipy.org/Cookbook/Matplotlib/ColormapTransformations #### Can this be added to matplotlib? def cmap_discretize(cmap, N): """Return a discrete colormap from the continuous colormap cmap. cmap: colormap instance, eg. cm.jet. N: Number of colors. Example x = resize(arange(100), (5,100)) djet = cmap_discretize(cm.jet, 5) imshow(x, cmap=djet) """ cdict = cmap._segmentdata.copy() # N colors colors_i = np.linspace(0,1.,N) # N+1 indices indices = np.linspace(0,1.,N+1) for key in ('red','green','blue'): # Find the N colors D = np.array(cdict[key]) I = interpolate.interp1d(D[:,0], D[:,1]) colors = I(colors_i) # Place these colors at the correct indices. A = np.zeros((N+1,3), float) A[:,0] = indices A[1:,1] = colors A[:-1,2] = colors # Create a tuple for the dictionary. L = [] for l in A: L.append(tuple(l)) cdict[key] = tuple(L) # Return colormap object. return matplotlib.colors.LinearSegmentedColormap('colormap',cdict,1024) def draw(m, cm, norm, ncolors): ax = plt.gca() ai = ax.imshow(m, cmap=cm, norm=norm, interpolation='gaussian') cb = ax.figure.colorbar(ai) cb.set_ticks(np.linspace(.5, ncolors-.5, ncolors)) cb.set_ticklabels(['$%s$' % (i,) for i in np.arange(ncolors)]) return ai, cb if __name__ == '__main__': ncolors = 4 norm = plt.Normalize(vmax=ncolors) m = np.array([[0, 0, 1], [3, 10, 1], [3, 2, 2]]) for over in [None, 'min', (1,1,1,1)]: f = plt.figure() cm = cmap_discretize(plt.cm.jet, ncolors) if over == 'min': cm.set_over(cm(0.0)) elif over is not None: cm.set_over(over) ai, cb = draw(m, cm, norm, ncolors) plt.show() |
From: Eric F. <ef...@ha...> - 2010-05-27 22:24:00
|
On 05/27/2010 09:32 AM, T J wrote: > Hi, > > I am plotting with imshow() and interpolation is turned on > ('gaussian'). Part of my issue is that the distribution of values is > such that I need to set the over/under colors to grab the most > relevant values. If I set the over color to be the "maximum" color, > then the result is too dark. Conversely for the under color. I can > set the over/under colors to not draw, but then I have "holes" in my > image. Is it possible to incorporate interpolation? That is, I would > like to set my over color to be interpolated among its neighboring > cells. This seems like it would require an (more) "intelligent" > colormap, so my guess is that this isn't currently supported. I'm > growing more comfortable with the mpl internals and might give a stab > at implementing this, but I'm not quite sure where to start. > > Thanks in advance. I'm not sure I understand the problem; could you provide a tiny example to illustrate? Eric |
From: Eric F. <ef...@ha...> - 2010-05-27 22:18:16
|
On 05/27/2010 09:08 AM, Adam Fraser wrote: > Thanks very much, > > I'm getting ValueError: argument must be "box", or "datalim" at > set_adjustable... > > I'm using Matplotlib version 0.98.5.3, do I need to update? > Yes. Unfortunately, you will need to build from svn. JJ added box-forced in January, and we have not had a release since then. Eric > > On Thu, May 27, 2010 at 2:59 PM, Jae-Joon Lee <lee...@gm... > <mailto:lee...@gm...>> wrote: > > ax1 = subplot(121) > ax2 = subplot(122, sharex=ax1, sharey=ax1) > > ax1.set_adjustable("box-forced") > ax2.set_adjustable("box-forced") > > arr1 = np.arange(100).reshape((10, 10)) > ax1.imshow(arr1) > > arr2 = np.arange(100, 0, -1).reshape((10, 10)) > ax2.imshow(arr2) > > Note the use of set_adjustable("box-forced"). > sharex and sharey does not get along with axes of aspect=1 & > adjustable="box". > > -JJ |
From: Adam F. <ada...@gm...> - 2010-05-27 20:05:49
|
Thanks very much, I'm getting ValueError: argument must be "box", or "datalim" at set_adjustable... I'm using Matplotlib version 0.98.5.3, do I need to update? On Thu, May 27, 2010 at 2:59 PM, Jae-Joon Lee <lee...@gm...> wrote: > ax1 = subplot(121) > ax2 = subplot(122, sharex=ax1, sharey=ax1) > > ax1.set_adjustable("box-forced") > ax2.set_adjustable("box-forced") > > arr1 = np.arange(100).reshape((10, 10)) > ax1.imshow(arr1) > > arr2 = np.arange(100, 0, -1).reshape((10, 10)) > ax2.imshow(arr2) > > Note the use of set_adjustable("box-forced"). > sharex and sharey does not get along with axes of aspect=1 & > adjustable="box". > > -JJ > > > > On Thu, May 27, 2010 at 2:10 PM, <PH...@ge...> wrote: > > Do the “sharex” and “sharey” kwargs help? > > > > > http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axes > > > > > http://matplotlib.sourceforge.net/examples/pylab_examples/shared_axis_demo.html > > > > -paul > > > > > > > > From: Adam Fraser [mailto:ada...@gm...] > > Sent: Thursday, May 27, 2010 10:44 AM > > To: matplotlib-users > > Subject: [Matplotlib-users] Is there a way to link axes of imshow plots? > > > > > > > > Suppose I have a figure canvas with 3 plots... 2 are images of the same > > dimensions plotted with imshow, and the other is a scatterplot. I'd like > to > > be able to link the x and y axes of the imshow plots so that when I zoom > in > > one, the other zooms to the same coordinates, and when I pan in one, the > > other pans as well. > > > > > > > > I started hacking my way around this by > subclassing NavigationToolbar2WxAgg > > (shown below)... but there are several problems here. > > > > 1) This will link the axes of all plots in a canvas since all I've done > is > > get rid of the checks for a.in_axes() > > > > 2) This worked well for panning, but zooming caused all subplots to zoom > > from the same global point, rather than from the same point in each of > their > > respective axes. > > > > > > > > Can anyone suggest a workaround? > > > > > > > > Much thanks! > > > > -Adam > > > > > > > > from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as > > NavigationToolbar > > > > class MyNavToolbar(NavigationToolbar): > > > > def __init__(self, canvas, cpfig): > > > > NavigationToolbar.__init__(self, canvas) > > > > > > > > # override > > > > def press_pan(self, event): > > > > 'the press mouse button in pan/zoom mode callback' > > > > > > > > if event.button == 1: > > > > self._button_pressed=1 > > > > elif event.button == 3: > > > > self._button_pressed=3 > > > > else: > > > > self._button_pressed=None > > > > return > > > > > > > > x, y = event.x, event.y > > > > > > > > # push the current view to define home if stack is empty > > > > if self._views.empty(): self.push_current() > > > > > > > > self._xypress=[] > > > > for i, a in enumerate(self.canvas.figure.get_axes()): > > > > # only difference from overridden method is that this one > > doesn't > > > > # check a.in_axes(event) > > > > if x is not None and y is not None and a.get_navigate(): > > > > a.start_pan(x, y, event.button) > > > > self._xypress.append((a, i)) > > > > self.canvas.mpl_disconnect(self._idDrag) > > > > > self._idDrag=self.canvas.mpl_connect('motion_notify_event', > > self.drag_pan) > > > > > > > > def press_zoom(self, event): > > > > 'the press mouse button in zoom to rect mode callback' > > > > if event.button == 1: > > > > self._button_pressed=1 > > > > elif event.button == 3: > > > > self._button_pressed=3 > > > > else: > > > > self._button_pressed=None > > > > return > > > > > > > > x, y = event.x, event.y > > > > > > > > # push the current view to define home if stack is empty > > > > if self._views.empty(): self.push_current() > > > > > > > > self._xypress=[] > > > > for i, a in enumerate(self.canvas.figure.get_axes()): > > > > # only difference from overridden method is that this one > > doesn't > > > > # check a.in_axes(event) > > > > if x is not None and y is not None and a.get_navigate() and > > a.can_zoom(): > > > > self._xypress.append(( x, y, a, i, a.viewLim.frozen(), > > a.transData.frozen())) > > > > > > > > self.press(event) > > > > > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > > > > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > > > > |
From: T J <tj...@gm...> - 2010-05-27 19:32:57
|
Hi, I am plotting with imshow() and interpolation is turned on ('gaussian'). Part of my issue is that the distribution of values is such that I need to set the over/under colors to grab the most relevant values. If I set the over color to be the "maximum" color, then the result is too dark. Conversely for the under color. I can set the over/under colors to not draw, but then I have "holes" in my image. Is it possible to incorporate interpolation? That is, I would like to set my over color to be interpolated among its neighboring cells. This seems like it would require an (more) "intelligent" colormap, so my guess is that this isn't currently supported. I'm growing more comfortable with the mpl internals and might give a stab at implementing this, but I'm not quite sure where to start. Thanks in advance. |
From: Jae-Joon L. <lee...@gm...> - 2010-05-27 18:59:42
|
ax1 = subplot(121) ax2 = subplot(122, sharex=ax1, sharey=ax1) ax1.set_adjustable("box-forced") ax2.set_adjustable("box-forced") arr1 = np.arange(100).reshape((10, 10)) ax1.imshow(arr1) arr2 = np.arange(100, 0, -1).reshape((10, 10)) ax2.imshow(arr2) Note the use of set_adjustable("box-forced"). sharex and sharey does not get along with axes of aspect=1 & adjustable="box". -JJ On Thu, May 27, 2010 at 2:10 PM, <PH...@ge...> wrote: > Do the “sharex” and “sharey” kwargs help? > > http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axes > > http://matplotlib.sourceforge.net/examples/pylab_examples/shared_axis_demo.html > > -paul > > > > From: Adam Fraser [mailto:ada...@gm...] > Sent: Thursday, May 27, 2010 10:44 AM > To: matplotlib-users > Subject: [Matplotlib-users] Is there a way to link axes of imshow plots? > > > > Suppose I have a figure canvas with 3 plots... 2 are images of the same > dimensions plotted with imshow, and the other is a scatterplot. I'd like to > be able to link the x and y axes of the imshow plots so that when I zoom in > one, the other zooms to the same coordinates, and when I pan in one, the > other pans as well. > > > > I started hacking my way around this by subclassing NavigationToolbar2WxAgg > (shown below)... but there are several problems here. > > 1) This will link the axes of all plots in a canvas since all I've done is > get rid of the checks for a.in_axes() > > 2) This worked well for panning, but zooming caused all subplots to zoom > from the same global point, rather than from the same point in each of their > respective axes. > > > > Can anyone suggest a workaround? > > > > Much thanks! > > -Adam > > > > from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as > NavigationToolbar > > class MyNavToolbar(NavigationToolbar): > > def __init__(self, canvas, cpfig): > > NavigationToolbar.__init__(self, canvas) > > > > # override > > def press_pan(self, event): > > 'the press mouse button in pan/zoom mode callback' > > > > if event.button == 1: > > self._button_pressed=1 > > elif event.button == 3: > > self._button_pressed=3 > > else: > > self._button_pressed=None > > return > > > > x, y = event.x, event.y > > > > # push the current view to define home if stack is empty > > if self._views.empty(): self.push_current() > > > > self._xypress=[] > > for i, a in enumerate(self.canvas.figure.get_axes()): > > # only difference from overridden method is that this one > doesn't > > # check a.in_axes(event) > > if x is not None and y is not None and a.get_navigate(): > > a.start_pan(x, y, event.button) > > self._xypress.append((a, i)) > > self.canvas.mpl_disconnect(self._idDrag) > > self._idDrag=self.canvas.mpl_connect('motion_notify_event', > self.drag_pan) > > > > def press_zoom(self, event): > > 'the press mouse button in zoom to rect mode callback' > > if event.button == 1: > > self._button_pressed=1 > > elif event.button == 3: > > self._button_pressed=3 > > else: > > self._button_pressed=None > > return > > > > x, y = event.x, event.y > > > > # push the current view to define home if stack is empty > > if self._views.empty(): self.push_current() > > > > self._xypress=[] > > for i, a in enumerate(self.canvas.figure.get_axes()): > > # only difference from overridden method is that this one > doesn't > > # check a.in_axes(event) > > if x is not None and y is not None and a.get_navigate() and > a.can_zoom(): > > self._xypress.append(( x, y, a, i, a.viewLim.frozen(), > a.transData.frozen())) > > > > self.press(event) > > > > > > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > |
From: <PH...@Ge...> - 2010-05-27 18:11:22
|
Do the "sharex" and "sharey" kwargs help? http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axes http://matplotlib.sourceforge.net/examples/pylab_examples/shared_axis_demo.html -paul From: Adam Fraser [mailto:ada...@gm...] Sent: Thursday, May 27, 2010 10:44 AM To: matplotlib-users Subject: [Matplotlib-users] Is there a way to link axes of imshow plots? Suppose I have a figure canvas with 3 plots... 2 are images of the same dimensions plotted with imshow, and the other is a scatterplot. I'd like to be able to link the x and y axes of the imshow plots so that when I zoom in one, the other zooms to the same coordinates, and when I pan in one, the other pans as well. I started hacking my way around this by subclassing NavigationToolbar2WxAgg (shown below)... but there are several problems here. 1) This will link the axes of all plots in a canvas since all I've done is get rid of the checks for a.in_axes() 2) This worked well for panning, but zooming caused all subplots to zoom from the same global point, rather than from the same point in each of their respective axes. Can anyone suggest a workaround? Much thanks! -Adam from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar class MyNavToolbar(NavigationToolbar): def __init__(self, canvas, cpfig): NavigationToolbar.__init__(self, canvas) # override def press_pan(self, event): 'the press mouse button in pan/zoom mode callback' if event.button == 1: self._button_pressed=1 elif event.button == 3: self._button_pressed=3 else: self._button_pressed=None return x, y = event.x, event.y # push the current view to define home if stack is empty if self._views.empty(): self.push_current() self._xypress=[] for i, a in enumerate(self.canvas.figure.get_axes()): # only difference from overridden method is that this one doesn't # check a.in_axes(event) if x is not None and y is not None and a.get_navigate(): a.start_pan(x, y, event.button) self._xypress.append((a, i)) self.canvas.mpl_disconnect(self._idDrag) self._idDrag=self.canvas.mpl_connect('motion_notify_event', self.drag_pan) def press_zoom(self, event): 'the press mouse button in zoom to rect mode callback' if event.button == 1: self._button_pressed=1 elif event.button == 3: self._button_pressed=3 else: self._button_pressed=None return x, y = event.x, event.y # push the current view to define home if stack is empty if self._views.empty(): self.push_current() self._xypress=[] for i, a in enumerate(self.canvas.figure.get_axes()): # only difference from overridden method is that this one doesn't # check a.in_axes(event) if x is not None and y is not None and a.get_navigate() and a.can_zoom(): self._xypress.append(( x, y, a, i, a.viewLim.frozen(), a.transData.frozen())) self.press(event) |
From: Adam F. <ada...@gm...> - 2010-05-27 17:44:50
|
Suppose I have a figure canvas with 3 plots... 2 are images of the same dimensions plotted with imshow, and the other is a scatterplot. I'd like to be able to link the x and y axes of the imshow plots so that when I zoom in one, the other zooms to the same coordinates, and when I pan in one, the other pans as well. I started hacking my way around this by subclassing NavigationToolbar2WxAgg (shown below)... but there are several problems here. 1) This will link the axes of all plots in a canvas since all I've done is get rid of the checks for a.in_axes() 2) This worked well for panning, but zooming caused all subplots to zoom from the same global point, rather than from the same point in each of their respective axes. Can anyone suggest a workaround? Much thanks! -Adam from matplotlib.backends.backend_wxagg import NavigationToolbar2WxAgg as NavigationToolbar class MyNavToolbar(NavigationToolbar): def __init__(self, canvas, cpfig): NavigationToolbar.__init__(self, canvas) # override def press_pan(self, event): 'the press mouse button in pan/zoom mode callback' if event.button == 1: self._button_pressed=1 elif event.button == 3: self._button_pressed=3 else: self._button_pressed=None return x, y = event.x, event.y # push the current view to define home if stack is empty if self._views.empty(): self.push_current() self._xypress=[] for i, a in enumerate(self.canvas.figure.get_axes()): *# only difference from overridden method is that this one doesn't* * # check a.in_axes(event) * if x is not None and y is not None and a.get_navigate(): a.start_pan(x, y, event.button) self._xypress.append((a, i)) self.canvas.mpl_disconnect(self._idDrag) self._idDrag=self.canvas.mpl_connect('motion_notify_event', self.drag_pan) def press_zoom(self, event): 'the press mouse button in zoom to rect mode callback' if event.button == 1: self._button_pressed=1 elif event.button == 3: self._button_pressed=3 else: self._button_pressed=None return x, y = event.x, event.y # push the current view to define home if stack is empty if self._views.empty(): self.push_current() self._xypress=[] for i, a in enumerate(self.canvas.figure.get_axes()): *# only difference from overridden method is that this one doesn't* * # check a.in_axes(event) * if x is not None and y is not None and a.get_navigate() and a.can_zoom(): self._xypress.append(( x, y, a, i, a.viewLim.frozen(), a.transData.frozen())) self.press(event) |