Re: [Matplotlib-users] Plot linestyle as an arrow
Thanks for your help, I simplified what I was doing and so changed the data, which is my fault. Here is some data of similar size to the data I am plotting: data1 = np.array([22000, 25000, 27000, 32000, 25000]) data2 = np.array([1400, 2200, 350, 300, 270]) When I try to run this with the above code I get a very strange graph and these errors: In [16]: run t.py Warning: overflow encountered in long_scalars Warning: overflow encountered in long_scalars Warning: overflow encountered in long_scalars Warning: overflow encountered in long_scalars Warning: invalid value encountered in sqrt So then tried the same method using the annotation as suggested (code below) which worked perfectly. import numpy as np import matplotlib.pyplot as plt import matplotlib as mpl from matplotlib.ticker import FuncFormatter labels=('91','92','93','94','95') data1 = np.array([22000, 25000, 27000, 32000, 25000]) data2 = np.array([1400, 2200, 350, 300, 270]) fig = plt.figure() ax = fig.add_subplot(111) # the next line is only use to set the proper lims, p = ax.plot(data1, data2, 'bo', linestyle='-', markersize=3, alpha=0) for x,y,dx,dy in zip(data1[:-1], data2[:-1], data1[1:], data2[1:]): ax.annotate('', xy=(dx,dy), xycoords='data', xytext=(x,y), textcoords='data', arrowprops=dict(arrowstyle=-)) ax.set_xlim(21000,33000) for i, label in enumerate(labels): x_loc = data1[i] y_loc = data2[i] txt = ax.annotate(label, xy=(x_loc, y_loc), size=8, xytext=(-10, 10), textcoords='offset points', arrowprops=None) plt.show() Just in case someone else has a similar problem. Thanks Catherine -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] X,Y,Z values to Wiremesh3d
Appologies if this question has been asked previously. I have done a quick search of the archives and have been unable to find a similar question: (I'm quite new to this) I have a set of data in a numpy array which consists of: X_Coord, Y_Coord, Z_level [[x,y,z], [x,y,z], [x,y,z], ... .. [x,y,z], [x,y,z]] How do I appropriatley format these arrays of data such that I can feed it to: ax.plot_wireframe(X, Y, Z, rstride=10, cstride=10) I WOULD have thought it was as simple as feeding the X value to X the Y value to Y and the Z value to Z in the above command. However this doesnt work. Also: is there a written specification for the data format expected by the above command?It does not seem to take a logical format. (at least logical in my eyes) I look forward to an answer (or more questions) Regards, David -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] Stacked Bar Chart Question in matplotlib 1.0.0
Hello all, I need to draw different hatch styles on the different groups of a stacked bar chart in order to make a figure that works properly in black and white. The devil is, I can't figure out how to do it. When I pass the hatch option a list of values, I get an error. A simple example: from numpy import * import matplotlib.pyplot as plt plt.hist( [ linspace(1, 10, 20), linspace(1, 10, 40)], bins=range(10), histtype=barstacked, rwidth=1.0, label=[a, b], color=[red, green], hatch=[/, x] ) plt.show() The resulting errors/outputs are at the end of the email. Thanks in advance for any help, Sean Lake In [4]: plt.hist( [ linspace(1, 10, 20), linspace(1, 10, 40)], bins=range(10), histtype =barstacked, rwidth=1.0, label=[a, b], ...: color=[red, green], hatch=[/, x] ) Out[4]: ([array([0, 3, 2, 2, 2, 2, 2, 2, 2]), array([0, 5, 4, 4, 5, 4, 4, 5, 4])], array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), a list of 2 Lists of Patches objects) In [5]: plt.show() --- TypeError Traceback (most recent call last) /sw/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.pyc in expose_event(self, widget, event) 391 x, y, w, h = self.allocation 392 self._pixmap_prepare (w, h) -- 393 self._render_figure(self._pixmap, w, h) 394 self._need_redraw = False 395 /sw/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.pyc in _render_figure(self, pixmap, width, height) 73 def _render_figure(self, pixmap, width, height): 74 if DEBUG: print 'FigureCanvasGTKAgg.render_figure' --- 75 FigureCanvasAgg.draw(self) 76 if DEBUG: print 'FigureCanvasGTKAgg.render_figure pixmap', pixmap 77 #agg_to_gtk_drawable(pixmap, self.renderer._renderer, None) /sw/lib/python2.6/site-packages/matplotlib/backends/backend_agg.pyc in draw(self) 392 393 self.renderer = self.get_renderer() -- 394 self.figure.draw(self.renderer) 395 396 def get_renderer(self): /sw/lib/python2.6/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) --- 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /sw/lib/python2.6/site-packages/matplotlib/figure.pyc in draw(self, renderer) 796 dsu.sort(key=itemgetter(0)) 797 for zorder, func, args in dsu: -- 798 func(*args) 799 800 renderer.close_group('figure') /sw/lib/python2.6/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) --- 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /sw/lib/python2.6/site-packages/matplotlib/axes.pyc in draw(self, renderer, inframe) 1932 1933 for zorder, a in dsu: - 1934 a.draw(renderer) 1935 1936 renderer.close_group('axes') /sw/lib/python2.6/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) --- 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /sw/lib/python2.6/site-packages/matplotlib/patches.pyc in draw(self, renderer) 381 path_effect.draw_path(renderer, gc, tpath, affine, rgbFace) 382 else: -- 383 renderer.draw_path(gc, tpath, affine, rgbFace) 384 385 gc.restore() /sw/lib/python2.6/site-packages/matplotlib/backends/backend_agg.pyc in draw_path(self, gc, path, transform, rgbFace) 115 self._renderer.draw_path(gc, p, transform, rgbFace) 116 else: -- 117 self._renderer.draw_path(gc, path, transform, rgbFace) 118 119 def draw_mathtext(self, gc, x, y, s, prop, angle): /sw/lib/python2.6/site-packages/matplotlib/backend_bases.pyc in get_hatch_path(self, density) 865 if self._hatch is None: 866 return None -- 867 return Path.hatch(self._hatch, density) 868 869 /sw/lib/python2.6/site-packages/matplotlib/path.pyc in hatch(cls, hatchpattern, density) 662 return None 663 -- 664 hatch_path = cls._hatch_dict.get((hatchpattern, density)) 665 if hatch_path is not None: 666 return hatch_path TypeError: unhashable type: 'list' --- TypeError Traceback (most recent call last)
Re: [Matplotlib-users] Stacked Bar Chart Question in matplotlib 1.0.0
On Wed, Mar 23, 2011 at 8:43 AM, Sean Lake odysseus9...@gmail.com wrote: Hello all, I need to draw different hatch styles on the different groups of a stacked bar chart in order to make a figure that works properly in black and white. The devil is, I can't figure out how to do it. When I pass the hatch option a list of values, I get an error. Looks like the 'hatch' keyword must be a single string, not a list. You can set the hatch style of the patches in the plot after calling hist(): - from numpy import * import matplotlib.pyplot as plt hatches = ['/', '+', '*', '\\', 'x', '.', '-', 'o'] result = plt.hist( [ linspace(1, 10, 20), linspace(1, 10, 40)], bins=len(hatches), histtype=barstacked, rwidth=1.0, label=[a, b], color=[red, green]) plist1 = result[2][0] plist2 = result[2][1] for h, p1, p2 in zip(hatches, plist1, plist2): p1.set_hatch(h) p2.set_hatch(h) plt.show() - Warren A simple example: from numpy import * import matplotlib.pyplot as plt plt.hist( [ linspace(1, 10, 20), linspace(1, 10, 40)], bins=range(10), histtype=barstacked, rwidth=1.0, label=[a, b], color=[red, green], hatch=[/, x] ) plt.show() The resulting errors/outputs are at the end of the email. Thanks in advance for any help, Sean Lake In [4]: plt.hist( [ linspace(1, 10, 20), linspace(1, 10, 40)], bins=range(10), histtype =barstacked, rwidth=1.0, label=[a, b], ...: color=[red, green], hatch=[/, x] ) Out[4]: ([array([0, 3, 2, 2, 2, 2, 2, 2, 2]), array([0, 5, 4, 4, 5, 4, 4, 5, 4])], array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), a list of 2 Lists of Patches objects) In [5]: plt.show() --- TypeError Traceback (most recent call last) /sw/lib/python2.6/site-packages/matplotlib/backends/backend_gtk.pyc in expose_event(self, widget, event) 391 x, y, w, h = self.allocation 392 self._pixmap_prepare (w, h) -- 393 self._render_figure(self._pixmap, w, h) 394 self._need_redraw = False 395 /sw/lib/python2.6/site-packages/matplotlib/backends/backend_gtkagg.pyc in _render_figure(self, pixmap, width, height) 73 def _render_figure(self, pixmap, width, height): 74 if DEBUG: print 'FigureCanvasGTKAgg.render_figure' --- 75 FigureCanvasAgg.draw(self) 76 if DEBUG: print 'FigureCanvasGTKAgg.render_figure pixmap', pixmap 77 #agg_to_gtk_drawable(pixmap, self.renderer._renderer, None) /sw/lib/python2.6/site-packages/matplotlib/backends/backend_agg.pyc in draw(self) 392 393 self.renderer = self.get_renderer() -- 394 self.figure.draw(self.renderer) 395 396 def get_renderer(self): /sw/lib/python2.6/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) --- 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /sw/lib/python2.6/site-packages/matplotlib/figure.pyc in draw(self, renderer) 796 dsu.sort(key=itemgetter(0)) 797 for zorder, func, args in dsu: -- 798 func(*args) 799 800 renderer.close_group('figure') /sw/lib/python2.6/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) --- 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /sw/lib/python2.6/site-packages/matplotlib/axes.pyc in draw(self, renderer, inframe) 1932 1933 for zorder, a in dsu: - 1934 a.draw(renderer) 1935 1936 renderer.close_group('axes') /sw/lib/python2.6/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs) 53 def draw_wrapper(artist, renderer, *args, **kwargs): 54 before(artist, renderer) --- 55 draw(artist, renderer, *args, **kwargs) 56 after(artist, renderer) 57 /sw/lib/python2.6/site-packages/matplotlib/patches.pyc in draw(self, renderer) 381 path_effect.draw_path(renderer, gc, tpath, affine, rgbFace) 382 else: -- 383 renderer.draw_path(gc, tpath, affine, rgbFace) 384 385 gc.restore() /sw/lib/python2.6/site-packages/matplotlib/backends/backend_agg.pyc in draw_path(self, gc, path, transform, rgbFace) 115 self._renderer.draw_path(gc, p, transform, rgbFace) 116 else: -- 117 self._renderer.draw_path(gc, path, transform, rgbFace) 118 119 def draw_mathtext(self, gc, x, y, s, prop, angle): /sw/lib/python2.6/site-packages/matplotlib/backend_bases.pyc in
Re: [Matplotlib-users] Qt4 on OSX
Greetings again, Michiel. Please excuse my slow response time... First, thanks for explaining the Framework stuff; it clarifies situation. I'll be sure to never blame the OSX backend where it is not warranted! Unfortunately (in terms of easy explanations): In [3]: MacOS.WMAvailable() Out[3]: True crap. Fortunately, I've been able to nail down the problem: bash-3.2$ ipython Python 2.6.6 (r266:84292, Jan 18 2011, 14:07:55) Type copyright, credits or license for more information. IPython 0.10.1 -- An enhanced Interactive Python. ? - Introduction and overview of IPython's features. %quickref - Quick reference. help - Python's own help system. object? - Details about 'object'. ?object also works, ?? prints more. In [2]: import matplotlib.pyplot as plt In [3]: plt.plot([0,1]) Out[3]: [matplotlib.lines.Line2D object at 0x118c6be90] In [4]: plt.show() (Here, saving the plot works like normal.) In [5]: plt.ion() In [6]: plt.plot([0,1]) Out[6]: [matplotlib.lines.Line2D object at 0x118c8bc90] (Now, when trying to save the plot, the save and cancel buttons no longer respond. I must kill python from another terminal.) So that's the situation with OSX. It's something that comes up frequently enough (typically a quick plot turns into a more thorough customization followed by the lockup) that TK becomes a more viable option for me though OSX is faster and has better file navigation features. Again, if QT4 was working, that is certainly my weapon of choice... On Mon, Mar 21, 2011 at 7:14 AM, Michiel de Hoon mjldeh...@yahoo.comwrote: --- On *Sun, 3/20/11, Daniel Welling dantwell...@gmail.com* wrote: The OSX backend used to have a bug where you cannot type a name in the file name text box.Since that has been fixed, ... That was not a bug in the MacOSX backend (and therefore was not fixed), but is related to how Python is installed on your system: If your Python is not a framework installation, it will not interact correctly with Apple's windowing manager. This is due to OS X itself and is independent of the MacOSX backend. I have found a new bug: every so often, when you go to save a file, the save and cancel button stop responding, trapping the user in file saving limbo. I'll have to play with it again to figure out what triggers this. Can you check if your Python is built as a framework? If it is, MacOS.WMAvailable() should return True: $ python Python 2.7.1 (r271:86832, Mar 12 2011, 13:44:53) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin Type help, copyright, credits or license for more information. import MacOS MacOS.WMAvailable() True Best, --Michiel. -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] autoscale y for current x range on display
Hi, I am new to python and matplotlib and have a small question. Is there a way to autoscale the y axis for the current x range in view? Currently, my y axes are scaled to all the data. Thanks Adrian -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] exclude lines from a loose_autoscale_view function
I'm not sure if this is going to work to solve an issue I'm having, but I'd like to try it before asking a much more complex question. I have a function, loose_autoscale_view(), that is based on the autoscale_view function in mpl but allows margin arguments to push the margins out a bit more. I'd like to try to alter it to allow certain lines belonging to an axis to not be taken into consideration when autoscaling. I can alter it to accept a list of lines to be excluded, but then I don't know how to exclude them when calculating the autoscaling. I think the key line in the function is this one: bb = mtransforms.BboxBase.union(dl) because that union gets the sub-BBoxes for all the lines...so is there a way to exclude some? Or is there a better approach? Thanks. The function is below. -Che def loose_autoscale_view(self, subplot, xmargin, ymargin, tight=False, scalex=True, scaley=True): autoscale the view limits using the data limits. You can selectively autoscale only a single axis, eg, the xaxis by setting *scaley* to *False*. The autoscaling preserves any axis direction reversal that has already been done. I have added a way to make it not quite so tight using xmargin and ymargin. # if image data only just use the datalim #if not self.subplot._autoscaleon: return if scalex: xshared = subplot._shared_x_axes.get_siblings(subplot) dl = [ax.dataLim for ax in xshared] bb = mtransforms.BboxBase.union(dl) xdiff = bb.intervalx[1] - bb.intervalx[0] x0 = bb.intervalx[0]-xdiff * xmargin x1 = bb.intervalx[1]+xdiff * xmargin if scaley: yshared = subplot._shared_y_axes.get_siblings(subplot) dl = [ax.dataLim for ax in yshared] bb = mtransforms.BboxBase.union(dl) y0_untampered = bb.intervaly[0]-(bb.intervaly[1]) y0 = bb.intervaly[0]-(bb.intervaly[1]* ymargin) y1_untampered = bb.intervaly[1] y1 = bb.intervaly[1]* (1+ymargin) if (tight or (len(subplot.images)0 and len(subplot.lines)==0 and len(subplot.patches)==0)): if scalex: subplot.set_xbound(x0, x1) if scaley: subplot.set_ybound(y0, y1) return if scalex: XL = subplot.xaxis.get_major_locator().view_limits(x0, x1) subplot.set_xbound(XL) if scaley: YL = subplot.yaxis.get_major_locator().view_limits(y0, y1) subplot.set_ybound(YL) -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] autoscale y for current x range on display
Adrian HILL, on 2011-03-23 19:42, wrote: Hi, I am new to python and matplotlib and have a small question. Is there a way to autoscale the y axis for the current x range in view? Currently, my y axes are scaled to all the data. Hi Adrian, there isn't a built-in way of doing this at the moment, because the general case would require going through all of the plotted data and finding the minmax for only the parts of the data that are withing some range (as apposed to the minmax for all data). If there's some regularity about your data, or if you know that you'll have only a few (maybe even just one?) artist, you could implement such functionality using callbacks, such as 'xlim_changed' or 'ylim_changed'. The quickest way would be to have those callbacks adjust ax.dataLim and then call autoscale. plt.clf() ax = plt.gca() data = np.sin(np.linspace(0,10,100)) ax.plot(data) def cb(ax): start,stop = [int(x) for x in ax.get_xlim()] d = data[start:stop+1] ax.dataLim._points[:,1] = d.min(), d.max() # the previous line would need to change depending on your # data ax.autoscale_view(scalex=False,scaley=True) plt.draw() ax.callbacks.connect('xlim_changed',cb) plt.xlim(0,30) # for the next line to work in ipython you'll need to # paste/or cpaste this entire script, or just pause before # changing the xlim again to verify that it works as intended raw_input(press return for to rescale) plt.xlim(0,55) best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 signature.asc Description: Digital signature -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Qt4 on OSX
OK, thanks. I got the same behavior using Python (instead of ipython). Non-interactive usage has not yet been implemented in the MacOSX backend. We should be able to fix the bug that you found when implementing interactive/non-interactive usage for the MacOSX backend. Thanks, --Michiel. --- On Wed, 3/23/11, Daniel Welling dantwell...@gmail.com wrote: From: Daniel Welling dantwell...@gmail.com Subject: Re: [Matplotlib-users] Qt4 on OSX To: Michiel de Hoon mjldeh...@yahoo.com Cc: matplotlib-users@lists.sourceforge.net Date: Wednesday, March 23, 2011, 12:27 PM Greetings again, Michiel. Please excuse my slow response time... First, thanks for explaining the Framework stuff; it clarifies situation. I'll be sure to never blame the OSX backend where it is not warranted! Unfortunately (in terms of easy explanations):In [3]: MacOS.WMAvailable()Out[3]: True crap. Fortunately, I've been able to nail down the problem: bash-3.2$ ipythonPython 2.6.6 (r266:84292, Jan 18 2011, 14:07:55) Type copyright, credits or license for more information. IPython 0.10.1 -- An enhanced Interactive Python. ? - Introduction and overview of IPython's features.%quickref - Quick reference.help - Python's own help system.object? - Details about 'object'. ?object also works, ?? prints more. In [2]: import matplotlib.pyplot as pltIn [3]: plt.plot([0,1])Out[3]: [matplotlib.lines.Line2D object at 0x118c6be90]In [4]: plt.show()(Here, saving the plot works like normal.) In [5]: plt.ion()In [6]: plt.plot([0,1])Out[6]: [matplotlib.lines.Line2D object at 0x118c8bc90](Now, when trying to save the plot, the save and cancel buttons no longer respond. I must kill python from another terminal.) So that's the situation with OSX. It's something that comes up frequently enough (typically a quick plot turns into a more thorough customization followed by the lockup) that TK becomes a more viable option for me though OSX is faster and has better file navigation features. Again, if QT4 was working, that is certainly my weapon of choice... On Mon, Mar 21, 2011 at 7:14 AM, Michiel de Hoon mjldeh...@yahoo.com wrote: --- On Sun, 3/20/11, Daniel Welling dantwell...@gmail.com wrote: The OSX backend used to have a bug where you cannot type a name in the file name text box.Since that has been fixed, ... That was not a bug in the MacOSX backend (and therefore was not fixed), but is related to how Python is installed on your system: If your Python is not a framework installation, it will not interact correctly with Apple's windowing manager. This is due to OS X itself and is independent of the MacOSX backend. I have found a new bug: every so often, when you go to save a file, the save and cancel button stop responding, trapping the user in file saving limbo. I'll have to play with it again to figure out what triggers this. Can you check if your Python is built as a framework? If it is, MacOS.WMAvailable() should return True: $ python Python 2.7.1 (r271:86832, Mar 12 2011, 13:44:53) [GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin Type help, copyright, credits or license for more information. import MacOS MacOS.WMAvailable() True Best, --Michiel. -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] colorbar and scilimits
Unfortunately, ticks in colorbar axes work differently. Use something like below instead. cb.formatter.set_scientific(True) cb.formatter.set_powerlimits((0,4)) cb.update_ticks() Regards, -JJ On Mon, Mar 21, 2011 at 11:26 PM, johanngoetz jgo...@ucla.edu wrote: Is there a way to set the style and scilimits to the colorbar axes? All my attempts failed. For example, run the following script, I get the error shown below: ### begin example script import numpy from matplotlib import pyplot n = 500 x = numpy.random.standard_normal(n) y = 2.0 + 3.0 * x + 4.0 * numpy.random.standard_normal(n) xmin = x.min() xmax = x.max() ymin = y.min() ymax = y.max() hist, edges = numpy.histogramdd([y,x], bins=[25,25], range=[[ymin,ymax], [xmin,xmax]]) extent = [xmin, xmax, ymin, ymax] fig = pyplot.figure() ax = fig.add_subplot(1,1,1) plt = ax.imshow(hist, extent = extent, origin = 'lower', interpolation = 'nearest', aspect = 'auto') cb = fig.colorbar(plt, ax=ax) # This causes an AttributeError exception cb.ax.ticklabel_format(style='sci', scilimits=(0,4)) pyplot.show() ### end example script python cb_scilim_test.py Traceback (most recent call last): File cb_scilim_test.py, line 25, in module cb.ax.ticklabel_format(style='sci', scilimits=(0,4)) File /usr/lib64/python2.7/site-packages/matplotlib/axes.py, line 2117, in ticklabel_format This method only works with the ScalarFormatter.) AttributeError: This method only works with the ScalarFormatter. -- View this message in context: http://old.nabble.com/colorbar-and-scilimits-tp31201133p31201133.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Changing xlabel/ylabel position
If you want full control of label coordinates, you need to use Axis.set_label_coords method. For example, ax = gca() ax.xaxis.set_label_coords(0.5, -0.1) And alternative way is to adjust the padding between the axis and the label. ax.xaxis.labelpad = 0 Regards, -JJ On Mon, Mar 21, 2011 at 3:27 AM, andes czuni...@yahoo.com wrote: x = linspace(0,1,10) y = x**2 plot(x, y) xlabel('xname', position=(0.5,0.1)) #-- ylabel('yname', position=(0.1,0.5)) #-- -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] some explanatory text with legend
The position of the legend is determined at drawing time, so it is a bit tricky to get it right. I recommend you to use annotate instead. ax = subplot(111) ax.plot([1,2,3], label=u=2,p=3) leg = ax.legend() ann = ax.annotate(Test 2, xy=(0.5, 1.), xycoords=leg.get_frame(), xytext=(0,10), textcoords=offset points, va=center, ha=left, ) ann.set_zorder(leg.get_zorder()+0.1) # the zorder of ann must be higher than leg so that the position of leg is known when ann gets drawn See here for some more details. http://matplotlib.sourceforge.net/users/annotations_guide.html#using-complex-coordinate-with-annotation Regards, -JJ On Fri, Mar 18, 2011 at 8:31 PM, Neal Becker ndbeck...@gmail.com wrote: My legend is going to have a series of entries that look like: u=2,p=3 u=1,p=4 ... I want to add some (short) text that explains what u and p are. I'm thinking to get the coordinates of the legend box so I can then annotate? How would I get the coordinates of the legend box? Or is there some better/easier way to do what I want? -- Colocation vs. Managed Hosting A question and answer guide to determining the best fit for your organization - today and in the future. http://p.sf.net/sfu/internap-sfd2d ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Enable your software for Intel(R) Active Management Technology to meet the growing manageability and security demands of your customers. Businesses are taking advantage of Intel(R) vPro (TM) technology - will your software be a part of the solution? Download the Intel(R) Manageability Checker today! http://p.sf.net/sfu/intel-dev2devmar ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users