SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S


1
(9)
2
(8)
3
4
(6)
5
6
7
(41)
8
(18)
9
(25)
10
(18)
11
(10)
12
(13)
13
(7)
14
(4)
15
(12)
16
(6)
17
(9)
18
(7)
19
(2)
20
(5)
21
(7)
22
(2)
23
(11)
24
(11)
25
(14)
26
(3)
27
(3)
28
(17)
29
(7)
30
(16)
31
(8)


Showing results of 290

<< < 1 2 3 4 5 6 .. 12 > >> (Page 4 of 12)
From: Jae-Joon L. <lee...@gm...> - 2011年03月24日 03:51:35
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 <czu...@ya...> 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)) #<------
From: Jae-Joon L. <lee...@gm...> - 2011年03月24日 03:35:21
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 <jg...@uc...> 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 = 5000000
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Michiel de H. <mjl...@ya...> - 2011年03月23日 20:34:48
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 <dan...@gm...> wrote:
From: Daniel Welling <dan...@gm...>
Subject: Re: [Matplotlib-users] Qt4 on OSX
To: "Michiel de Hoon" <mjl...@ya...>
Cc: mat...@li...
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 <mjl...@ya...> wrote:
--- On Sun, 3/20/11, Daniel Welling <dan...@gm...> 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.
 
 
From: Paul I. <piv...@gm...> - 2011年03月23日 19:58:17
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 min&max for only the parts of the data that
are withing some range (as apposed to the min&max 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 
From: C M <cmp...@gm...> - 2011年03月23日 19:46:33
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)
From: Adrian H. <adr...@es...> - 2011年03月23日 18:42:25
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
From: Daniel W. <dan...@gm...> - 2011年03月23日 16:27:50
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 <mjl...@ya...>wrote:
> --- On *Sun, 3/20/11, Daniel Welling <dan...@gm...>* 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.
>
>
>
From: Warren W. <war...@en...> - 2011年03月23日 14:46:03
On Wed, Mar 23, 2011 at 8:43 AM, Sean Lake <ody...@gm...> 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
> 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)
>
> /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)
>
> /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'
>
>
>
> ------------------------------------------------------------------------------
> 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
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Sean L. <ody...@gm...> - 2011年03月23日 13:43:32
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)
/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)
/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'
From: David C. <dc...@ne...> - 2011年03月23日 13:40:30
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
From: Catherine T. <cab...@gm...> - 2011年03月23日 10:05:33
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([14000000, 22000000, 3500000, 3000000, 2700000])
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([14000000, 22000000, 3500000, 3000000, 2700000])
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
From: Paul I. <piv...@gm...> - 2011年03月23日 03:56:07
Sachin Kumar Sharma, on 2011年03月23日 02:44, wrote:
> BB,
> 
> I am Xploting two variables using
> Plot(a,b,'o')
> 
> Is it possible to color code the same plot with a 3rd property c instead of color we specify.
> 
> Also advise if it is possible to do 3D Xplot in matplotlib for variables a,b, & c and if possible to color code this 3d plot with 4th variable d.
Sashin,
use scatter(a,b,c=c, marker='o') to set the color of individual point.
There's even an 's' parameter with which you can individually set
the size of the marker.
npts = 100
a = np.random.rand(npts)
b = np.random.rand(npts)
c = np.random.rand(npts)
d = np.random.rand(npts)
plt.scatter(a,b,c=c,s=c*100, marker='o')
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Sachin K. S. <SSh...@sl...> - 2011年03月23日 03:03:18
BB,
I am Xploting two variables using
Plot(a,b,'o')
Is it possible to color code the same plot with a 3rd property c instead of color we specify.
Also advise if it is possible to do 3D Xplot in matplotlib for variables a,b, & c and if possible to color code this 3d plot with 4th variable d.
Cheers
Sachin
************************************************************************
Sachin Kumar Sharma
Senior Geomodeler
From: Paul I. <piv...@gm...> - 2011年03月22日 22:05:01
Catherine Thwaites, on 2011年03月23日 10:10, wrote:
> I have tried to search for the answer but have not found anything useful so
> forgive me if this has been answered before.
> I want to change the linestyle of a regular plot to an arrow, in the
> direction of the data in the tuple. So in this script below I would like an
> arrow head pointing to the next marker.
> There does not seem to be a line style to do it, but is there a way I can
> add the head at the correct end of the line?
Hi Catherine,
here's one way to get the type of plot you desire, and you might
also consider using a series of annotation with arrows to get a
similar effect:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
labels=('91','92','93','94','95')
data1 = np.array([2500, 3000, 3500, 3000, 2700])
data2 = np.array([200, 250, 270, 320, 250])
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], np.diff(data1), np.diff(data2)):
 ax.arrow(x,y,dx,dy, head_width=10, length_includes_head=True)
ax.set_ylim(0, 350)
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.axis('equal')
plt.show()
best,
-- 
Paul Ivanov
314 address only used for lists, off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 
From: Catherine T. <cab...@gm...> - 2011年03月22日 21:10:24
I have tried to search for the answer but have not found anything useful so
forgive me if this has been answered before.
I want to change the linestyle of a regular plot to an arrow, in the
direction of the data in the tuple. So in this script below I would like an
arrow head pointing to the next marker.
There does not seem to be a line style to do it, but is there a way I can
add the head at the correct end of the line?
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
labels=('91','92','93','94','95')
data1 = (2500, 3000, 3500, 3000, 2700)
data2 = (200, 250, 270, 320, 250)
fig = plt.figure()
ax = fig.add_subplot(111)
p = ax.plot(data1, data2, 'bo', linestyle='-', markersize=3)
ax.set_ylim(0, 350)
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()
Catherine
From: Edward G. <Edw...@me...> - 2011年03月21日 21:28:06
Following the advice to ping you on the mailing list, I've submitted a 
suggestion for a patch to the EMF Backend. I've copied the contents 
here for convenience.
Patch ID is: 3232997
Content is:
With Matplotlib 1.0.1, When plotting a patch (e.g. text with a bbox with 
facecolor), the facecolor of the patch is passed to the backend as RGBa. 
EMFBrush can't handle RGBa and dies with the following:
File "/usr/local/lib/python2.7/dist-packages/matplotlib/patches.py", 
line 411, in draw
renderer.draw_path(gc, tpath, affine, rgbFace)
File 
"/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_emf.py", 
line 260, in draw_path
self.select_brush(rgbFace)
File 
"/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_emf.py", 
line 567, in select_brush
brush=EMFBrush(self.emf,rgb)
File 
"/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_emf.py", 
line 107, in __init__
r,g,b=rgb
ValueError: too many values to unpack
Suggested patch is to change line 107 in backend_emf.py from r,g,b=rgb to:
r,g,b=rgb[:3]
which will drop the alpha channel. Given the EMF backend doesn't support 
alpha channels, it shouldn't cause any problems to do this silently.
From: johanngoetz <jg...@uc...> - 2011年03月21日 14:26:28
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 = 5000000
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.
From: Michiel de H. <mjl...@ya...> - 2011年03月21日 13:14:41
--- On Sun, 3/20/11, Daniel Welling <dan...@gm...> 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.
 
From: Rohaq <ro...@de...> - 2011年03月21日 04:30:49
I've been visualising some data using the pyplot fill function, and whilst
overlapping polygons do mix their colours and allow for any overlaps to be
apparent, I thought that perhaps this would look much better in a heatmap
format to better show high levels of change in the same areas.
I've tested this using the histogram2d function in numpy using various
online examples, and whilst experiments with random data looked nice enough,
each set of results data is basically a series of 0's and 1's: In a heatmap
using the same code, this results in an incredibly long (since there's about
65000 results) heatmap that's only a pixel or two in height. Also, I can't
seem to use the tools to zoom in and navigate around this, which is pretty
much a requirement given the large number of data rows.
Does anyone know if there's a way to convert a series of polygon objects
into a decent looking heatmap? Any help is appreciated!
Cheers!
*Rohaq*
From: Daniel W. <dan...@gm...> - 2011年03月21日 02:32:42
Hello, Michiel.
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, 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. Other than that, the OSX backend
is light and quick, which is nice. When QT4 is working, however, I prefer
that. Sorry I can't give you more details; I'll see if I can get a clearer
picture.
-dw
On Sun, Mar 20, 2011 at 1:31 AM, Michiel de Hoon <mjl...@ya...>wrote:
> --- On *Wed, 3/16/11, Daniel Welling <dan...@gm...>* wrote:
>
> After playing with backends quite a bit, I have found that the best one in
> terms of speed, robustness, and features is Qt4Agg - especially on OSX,
> where the MacOSX backend is buggy and many others just don't plain work.
>
> Why do you think that the MacOSX backend is buggy?
>
> --Michiel.
>
>
>
>
>
>
From: Darren D. <dsd...@gm...> - 2011年03月21日 01:59:35
On Sun, Mar 20, 2011 at 8:52 PM, Xavier Gnata <xav...@gm...> wrote:
> On 03/20/2011 07:19 PM, Darren Dale wrote:
>>
>> On Sun, Mar 20, 2011 at 2:08 PM, Xavier Gnata<xav...@gm...>
>> wrote:
>>>
>>> Hi,
>>>
>>> It looks like the
>>> http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/branches/py3k/
>>> in dead.
>>> The last commit was 8months ago.
>>>
>>> Numpy is ok with python3.1, scipy is ok, nose is ok, ipython is usable.
>>> Ubuntu already provides python-tk for python3.x
>>> It would be nice to port matplotlib to python3.
>>> Is there a plan? another svn/git branch?
>>
>> https://github.com/matplotlib/matplotlib-py3
>
> Thanks!
> AFAICS it works already well with the tk backend :)
> Are you interested in more testing with another backend?
Mike D. put a wiki page together summarizing where things stand and
listing outstanding issues:
https://github.com/matplotlib/matplotlib-py3/wiki
From: Xavier G. <xav...@gm...> - 2011年03月21日 00:53:07
On 03/20/2011 07:19 PM, Darren Dale wrote:
> On Sun, Mar 20, 2011 at 2:08 PM, Xavier Gnata<xav...@gm...> wrote:
>> Hi,
>>
>> It looks like the
>> http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/branches/py3k/
>> in dead.
>> The last commit was 8months ago.
>>
>> Numpy is ok with python3.1, scipy is ok, nose is ok, ipython is usable.
>> Ubuntu already provides python-tk for python3.x
>> It would be nice to port matplotlib to python3.
>> Is there a plan? another svn/git branch?
> https://github.com/matplotlib/matplotlib-py3
Thanks!
AFAICS it works already well with the tk backend :)
Are you interested in more testing with another backend?
Xavier
Hi all,
I am using Matplotlib 1.0.1 and am seeing weird behaviour with mplot3d and 
ticker formatters, and I think I need to submit a patch to axes3d, but am not 
sure how much it will break, because format_zdata() and format_coord() look to 
be defined inconsistently.
When trying to rotate a plot, which was created including the following 
commands,
 ...
 ax.plot(x[0,alow:atop],x[1,alow:atop],x[2,alow:atop],c=rgb.tolist())
 ax.w_xaxis.set_major_locator(tic.LinearLocator(3))
 ax.w_xaxis.set_major_formatter(tic.FormatStrFormatter(''))
 ax.w_yaxis.set_major_locator(tic.LinearLocator(3))
 ax.w_yaxis.set_major_formatter(tic.FormatStrFormatter(''))
 ax.w_zaxis.set_major_locator(tic.LinearLocator(3))
 ax.w_zaxis.set_major_formatter(tic.FormatStrFormatter(''))
 plt.draw()
 ...
I received the following backtrace and error message:
/usr/lib64/python2.6/site-packages/matplotlib/backend_bases.pyc in 
mouse_move(self, event)
 2393 if event.inaxes and event.inaxes.get_navigate():
 2394 
-> 2395 try: s = event.inaxes.format_coord(event.xdata, 
event.ydata)
 2396 except ValueError: pass
 2397 except OverflowError: pass
/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.pyc in 
format_coord(self, xd, yd)
 474 
 475 xs = self.format_xdata(x)
--> 476 ys = self.format_ydata(y)
 477 zs = self.format_ydata(z)
 478 return 'x=%s, y=%s, z=%s' % (xs, ys, zs)
/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.pyc in 
format_ydata(self, y)
 424 except TypeError:
 425 fmt = self.w_yaxis.get_major_formatter()
--> 426 return sensible_format_data(fmt, y)
 427 
 428 def format_zdata(self, z):
/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.pyc in 
sensible_format_data(self, value)
 26 if abs(value) > 1e4 or abs(value)<1e-3:
 27 s = '%1.4e' % value
---> 28 return self._formatSciNotation(s)
 29 else:
 30 return '%4.3f' % value
AttributeError: FormatStrFormatter instance has no attribute 
'_formatSciNotation'
---
I am using FormatStrFormatter('') to try to obtain an empty tick.
[1] It looks like sensible_format_data() assumes that self is class 
ScalarFormatter(Formatter), since this is the only ticker Formatter that has 
attribute _formatSciNotation(s). As far as I can tell, this means that 
sensible_format_data(fmt,y) should *only* be called if fmt has class 
ScalarFormatter(Formatter).
[2] In axes3d.py, I see:
 def format_zdata(self, z):
 """
 Return z string formatted. This function will use the attribute
 self.fmt_zdata if it is callable, else will fall back on the yaxis
 major formatter
 """
 try:
 return self.fmt_zdata(z)
 except (AttributeError, TypeError):
 fmt = self.w_zaxis.get_major_formatter()
 return sensible_format_data(fmt, z)
To me, it looks like the call to sensible_format_data(fmt, z) is wrong. The 
same error occurs in format_xdata() and format_ydata(). So I would like to 
submit a patch for format_xdata(), format_ydata(), format_zdata(), e.g.:
 def format_zdata(self, z):
 """
 Return z string formatted. This function will use the attribute
 self.fmt_zdata if it is callable, else will fall back on the zaxis
 major formatter
 """
 try:
 return self.fmt_zdata(z)
 except (AttributeError, TypeError):
 fmt = self.w_zaxis.get_major_formatter()
 try:
 return sensible_format_data(fmt, z)
 except (AttributeError, TypeError):
 return format_data(fmt, z)
[3] But I am also worried about the comment "else will fall back on the yaxis 
major formatter". Shouldn't this say "the zaxis major formatter", since that 
is what the code does? Or should the code use the yaxis major formatter, since 
that is what the documentation says? The documentation 
http://matplotlib.github.com/mpl_toolkits/mplot3d/api.html agrees with the 
comment and not with the code.
[4] In def format_coord(self, xd, yd), I see
 xs = self.format_xdata(x)
 ys = self.format_ydata(y)
 zs = self.format_ydata(z)
Why doesn't the last line say 
 zs = self.format_zdata(z)
?
Best, Paul
From: andes <czu...@ya...> - 2011年03月20日 18:27:58
Hello all,
I am trying to change the position of the xlabel/ylabel with respect to the
xaxis/yaxis. Particularly, I was trying to get the "xlabel" closer to the
"xaxis" and the "ylabel" closer to the "yaxis", for which I was using the
lines indicated with '#<-------' in the following sample code:
#----
from pylab import *
from numpy import *
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)) #<------
#----
My understanding was that "position=(xpos,ypos)" would place the label
anywhere I wanted, though there is problem. Let me take "xlabel" as an
example. I can successfully move the "xlabel" parallel to the "xaxis" by
setting the quantity "xpos" anywhere from 0 to 1 (0.5 being the center of
the "xaxis"). However, for moving the "xlabel" closer to or further from the
"xaxis" I change the value of "ypos" but it does NOT do anything, i.e. the
"xlabel" stays at the same distance from the "xaxis". The equivalent problem
occurs with the "ylabel", i.e. I can move "ylabel" parallel to the "yaxis"
but I cannot get it any closer.
I am aware that I can "create a label" and place it anywhere by using the
text() command. Yet, it would be better if I can get the label placement
done with the xlabel/ylabel command so that I can eventually control the
label placement via rcParams.update().
Many thanks in advance.
carlo
-- 
View this message in context: http://old.nabble.com/Changing-xlabel-ylabel-position-tp31195337p31195337.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Darren D. <dsd...@gm...> - 2011年03月20日 18:19:34
On Sun, Mar 20, 2011 at 2:08 PM, Xavier Gnata <xav...@gm...> wrote:
> Hi,
>
> It looks like the
> http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/branches/py3k/
> in dead.
> The last commit was 8months ago.
>
> Numpy is ok with python3.1, scipy is ok, nose is ok, ipython is usable.
> Ubuntu already provides python-tk for python3.x
> It would be nice to port matplotlib to python3.
> Is there a plan? another svn/git branch?
https://github.com/matplotlib/matplotlib-py3
9 messages has been excluded from this view by a project administrator.

Showing results of 290

<< < 1 2 3 4 5 6 .. 12 > >> (Page 4 of 12)
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /