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) |
|
|
|
On Tue, Mar 30, 2010 at 3:17 PM, Ryan May <rm...@gm...> wrote: > > According to the docstring, it only puts ticks in both locations, not > labels, which is what I'm seeing here on SVN with the PyGTK backend. > > Are you seeing something different? > > Yes, same here. It is just a bit unexpected ax.xaxis.set_ticks_position('top') puts labels as well but 'both' works only for ticks. It would be nice in some instances to have tick-labels appear on bottom and top with this easy way one-line way. -- Gökhan
On Tue, Mar 30, 2010 at 3:51 PM, Rachel-Mikel Arce Jaeger <Rac...@hm...> wrote: > Ryan's code works great - thanks! > > The only problem I have is that show() never terminates? If I force terminate it and close the figure, then all I ever have to do is call draw() and the figure reappears, but I have to call show() at least once, or else the figure will never appear. I don't want my program to create a figure until I absolutely have to, but I want to avoid non-termination and force-termination as well. Is there a way to do that? You really should only call show() once (because it starts the event loops for the user interface), usually at the end of your script, which will bring up all of the figures. The script will then exit when you close all of the figures. If you're doing interactive work, you probably want to look into something like ipython (http://ipython.scipy.org/moin/) which makes working with plots interactively a breeze. Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
Ryan's code works great - thanks! The only problem I have is that show() never terminates? If I force terminate it and close the figure, then all I ever have to do is call draw() and the figure reappears, but I have to call show() at least once, or else the figure will never appear. I don't want my program to create a figure until I absolutely have to, but I want to avoid non-termination and force-termination as well. Is there a way to do that? ~Rachel ----- Original Message ----- From: "Ryan May" <rm...@gm...> To: "Gökhan Sever" <gok...@gm...> Cc: "Rachel-Mikel_ArceJaeger" <Rac...@hm...>, "matplotlib-users" <mat...@li...> Sent: Tuesday, March 30, 2010 1:17:34 PM GMT -08:00 US/Canada Pacific Subject: Re: [Matplotlib-users] Shifting the Origin On Tue, Mar 30, 2010 at 2:10 PM, Gökhan Sever <gok...@gm...> wrote: > On Tue, Mar 30, 2010 at 2:37 PM, Ryan May <rm...@gm...> wrote: >> You're looking for the set_ticks_position method on the xaxis (I've >> also tweaked setting the limits): >> >> plt.plot(xcoords, ycoords, 'ro') >> plt.xlim(0, maxX) >> plt.ylim(maxY, 0) >> ax = plt.gca() # Get current axes object >> ax.xaxis.set_ticks_position('top') >> plt.show() > > This is easier :) > > Could you get this one working ? > > ax.xaxis.set_ticks_position('both') > > It doesn't have an effect here on Qt4Agg using svn copy of matplotlib. According to the docstring, it only puts ticks in both locations, not labels, which is what I'm seeing here on SVN with the PyGTK backend. Are you seeing something different? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
2010年3月30日 Chloe Lewis <ch...@be...>: > But this example doesn't solve the problem I was thinking of: it shows lots > of colors in the colorbar that aren't used in the plot. I'm so stupid! Here is the correct code. I just interchanged "-bounds, bound" with "min_val, max_val" on line 28. The only thing I didn't fix was to exclude the 0.00 from the ticks, but this Ariel already did, so I leave it now like it is. Friedrich
2010年3月30日 Filipe Pires Alvarenga Fernandes <oc...@gm...>: > However, my knowledge of python is very limited, even though I think I > understood what you suggested I do not know how to get the shape (of > the figure?) for this part: > >>>> fig.set_size_inches(float(shape[0]) / dpi, float(shape[1]) / dpi) > > error is: > > Traceback (most recent call last): > File "blueearth-map.py", line 108, in <module> > fig.set_size_inches(float(shape[0]) / dpi, float(shape[1]) / dpi) > TypeError: 'function' object is unsubscriptable > > It seems that it ended up calling a function shape instead of a variable shape. You're completely right, I assumed that you fill in some 2-element vector in *shape*, it was intended as an /argument/. The function attemted to be indexed is imported from numpy by matplotlib.pyplot: There is a code line "from numpy import *". So, simply put some line somewhere like: shape = [500, 500] . You have to set or have to calculate the figure's shape in pixels somewhere, because you need it to convert the rgb string back into a PIL image. It's not that nice, I know, for your problem? Friedrich
On Tue, Mar 30, 2010 at 2:10 PM, Gökhan Sever <gok...@gm...> wrote: > On Tue, Mar 30, 2010 at 2:37 PM, Ryan May <rm...@gm...> wrote: >> You're looking for the set_ticks_position method on the xaxis (I've >> also tweaked setting the limits): >> >> plt.plot(xcoords, ycoords, 'ro') >> plt.xlim(0, maxX) >> plt.ylim(maxY, 0) >> ax = plt.gca() # Get current axes object >> ax.xaxis.set_ticks_position('top') >> plt.show() > > This is easier :) > > Could you get this one working ? > > ax.xaxis.set_ticks_position('both') > > It doesn't have an effect here on Qt4Agg using svn copy of matplotlib. According to the docstring, it only puts ticks in both locations, not labels, which is what I'm seeing here on SVN with the PyGTK backend. Are you seeing something different? Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
On Tue, Mar 30, 2010 at 2:37 PM, Ryan May <rm...@gm...> wrote: > You're looking for the set_ticks_position method on the xaxis (I've > also tweaked setting the limits): > > plt.plot(xcoords, ycoords, 'ro') > plt.xlim(0, maxX) > plt.ylim(maxY, 0) > ax = plt.gca() # Get current axes object > ax.xaxis.set_ticks_position('top') > plt.show() > > Ryan > > This is easier :) Could you get this one working ? ax.xaxis.set_ticks_position('both') It doesn't have an effect here on Qt4Agg using svn copy of matplotlib. -- Gökhan
On Tue, Mar 30, 2010 at 11:12 AM, Julien <ju_...@ya...> wrote: > This script should give you a srange historamme, with bins that are half > the size they shoud be. > I'm sorry but it is not clear what is wrong. The histogram looks just fine to me. Maybe you wanted to do plt.hist(sorted(liste_histo),bins=range(31)) ? -JJ
On Tue, Mar 30, 2010 at 2:56 PM, Eric Firing <ef...@ha...> wrote: > Is even that worth the potential extra complexity, both in the code and in > the documentation? What is the real benefit? > I think there are some benefit of moving artists to another axes. Also this will help enabling moving an axes to another figure. http://www.mail-archive.com/mat...@li.../msg13544.html Anyhow, given that I don't know how the implementation will make things more complicated. I don't think i'm in a good position to discuss whether it is worth while to do. While (as I said) I'm not very kin to implementing this feature, I'll discuss this issue with you and others when I have more idea (or actual code) in the future. Regards, -JJ
2010年3月29日 Rachel-Mikel_ArceJaeger <Rac...@hm...>: > Hello, > > This is my first time trying out this list, so please forgive me if I've doing this wrong. > > I'm trying to create a plot that has its origin in the upper-left hand corner, rather than the lower-left hand corner. I've discovered that I get the same effect if I do: > > plt.plot( xcoords, ycoords, 'ro' ) > plt.axis( [0, maxX, maxY, 0] ) You're looking for the set_ticks_position method on the xaxis (I've also tweaked setting the limits): plt.plot(xcoords, ycoords, 'ro') plt.xlim(0, maxX) plt.ylim(maxY, 0) ax = plt.gca() # Get current axes object ax.xaxis.set_ticks_position('top') plt.show() Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
On Mon, Mar 29, 2010 at 10:20 PM, <Rac...@hm...> wrote: > Hello, > > This is my first time trying out this list, so please forgive me if I've > doing this wrong. > > I'm trying to create a plot that has its origin in the upper-left hand > corner, rather than the lower-left hand corner. I've discovered that I get > the same effect if I do: > > plt.plot( xcoords, ycoords, 'ro' ) > plt.axis( [0, maxX, maxY, 0] ) > > However, the x-axis still appears on the bottom of the graph rather than > the top. > > Is there a way that I can shift the location of the origin more easily, or > at least shift where the axis is written at? > > Thanks! > Spines should do the trick. Take a look at: http://matplotlib.sourceforge.net/examples/pylab_examples/spine_placement_demo.html#pylab-examples-spine-placement-demo -- Gökhan
On Tue, Mar 30, 2010 at 11:15 AM, Chloe Lewis <ch...@be...> wrote: > But this example doesn't solve the problem I was thinking of: it shows > lots of colors in the colorbar that aren't used in the plot. Here's a patch (and example) that I've cooked up that adds a colorbar.set_limits() method. It works pretty well, but there's still one issue to be sorted out: Setting the data limits distorts the aspect ratio. I haven't quite figured out how best to make it so that the aspect ratio is handled based on the size in axes coordinates and not based on the data range (or rather, data aspect ratio). (I'd love to hear any ideas the other devs have.) Ryan -- Ryan May Graduate Research Assistant School of Meteorology University of Oklahoma
Jae-Joon Lee wrote: > Doing this in a general way is quite difficult (if possible) because a > user can set an arbitrary transform for an artist. What we may try to > do is recycling artists whose transform is simple, e.g., transData, > rather than try to come up with a general solution. Is even that worth the potential extra complexity, both in the code and in the documentation? What is the real benefit? Eric > > I'll see what I can do but I must admit that I'm not very kin to this > kind of feature and it may take a while. I recommend you to open a new > ticket in the feature requests tracker hoping that other developers > or contributors can take a look. > > http://sourceforge.net/tracker/?atid=560723&group_id=80706&func=browse > > Regards, > > -JJ > > > > On Mon, Mar 29, 2010 at 1:54 PM, Thomas Robitaille > <tho...@gm...> wrote: >> Hi Jae-Joon, >> >> Thanks for your quick reply! Since for example LineCollections can be created independent of the Axes in which they are going to be plotted through the creation of a LineCollection instance, would it not be possible to have a method that allows one to retrieve an Axes-independent LineCollection from an Axes instance? (for example a get_collection method) This would then allow one to 'recycle' existing collections. >> >> Cheers, >> >> Thomas >> >> On Mar 29, 2010, at 1:40 PM, Jae-Joon Lee wrote: >> >>> As far as I can say, moving around artists from one axes to the other >>> is NOT recommended. And I encourage you to create separate artists for >>> each axes rather than try to reuse the existing ones. >>> >>> For your particular example, >>> >>> fig = mpl.figure() >>> ax2 = fig.add_subplot(1,1,1) >>> for c in ax1.collections: >>> c._transOffset=ax2.transData >>> ax2.add_collection(c) >>> >>> should work. >>> >>> Regards, >>> >>> -JJ >>> >>> >>> >>> >>> On Mon, Mar 29, 2010 at 12:24 PM, Thomas Robitaille >>> <tho...@gm...> wrote: >>>> Hello, >>>> >>>> In the following example, I am trying to copy over existing collections from one plot to another: >>>> >>>> import matplotlib.pyplot as mpl >>>> >>>> fig = mpl.figure() >>>> ax1 = fig.add_subplot(1,1,1) >>>> ax1.scatter([0.5],[0.5]) >>>> fig.savefig('test1.png') >>>> >>>> fig = mpl.figure() >>>> ax2 = fig.add_subplot(1,1,1) >>>> for c in ax1.collections: >>>> ax2.add_collection(c) >>>> fig.savefig('test2.png') >>>> >>>> However, the circle appears in the wrong place in test2.png (close to 0.4, 0.4 instead of 0.5,0.5). Is it not possible/safe to copy over collections in this way? If not, then how should this be done? >>>> >>>> Thanks, >>>> >>>> Thomas >>>> ------------------------------------------------------------------------------ >>>> Download Intel® 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 >>>> >> >> ------------------------------------------------------------------------------ >> Download Intel® 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 >> > > ------------------------------------------------------------------------------ > Download Intel® 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
Doing this in a general way is quite difficult (if possible) because a user can set an arbitrary transform for an artist. What we may try to do is recycling artists whose transform is simple, e.g., transData, rather than try to come up with a general solution. I'll see what I can do but I must admit that I'm not very kin to this kind of feature and it may take a while. I recommend you to open a new ticket in the feature requests tracker hoping that other developers or contributors can take a look. http://sourceforge.net/tracker/?atid=560723&group_id=80706&func=browse Regards, -JJ On Mon, Mar 29, 2010 at 1:54 PM, Thomas Robitaille <tho...@gm...> wrote: > Hi Jae-Joon, > > Thanks for your quick reply! Since for example LineCollections can be created independent of the Axes in which they are going to be plotted through the creation of a LineCollection instance, would it not be possible to have a method that allows one to retrieve an Axes-independent LineCollection from an Axes instance? (for example a get_collection method) This would then allow one to 'recycle' existing collections. > > Cheers, > > Thomas > > On Mar 29, 2010, at 1:40 PM, Jae-Joon Lee wrote: > >> As far as I can say, moving around artists from one axes to the other >> is NOT recommended. And I encourage you to create separate artists for >> each axes rather than try to reuse the existing ones. >> >> For your particular example, >> >> fig = mpl.figure() >> ax2 = fig.add_subplot(1,1,1) >> for c in ax1.collections: >> c._transOffset=ax2.transData >> ax2.add_collection(c) >> >> should work. >> >> Regards, >> >> -JJ >> >> >> >> >> On Mon, Mar 29, 2010 at 12:24 PM, Thomas Robitaille >> <tho...@gm...> wrote: >>> Hello, >>> >>> In the following example, I am trying to copy over existing collections from one plot to another: >>> >>> import matplotlib.pyplot as mpl >>> >>> fig = mpl.figure() >>> ax1 = fig.add_subplot(1,1,1) >>> ax1.scatter([0.5],[0.5]) >>> fig.savefig('test1.png') >>> >>> fig = mpl.figure() >>> ax2 = fig.add_subplot(1,1,1) >>> for c in ax1.collections: >>> ax2.add_collection(c) >>> fig.savefig('test2.png') >>> >>> However, the circle appears in the wrong place in test2.png (close to 0.4, 0.4 instead of 0.5,0.5). Is it not possible/safe to copy over collections in this way? If not, then how should this be done? >>> >>> Thanks, >>> >>> Thomas >>> ------------------------------------------------------------------------------ >>> Download Intel® 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 >>> > > > ------------------------------------------------------------------------------ > Download Intel® 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 >
But this example doesn't solve the problem I was thinking of: it shows lots of colors in the colorbar that aren't used in the plot. &C On Mar 30, 2010, at 6:52 AM, Friedrich Romstedt wrote: > 2010年3月30日 Ariel Rokem <ar...@be...>: >> I ended up with the code below, using Chloe's previously posted >> 'subcolormap' and, in order to make the colorbar nicely attached to >> the main >> imshow plot, I use make_axes_locatable in order to generate the >> colorbar >> axes. I tried it out with a couple of use-cases and it seems to do >> what it >> is supposed to, (with ticks only for the edges of the range of the >> data and >> 0, if that is within that range), but I am not entirely sure. Do >> you think >> it works? > > I think even Chloe would agree that you should avoid the subcolormap() > if you can. I tried to create an as minimalistic as possible but > working self-contained example, please find the code also attached as > .py file: > > from matplotlib import pyplot as plt > import matplotlib as mpl > from mpl_toolkits.axes_grid import make_axes_locatable > import numpy as np > > fig = plt.figure() > ax_im = fig.add_subplot(1, 1, 1) > divider = make_axes_locatable(ax_im) > ax_cb = divider.new_vertical(size = '20%', pad = 0.2, pack_start = > True) > fig.add_axes(ax_cb) > > x = np.linspace(-5, 5, 101) > y = x > Z = np.sin(x*y[:,None]).clip(-1,1-0.1) > > # Leave out if you want: > Z += 2 > > min_val = Z.min() > max_val = Z.max() > bound = max(np.abs(Z.max()), np.abs(Z.min())) > > patch = ax_im.imshow(Z, origin = 'upper', interpolation = 'nearest', > vmin = -bound, vmax = bound) > > cb = fig.colorbar(patch, cax = ax_cb, orientation = 'horizontal', > norm = patch.norm, > boundaries = np.linspace(-bound, bound, 256), > ticks = [min_val, 0, max_val], > format = '%.2f') > > plt.show() > > Friedrich > <cbar.py><cbar.png>
Thanks Friedrich, However, my knowledge of python is very limited, even though I think I understood what you suggested I do not know how to get the shape (of the figure?) for this part: >>> fig.set_size_inches(float(shape[0]) / dpi, float(shape[1]) / dpi) error is: Traceback (most recent call last): File "blueearth-map.py", line 108, in <module> fig.set_size_inches(float(shape[0]) / dpi, float(shape[1]) / dpi) TypeError: 'function' object is unsubscriptable It seems that it ended up calling a function shape instead of a variable shape. I'm sending attached the script if you are interested in looking at it. Thanks again. Filipe. On Sun, Mar 28, 2010 at 3:35 PM, Friedrich Romstedt <fri...@gm...> wrote: > > 2010年3月28日 Filipe Pires Alvarenga Fernandes <oc...@gm...>: > > Hello list > > I've trying for a while a "python only" solution to remove white spaces that > > Basemap generate to keep the aspect ratio. I found these two threads that > > explain the issue better: > > I think maybe you can make use of the Agg Backend to achieve a > Python-only solution to obtain a PIL Image from a figure without > bypassing over the HDD: > > Furthemore, if this doesn't work, maybe you can use a StringIO as > "file", then seek() the StringIO and reread with PIL from the > "file-like" StringIO, or something like that? > > # > # Render the Figure to a PIL Image ... > # > > # Prepare figure to be of pixel extent *shape* ... > > dpi = figure.dpi > figure.set_size_inches(float(shape[0]) / dpi, float(shape[1]) / dpi) > > # Create the rendering Canvas ... > # > # We also convert the picture to an RGB string. > > canvas = matplotlib.backends.backend_agg.FigureCanvasAgg(figure) > canvas.draw() > image_string = canvas.tostring_rgb() > > # Create a PIL Image from RGB string ... > > image = Image.fromstring("RGB", shape, image_string) > > # Now do whatever you want with the Image. > > Friedrich
> 2010年3月29日 Alan G Isaac <ala...@gm...>: > > Can you explain this: > > norm = colors.Normalize(vmin = -1, vmax = 1) On 3/28/2010 10:05 PM, Friedrich Romstedt wrote: > The normaliser takes some arbitrary value and returns a value in [0, > 1]. Hence the name. The value \in [0, 1] is handed over to the > cmap's __call__(), resulting in the color value. And yes, I guess you > can use vmin and vmax directly, it's just a matter of taste. OK, thanks! Alan
Hello All. I just found a bug with the histogramme fonction of matplotlib. It might been already known, in this case don't pay attention to my message. The bug append with both OS: Windows XP and Linux (ubuntu). Both using the latest matplotlib release: 0.99.1 The bug is reproductible, with the folliwng script: What the script shall do: Let's say you are looking at the color of wagons on trains. Every trains has 31 wagons. Each time you see a red one, you write down it's number At the end, you want to draw the histogramme with X axis: Number of the wagon in the tain Y axis: Number of wagon of a specific number which is red. My script #------------------------------------------------------------------------------------------------------------------------------ import matplotlib.pyplot as plt liste_histo=[2,2,2,6,1,2,7,2,1,2,1,2,2,1,2,2,11,1,2,12,2,2,14,2,2,1,2,6,1,2,2] plt.figure(1) plt.hist(sorted(liste_histo),bins=31) plt.axis([0,31,0,20]) plt.show() #----------------------------------------------------------------------------------------------------------------------------- This script should give you a srange historamme, with bins that are half the size they shoud be. With the same script, but a different countdown of my wagons, it works well: #----------------------------------------------------------------------------------------------------------------------------- import matplotlib.pyplot as plt liste_histo=[2,2,2,6,1,2,7,2,1,2,1,2,2,1,2,2,11,1,2,12,2,2,14,2,2,1,2,6,15,25] plt.figure(1) plt.hist(sorted(liste_histo),bins=31) plt.axis([0,31,0,20]) plt.show() #----------------------------------------------------------------------------------------------------------------------------- I corrected this error by adding a 32 (my max value on the histogramme should be a 31). asking 32 bins, and drawing the histogramme between 1 and 31: #------------------------------------------------------------------------------------------------------------------------------ import matplotlib.pyplot as plt liste_histo=[2,2,2,6,1,2,7,2,1,2,1,2,2,1,2,2,11,1,2,12,2,2,14,2,2,1,2,6,1,2,2,32] plt.figure(1) plt.hist(sorted(liste_histo),bins=32) plt.axis([0,31,0,20]) plt.show() #----------------------------------------------------------------------------------------------------------------------------- And it works... Am I the only one to get a probleme here? Thanks for reading me Julien
Hi Friedrich, Thanks a lot - very nice! Cheers - Ariel On Tue, Mar 30, 2010 at 6:52 AM, Friedrich Romstedt < fri...@gm...> wrote: > 2010年3月30日 Ariel Rokem <ar...@be...>: > > I ended up with the code below, using Chloe's previously posted > > 'subcolormap' and, in order to make the colorbar nicely attached to the > main > > imshow plot, I use make_axes_locatable in order to generate the colorbar > > axes. I tried it out with a couple of use-cases and it seems to do what > it > > is supposed to, (with ticks only for the edges of the range of the data > and > > 0, if that is within that range), but I am not entirely sure. Do you > think > > it works? > > I think even Chloe would agree that you should avoid the subcolormap() > if you can. I tried to create an as minimalistic as possible but > working self-contained example, please find the code also attached as > .py file: > > from matplotlib import pyplot as plt > import matplotlib as mpl > from mpl_toolkits.axes_grid import make_axes_locatable > import numpy as np > > fig = plt.figure() > ax_im = fig.add_subplot(1, 1, 1) > divider = make_axes_locatable(ax_im) > ax_cb = divider.new_vertical(size = '20%', pad = 0.2, pack_start = True) > fig.add_axes(ax_cb) > > x = np.linspace(-5, 5, 101) > y = x > Z = np.sin(x*y[:,None]).clip(-1,1-0.1) > > # Leave out if you want: > Z += 2 > > min_val = Z.min() > max_val = Z.max() > bound = max(np.abs(Z.max()), np.abs(Z.min())) > > patch = ax_im.imshow(Z, origin = 'upper', interpolation = 'nearest', > vmin = -bound, vmax = bound) > > cb = fig.colorbar(patch, cax = ax_cb, orientation = 'horizontal', > norm = patch.norm, > boundaries = np.linspace(-bound, bound, 256), > ticks = [min_val, 0, max_val], > format = '%.2f') > > plt.show() > > Friedrich > -- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel
Email not displaying correctly? View it in your browser. Hello Amenity, Spring is upon us and arrangements for SciPy 2010 are in full swing. We're already nearing on some important deadlines for conference participants: April 11th is the deadline for submitting an abstract for a paper, and April 15th is the deadline for submitting a tutorial proposal. Help choose tutorials for SciPy 2010... We set up a UserVoice page to brainstorm tutorial topics last week and we already have some great ideas. The top ones at the moment are: Effective multi-core programming with Cython and Python Building your own app with Mayavi High performance computing with Python Propose your own or vote on the existing suggestions here. ...Or instruct a tutorial and cover your conference costs. Did you know that we're awarding generous stipends to tutorial instructors this year? So if you believe you could lead a tutorial, by all means submit your proposal — soon! They're due April 15th. Call for Papers Continues Submitting a paper for to present at SciPy 2010 is easy, so remember to prepare one and have your friends and colleagues follow suit. Send us your abstract before April 11th and let us know whether you'd like to speak at the main conference or one of the specialized tracks. Details here. Have you registered? Booking your tickets early should save you money — not to mention the early registration prices you will qualify for if you register before May 10th. Best, The SciPy 2010 Team @SciPy2010 on Twitter You are receiving this email because you have registered for the SciPy 2010 conference in Austin, TX. Unsubscribe am...@en... from this list | Forward to a friend | Update your profile Our mailing address is: Enthought, Inc. 515 Congress Ave. Austin, TX 78701 Add us to your address book Copyright (C) 2010 Enthought, Inc. All rights reserved.
2010年3月30日 Ariel Rokem <ar...@be...>: > I ended up with the code below, using Chloe's previously posted > 'subcolormap' and, in order to make the colorbar nicely attached to the main > imshow plot, I use make_axes_locatable in order to generate the colorbar > axes. I tried it out with a couple of use-cases and it seems to do what it > is supposed to, (with ticks only for the edges of the range of the data and > 0, if that is within that range), but I am not entirely sure. Do you think > it works? I think even Chloe would agree that you should avoid the subcolormap() if you can. I tried to create an as minimalistic as possible but working self-contained example, please find the code also attached as .py file: from matplotlib import pyplot as plt import matplotlib as mpl from mpl_toolkits.axes_grid import make_axes_locatable import numpy as np fig = plt.figure() ax_im = fig.add_subplot(1, 1, 1) divider = make_axes_locatable(ax_im) ax_cb = divider.new_vertical(size = '20%', pad = 0.2, pack_start = True) fig.add_axes(ax_cb) x = np.linspace(-5, 5, 101) y = x Z = np.sin(x*y[:,None]).clip(-1,1-0.1) # Leave out if you want: Z += 2 min_val = Z.min() max_val = Z.max() bound = max(np.abs(Z.max()), np.abs(Z.min())) patch = ax_im.imshow(Z, origin = 'upper', interpolation = 'nearest', vmin = -bound, vmax = bound) cb = fig.colorbar(patch, cax = ax_cb, orientation = 'horizontal', norm = patch.norm, boundaries = np.linspace(-bound, bound, 256), ticks = [min_val, 0, max_val], format = '%.2f') plt.show() Friedrich
David Carmean <dlc-sfl@...> writes: > At what point is a line Collection useful? More efficient for adding or manipulating many lines in one go. It saved my life (some hours of it, anyway) the other day: http://article.gmane.org/gmane.comp.python.matplotlib.general/22149
Hi - I ended up with the code below, using Chloe's previously posted 'subcolormap' and, in order to make the colorbar nicely attached to the main imshow plot, I use make_axes_locatable in order to generate the colorbar axes. I tried it out with a couple of use-cases and it seems to do what it is supposed to, (with ticks only for the edges of the range of the data and 0, if that is within that range), but I am not entirely sure. Do you think it works? Cheers, Ariel from mpl_toolkits.axes_grid import make_axes_locatable fig=plt.figure() ax_im = fig.add_subplot(1,1,1) divider = make_axes_locatable(ax_im) ax_cb = divider.new_vertical(size="20%", pad=0.2, pack_start=True) fig.add_axes(ax_cb) #Extract the minimum and maximum values for scaling of the colormap/colorbar: max_val = np.max(m[np.where(m<1)]) min_val = np.min(m) #This makes sure that 0 is always the center of the colormap: if min_val<-max_val: ax_max = -min_val ax_min = min_val else: ax_max = max_val ax_min = -max_val #Keyword args to imshow: kw = {'origin': 'upper', 'interpolation': 'nearest', 'cmap':cmap, 'vmin':ax_min, 'vmax':ax_max} im=ax_im.imshow(m,**kw) #The following produces the colorbar and sets the ticks if colorbar: delta = ax_max-ax_min #The size of the entire interval of data min_p = (min_val-ax_min)/delta max_p = (max_val-ax_min)/delta print min_p print max_p cnorm = mpl.colors.Normalize(vmin=min_val,vmax=max_val) subcmap = subcolormap(min_p,max_p,cmap) cb = mpl.colorbar.ColorbarBase(ax_cb, cmap=subcmap, orientation='horizontal',norm=cnorm) #Set the ticks - if 0 is in the interval of values, set that, as well #as the maximal and minimal values: if min_val<0: cb.set_ticks([min_val,0,max_val]) cb.set_ticklabels(['%.2f'%min_val,'0','%.2f'%max_val]) #Otherwise - only set the minimal and maximal value: else: cb.set_ticks([min_val,max_val]) cb.set_ticklabels(['%.2f'%min_val,'%.2f'%max_val]) On Mon, Mar 29, 2010 at 6:41 AM, Friedrich Romstedt < fri...@gm...> wrote: > 2010年3月29日 Friedrich Romstedt <fri...@gm...>: > > Note that the ticking is a bit weird, there is also a bug in > > matplotlib I will report on right after this e-mail, whose bugfix you > > will maybe want to apply to get ticking properly working. When you > > have insane values for C.min() and C.max() anyway, I'm afraid you have > > to retick manually with *ticks* to colorbar(). The ticker.MaxNLocator > > is only used when not using the *boundaries* arg to colorbar(), > > unfortunately. Otherwise it tries to create maximal many and less > > than 11 ticks by using the lowest value and an appropriate step in > > *boundaries*. I think the implementation of ticking is cumbersome and > > never optimal. > > You can get rid of this night mare by giving the kwarg "ticks = > matplotlib.ticker.MaxNLocator()" to fig.colorbar(). Then the > *boundaries* aren't used for ticking (but still for plotting). > > Friedrich > -- Ariel Rokem Helen Wills Neuroscience Institute University of California, Berkeley http://argentum.ucbso.berkeley.edu/ariel
Hello, This is my first time trying out this list, so please forgive me if I've doing this wrong. I'm trying to create a plot that has its origin in the upper-left hand corner, rather than the lower-left hand corner. I've discovered that I get the same effect if I do: plt.plot( xcoords, ycoords, 'ro' ) plt.axis( [0, maxX, maxY, 0] ) However, the x-axis still appears on the bottom of the graph rather than the top. Is there a way that I can shift the location of the origin more easily, or at least shift where the axis is written at? Thanks!