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) |
|
|
|
|
|
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()
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
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
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 > > > > >
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.
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 > >
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)
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)
Ah, thanks a lot. --- On Thu, 5/27/10, Jae-Joon Lee <lee...@gm...> wrote: > From: Jae-Joon Lee <lee...@gm...> > Subject: Re: [Matplotlib-users] Clip text in bars > To: "wrpd_mnd" <wrp...@ya...> > Cc: mat...@li... > Date: Thursday, May 27, 2010, 9:24 AM > The bbox needs to be in a proper > coordinate. > > from matplotlib.transforms import TransformedBbox > bb = TransformedBbox(rect[0].get_bbox(), ax.transData) > > Also, do not use clip_on when clip_box is used. clip_on > override > clip_box with ax.bbox. > > text0 = ax.text(0,11,'JobName', clip_box=bb) > > A complete code is attached. > > Regards, > > -JJ > > > import matplotlib.pyplot as plt > from matplotlib.transforms import TransformedBbox > > fig = plt.figure() > > ax = fig.add_subplot(111) > rect = ax.barh(10, 50, 3, facecolor='green', visible=True) > ax.set_ylim(0,35) > ax.set_xlim(0,1000) > > bb = TransformedBbox(rect[0].get_bbox(), ax.transData) > > text0 = ax.text(0,11,'JobName', clip_box=bb) > > ax.grid(True) > > plt.show() > > > > On Thu, May 27, 2010 at 8:41 AM, wrpd_mnd <wrp...@ya...> > wrote: > > > > I'm trying to set up a chart that shows a runtime > trace of a single frame. > > Most of it is straight forward, however one aspect of > it is driving me > > crazy. I would like to label the inside of the bar > fragments (each represent > > a function call with the x-extent being its runtime) > with the name of the > > task, however I would like the text itself to be fully > contained within the > > bar itself. I should, in theory, be able to set the > clipping box of the text > > to be the bounding box of the bar and that should give > me the result I want. > > Except, I'm not getting that. > > > > Any ideas? > > > > See the code below: > > > > import numpy as np > > import matplotlib.pyplot as plt > > > > fig = plt.figure() > > ax = fig.add_subplot(111) > > rect = ax.barh(10, 50, 3, facecolor='green', > visible=True) > > ax.set_ylim(0,35) > > ax.set_xlim(0,1000) > > > > text0 = > ax.text(0,11,'JobName',clip_on=True,clip_box=rect[0].get_bbox()) > > > > ax.grid(True) > > > > plt.show() > > > > -- > > View this message in context: http://old.nabble.com/Clip-text-in-bars-tp28693489p28693489.html > > Sent from the matplotlib - users mailing list archive > at Nabble.com. > > > > > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > > Matplotlib-users mailing list > > Mat...@li... > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users > > >
What I usually do is to clear the axis (using cla() only) right after creating or accessing it (either with figure() or subplot() or similar magic): from pylab import * fig = figure(num=1) for example in range(5): cla() plot(rand(100)) savefig('test-%d.png'%example) -------- Original Message -------- Subject: [Matplotlib-users] Clearing A Figure (I Know That This Has Been Posted Before But I Does Not Work For Me) Date: 2010年5月25日 02:08:42 -0700 (PDT) From: Thistleryver <mh...@ec...> To: mat...@li... I am attempting to run a lot of tests automatically and generate a graph for each one. However, at the moment, the previous graph remains on the figure and the next plot is drawn over it. I have read extensively the documentation and I have tried a whole lot of different commands but to no avail. In the previous post it said to use pylab.clf() which is exactly what I've been trying to use. So far I have used pylab.cla(), pylab.clf() and pylab.close() although I believe that this only closes an open figure window. I have no idea why it is not working now especially since it would appear that my question had already been answered in both the documentation and the forums. I am using Python 2.6.4 on Ubuntu Linux. Here is the relevant code I am using: pylab.plot(xAxis, TrainingPoints, 'b-') pylab.plot(xAxis, TestPoints, 'r-') pylab.xlabel('Epochs') pylab.ylabel('Sum Squared Error') pylab.title('Plot of Iris Training Errors') outfilename = str(int(LEARNING_RATE)) + ".png" print outfilename pylab.ylim(ymin=0) pylab.savefig(outfilename) pylab.cla() pylab.clf() I really hope one of you can spot an error otherwise I am completely stuck. -- View this message in context: http://old.nabble.com/Clearing-A-Figure-%28I-Know-That-This-Has-Been-Posted-Before-But-I-Does-Not-Work-For-Me%29-tp28665976p28665976.html Sent from the matplotlib - users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Mat...@li... https://lists.sourceforge.net/lists/listinfo/matplotlib-users
The bbox needs to be in a proper coordinate. from matplotlib.transforms import TransformedBbox bb = TransformedBbox(rect[0].get_bbox(), ax.transData) Also, do not use clip_on when clip_box is used. clip_on override clip_box with ax.bbox. text0 = ax.text(0,11,'JobName', clip_box=bb) A complete code is attached. Regards, -JJ import matplotlib.pyplot as plt from matplotlib.transforms import TransformedBbox fig = plt.figure() ax = fig.add_subplot(111) rect = ax.barh(10, 50, 3, facecolor='green', visible=True) ax.set_ylim(0,35) ax.set_xlim(0,1000) bb = TransformedBbox(rect[0].get_bbox(), ax.transData) text0 = ax.text(0,11,'JobName', clip_box=bb) ax.grid(True) plt.show() On Thu, May 27, 2010 at 8:41 AM, wrpd_mnd <wrp...@ya...> wrote: > > I'm trying to set up a chart that shows a runtime trace of a single frame. > Most of it is straight forward, however one aspect of it is driving me > crazy. I would like to label the inside of the bar fragments (each represent > a function call with the x-extent being its runtime) with the name of the > task, however I would like the text itself to be fully contained within the > bar itself. I should, in theory, be able to set the clipping box of the text > to be the bounding box of the bar and that should give me the result I want. > Except, I'm not getting that. > > Any ideas? > > See the code below: > > import numpy as np > import matplotlib.pyplot as plt > > fig = plt.figure() > ax = fig.add_subplot(111) > rect = ax.barh(10, 50, 3, facecolor='green', visible=True) > ax.set_ylim(0,35) > ax.set_xlim(0,1000) > > text0 = ax.text(0,11,'JobName',clip_on=True,clip_box=rect[0].get_bbox()) > > ax.grid(True) > > plt.show() > > -- > View this message in context: http://old.nabble.com/Clip-text-in-bars-tp28693489p28693489.html > Sent from the matplotlib - users mailing list archive at Nabble.com. > > > ------------------------------------------------------------------------------ > > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users >
On 5/27/2010 9:54 AM, Sandy Ydnas wrote: > it is the my point > show() can not be used during debuging.... > > but without debug option any tools is usless > since the main problem in coding is debuging ... But you have never explained your need here. You cannot start the mainloop (using ``show``) and then complain that the mainloop is running! If you want do debug your script, just use ``savefig`` instead of ``show``. If that is not adequate, explain why. Alan Isaac
Dear Pim, 2010年5月27日 Pim Schellart <p.s...@gm...>: > At first I used the binaries for the latest stable releases of Python > 2.6 + numpy + matplotlib from the respected websites. > But in order to compile a custom library I needed Python to be compiled 64 bit. For me this was the same with PIL ... though I didn't need 64bit for that. And I agree, for a new Mac user it's a mess. > This worked for Python, numpy and scipy but not for matplotlib. > I used to be able to compile matplotlib with a simple "sudo python > setup.py install" but when I tried to do this after the change to 64 > bit the build failed with some errors which seemed to me to be related > to freetype not being compiled 64 bit (these errors, which I > unfortunately did not save clearly indicated that the linker could not > find some symbols and when I checked the architecture of the libs it > was i386 only). > I tried to fix this by first compiling freetype 64 bit, and later > libpng as well. > The problem now was that setupext.py did not look in the right > location for my new libpng build. > After I installed pkgtool this was also solved, however now the > reported error occurred. And this error was due to the API change. > I also could not use the make.osx script from the latest svn checkout > because of a bug in the fetching of zlib which John fixed. > Finally removing my custom installations of freetype and libpng and > using make.osx to fetch and build them solved the problem. > Oh and somewhere in all this mess I also managed to build it but then > got a malloc error when loading so I tried the removing of i386 but > this did not solve the problem so I changed it back. This I don't understand. > I guess the conclusion is that the current svn works, but only with > the make.osx approach. I cannot agree currently. I can try to do my first contact with svn, but for the stable release, it works as said before with some tweaking in setupext.py and src/_png.cpp too. Also we seem to have quite similar machines and prerequisites. The setupext.py tweak may be omittable by using pkgtool. So my conclusion is that with using pkgtool and the change in src/_png.cpp matplotlib should be buildable from sources with setup.py. John, shouldn't we finally fix this ugly src/_png.cpp problem? More and more people run into problems when using the recent libpng-1.4. The lines to be added to _png.cpp are: #define png_infopp_NULL (png_infopp)NULL #define int_p_NULL (int*)NULL Maybe libpng defines some constant to make use of in determining whether the build is with libpng-1.2 or 1.4. > If I had the time I would try it again on a fresh install to see where > the bug is that prevents setup.py from working with a custom compiled > freetype and libpng but for now I am happy that it finally works :) I can understand you and I'm facing the same problem. Friedrich
I'm trying to set up a chart that shows a runtime trace of a single frame. Most of it is straight forward, however one aspect of it is driving me crazy. I would like to label the inside of the bar fragments (each represent a function call with the x-extent being its runtime) with the name of the task, however I would like the text itself to be fully contained within the bar itself. I should, in theory, be able to set the clipping box of the text to be the bounding box of the bar and that should give me the result I want. Except, I'm not getting that. Any ideas? See the code below: import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) rect = ax.barh(10, 50, 3, facecolor='green', visible=True) ax.set_ylim(0,35) ax.set_xlim(0,1000) text0 = ax.text(0,11,'JobName',clip_on=True,clip_box=rect[0].get_bbox()) ax.grid(True) plt.show() -- View this message in context: http://old.nabble.com/Clip-text-in-bars-tp28693489p28693489.html Sent from the matplotlib - users mailing list archive at Nabble.com.
Dear Friedrich, sorry for the confusion. It may very well be that I misinterpreted part of the problem as I am no expert either. The problem came to be as follows. At first I used the binaries for the latest stable releases of Python 2.6 + numpy + matplotlib from the respected websites. But in order to compile a custom library I needed Python to be compiled 64 bit. This worked for Python, numpy and scipy but not for matplotlib. I used to be able to compile matplotlib with a simple "sudo python setup.py install" but when I tried to do this after the change to 64 bit the build failed with some errors which seemed to me to be related to freetype not being compiled 64 bit (these errors, which I unfortunately did not save clearly indicated that the linker could not find some symbols and when I checked the architecture of the libs it was i386 only). I tried to fix this by first compiling freetype 64 bit, and later libpng as well. The problem now was that setupext.py did not look in the right location for my new libpng build. After I installed pkgtool this was also solved, however now the reported error occurred. I also could not use the make.osx script from the latest svn checkout because of a bug in the fetching of zlib which John fixed. Finally removing my custom installations of freetype and libpng and using make.osx to fetch and build them solved the problem. Oh and somewhere in all this mess I also managed to build it but then got a malloc error when loading so I tried the removing of i386 but this did not solve the problem so I changed it back. I guess the conclusion is that the current svn works, but only with the make.osx approach. If I had the time I would try it again on a fresh install to see where the bug is that prevents setup.py from working with a custom compiled freetype and libpng but for now I am happy that it finally works :) Kind regards, Pim Schellart 2010年5月27日 Friedrich Romstedt <fri...@gm...>: > 2010年5月27日 Pim Schellart <p.s...@gm...>: >> thank you for the tip, I'll try and see if the stable release works as >> well with this adjustment. >> The problem however was not just in compiling on Snow Leopard, but >> compiling specifically against a custom compiled 64 bit only version >> of python. >> This now works with the make.osx file and the latest svn release, >> although I agree this is an ugly solution and would prefer the same >> build system on every OS. > > Pim, > > I must confess that I'm lost a bit in all this details and all this > patches ... I hope that I'm not alone with this ... Can you maybe give > a short summary on the list? > > First I don't understand why you compiled a "64 bit only" version of > your Python. I.e., what am I missing, when I compile my Python 2.6 > the usual way? (I also have a 64 bit machine.) > > Then, your first error seems to originate from: >> src/ft2font.h:13:22: error: ft2build.h: No such file or directory > > I don't know, but I guess it's due to not finding the correct include > directory for you self-compiled freetype2? If it is like this, I > fixed it in setupext.py (the "darwin" section, not the "darwin_" > section). The search path list is empty for "darwin", and I added > "/usr/local" into it. Actually I don't remember precisely what the > error was making me fixing this ... And it's true, I simply ignored > the "# So I'm pointing to ..." comment in setupext.py ... > > Then the next error you reported was clearly related to libpng API > change, so again nothing with 32/64 bit issues. > > So, I don't understand your conclusion that at all you have problems > due to your 64bit-only built Python? Sorry, maybe I miss something > obvious? I think people have been trusting you that it's a 64bit > issue, and gave suggestions based on that, but maybe it isn't at all? > Just a whacky thought! I simply cannot find an error pointing towards > this root! I now went throught it again finally, and I found that > magically John mentioned his "work for 64bit Python on the make.osx > file", and then there was some "remove all -arch i386" recommendation, > but it's all a bit unclear to me ... Sorry, I'm not an expert at all, > my intention is just to track the problem /not to the false root/ > down. > > My explanation is: You downloaded by using make.osx an older version > of libpng (1.2) and additionally a freetype version in local > directory, so all the -Is are working respectively. This solved both > your freetype problem and your libpng problem. I need some advice > what else was solved by make.osx? > > Of course this path is good for creating binaries with libpng and > freetype2 hardlinked, but I don't see the clue for your case. > > Friedrich >
2010年5月25日 Pim Schellart <p.s...@gm...>: > I tried both and although it now seems to find the libraries it still > fails to link something. > > src/_png.cpp:293: error: ‘png_infopp_NULL’ was not declared in this scope > src/_png.cpp:293: error: ‘png_infopp_NULL’ was not declared in this scope I compiled matplotlib-0.99.1.2 just yesterday fine on Snow Leopard from source without being aware of make.osx (with freetype2-2.3.12, libpng-1.4.1). The problem I'm citing here, which seems to be actually also your problem, is due to an API change in linbpng from 1.3 to 1.4. I soon ago pointed this out on the list but there were no responses. One can add #defines for the missing things in src/_png.cpp to fix it. I don't know if you would run into some more problems but this one is solvable. But I also modified setupext.py to find my libraries in /usr/local. Friedrich
We can actually check from Python whether it's a framework install or not. >>> import MacOS >>> MacOS.WMAvailable() returns True if it's a framework install, False if not. I can add this check to the MacOSX backend and print out a warning if it's not a framework install. --Michiel --- On Wed, 5/26/10, Daniel Welling <dan...@gm...> wrote: From: Daniel Welling <dan...@gm...> Subject: Re: [Matplotlib-users] Mac backend problems for nearly all backends. To: "Michiel de Hoon" <mjl...@ya...> Cc: mat...@li... Date: Wednesday, May 26, 2010, 12:51 AM 2) In which case, it's not a framework install. Fink puts everything into /sw/; there's nothing to do with pyton in /Library/Frameworks.Thanks for the clarification; I'm tempted to get Python from source and try this... -dw On Tue, May 25, 2010 at 10:41 PM, Michiel de Hoon <mjl...@ya...> wrote: > 1)The problem does manifest in the same manner through the normal python prompt. OK that is good to know. > 2) I'm not sure what is meant by a "framework install." Everything (except MPL 99.1.1) > was installed through fink. This is important. Check where python is installed. If 'which python' shows /Library/Frameworks/Python.framework/Versions/2.6/bin/python or something similar, you have a framework version. If on the other hand it shows /usr/bin/python, /usr/local/bin/python, or something similar, you don't have a framework version. I don't know what fink installs by default. If you don't have Python installed as a framework, some backends (including the MacOSX backend) will not interact properly with the window manager. This is a Mac peculiarity. If you build Python from source, you can specify to install a framework version by passing the --enable-framework option to the configure script. > 6) Although I use x11 and not the native Mac terminal, I'm not sure if this requires me to > install different packages for the gui stuff. Could you guys expand on this, please? Some backends go make use of X11 (e.g., the gtkcairo backend), others do not (e.g., the MacOSX backend). The MacOSX backend should work with both the native Mac terminal and with an X11 terminal. --Michiel.