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
(6)
2
(29)
3
(19)
4
(6)
5
(5)
6
(9)
7
(9)
8
(19)
9
(14)
10
(19)
11
(26)
12
(10)
13
(26)
14
(22)
15
(19)
16
(17)
17
(16)
18
(2)
19
20
(1)
21
(1)
22
(10)
23
(11)
24
(17)
25
(6)
26
(1)
27
28
(9)
29
(9)
30
(9)



Showing results of 339

<< < 1 .. 8 9 10 11 12 .. 14 > >> (Page 10 of 14)
From: Russell E. O. <ro...@uw...> - 2011年11月09日 19:23:12
In article <629...@pi...>,
 Bedartha Goswami <go...@pi...> 
 wrote:
> Hi,
> 
> I have recently installed Python 32/64bit from Python.org and then I 
> proceeded to install bumpy, scipy, matplotlib and igraph on it. But the 
> Matplotlib does not show the plots even if it opens a Figure window. Here is 
> a summary of what I had done in my installation:
> -----
> I first did a "clean install" by following the instructions at (with an idea 
> to reinstall Matplotlib and see if the rror repeats):
> http://matplotlib.sourceforge.net/faq/installing_faq.html#clean-install
> -----
> So now my python does not have matplotlib:
> 
> Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
> Bedarthas-MacBook-Air:Desktop bedartha$ python
> Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named matplotlib
> >>> 
> Bedarthas-MacBook-Air:Desktop bedartha$
> -----
> Then I downloaded (again) the DMG file at: 
> http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/m
> atplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg/download
> -----
> and installed Matplotlib (which seems to go through fine). But after that:
> 
> Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
> Bedarthas-MacBook-Air:Desktop bedartha$ python
> Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
I suspect you are trying to install matplotlib on the 64-bit Python 
instead of the 32-bit python for which it was built
I say this because 32-bit python is built using GCC 4.0.1.
There is no matplotlib binary for 64-bit Python yet because I've not 
figured out how to build one successfully -- I get horrible conflicts 
with Tcl/Tk.
-- Russell
From: Benjamin R. <ben...@ou...> - 2011年11月09日 16:53:53
On Tue, Nov 8, 2011 at 11:15 AM, Bedartha Goswami <go...@pi...>wrote:
> Hi,
>
> I have recently installed Python 32/64bit from Python.org and then I
> proceeded to install bumpy, scipy, matplotlib and igraph on it. But the
> Matplotlib does not show the plots even if it opens a Figure window. Here
> is a summary of what I had done in my installation:
> -----
> I first did a "clean install" by following the instructions at (with an
> idea to reinstall Matplotlib and see if the rror repeats):
> http://matplotlib.sourceforge.net/faq/installing_faq.html#clean-install
> -----
> So now my python does not have matplotlib:
>
> Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
> Bedarthas-MacBook-Air:Desktop bedartha$ python
> Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ImportError: No module named matplotlib
> >>>
> Bedarthas-MacBook-Air:Desktop bedartha$
> -----
> Then I downloaded (again) the DMG file at:
>
> http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg/download
> -----
> and installed Matplotlib (which seems to go through fine). But after that:
>
> Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
> Bedarthas-MacBook-Air:Desktop bedartha$ python
> Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib as mpl
> >>> from pylab import *
> >>> plot([1,2,3])
> [<matplotlib.lines.Line2D object at 0x2f87fb0>]
> >>> show()
> Exception in Tkinter callback
> Traceback (most recent call last):
> File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py",
> line 1410, in __call__
> return self.func(*args)
> File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py",
> line 236, in resize
> self.show()
> File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py",
> line 240, in draw
> tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
> File
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py",
> line 19, in blit
> tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode,
> id(bbox_array))
> TclError
> >>>
> Bedarthas-MacBook-Air:Desktop bedartha$
> -----
> Here is the essential info about my machine and my Python and Matplotlib
> versions:
>
> Bedarthas-MacBook-Air:~ bedartha$ uname -a
> Darwin Bedarthas-MacBook-Air.local 11.0.1 Darwin Kernel Version 11.0.1:
> Wed Jun 29 19:53:22 PDT 2011; root:xnu-1699232~1/RELEASE_X86_64 x86_64
> -----
> Bedarthas-MacBook-Air:Desktop bedartha$ python
> Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34)
> [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import matplotlib as mpl
> >>> mpl.__version__
> '1.1.0'
> >>>
> Bedarthas-MacBook-Air:Desktop bedartha$
> -----
> I also have the following alias (in ~/.bash_profile) for my Python2.7 (to
> deal with some issues in igraph):
>
> alias python="arch -i386 python"
> -----
>
> Can anyone please help me out?
>
> Best regards,
> and apologies for the lengthy post,
>
> Bedartha
>
>
As a test, try to set your backend to either 'cocoaagg' or 'macosx' like so:
import matplotlib as mpl
mpl.use('cocoaagg')
There have been issues with TkAgg on macs. I have personally not had any
success with it (even with ActiveState's Tcl).
Ben Root
From: Joe K. <jki...@wi...> - 2011年11月09日 16:32:53
On Wed, Nov 9, 2011 at 10:20 AM, Howard <ho...@re...> wrote:
> On 11/9/11 11:13 AM, Joe Kington wrote:
>
> On Wed, Nov 9, 2011 at 10:07 AM, Howard <ho...@re...> wrote:
>
>> Hi all
>>
>> I'm a new user to matplotlib, and I'm having a little difficulty with
>> something I feel must be basic. When I plot our data, I'm using a canvas
>> that is 4"x4" at 128 DPI and saving the canvas as a png. Here's the basics
>> of the code:
>>
>> imageWidth = 4
>> imageHeight = 4
>> DPI = 128
>>
>> figure1 = plt.figure(figsize=(imageWidth,imageHeight))
>> plt.axis("off")
>> plt.tricontourf(theTriangulation,
>> modelData,
>> theLookupTable.N,
>> cmap=theLookupTable)
>> canvas = FigureCanvasAgg(figure1)
>> canvas.print_figure(prefix + ".png", dpi=DPI)
>>
>> The png is 512x512 as I would expect, but the contoured image doesn't
>> fill the whole image. How do I tell the library to map the plotted are to
>> the entire canvas and not leave a border around the rendered image?
>>
>
> You need to make an axis that fills up the entire figure.
>
> By default, axes don't fill up the entire figure to leave room for tick
> labels, axis lables, titles, etc.
>
> Try something like:
>
> import matplotlib as plt
>
> dpi = 128
> fig = plt.figure(figsize=(4,4))
>
> # Specifies an axis at 0, 0 with a width and height of 1 (the full width
> of the figure)
> ax = fig.add_axes([0,0,1,1])
>
> ax.tricontourf(...)
>
> fig.savefig('output.png', dpi=dpi)
>
> Hope that helps,
> -Joe
>
> Hi Joe
>
> That did it! Thanks much. Can I also turn off the tick marks on the new
> axis?
>
>
Sure! If you want an exact duplicate of your original code snippet, just
add an:
ax.axis('off')
or one of the many equivalent ways of hiding the entire axis.
If you'd rather keep the outline and white background patch, but just turn
the ticks off, then you can do something like:
for axis in [ax.xaxis, ax.yaxis]:
 ax.set_ticks([])
or similarly:
ax.tick_params(color='none')
Also, as you've probably already noticed, I meant to have "import
matplotlib.pyplot as plt" in my first reply, rather than "import matplotlib
as plt".
Cheers!
From: Howard <ho...@re...> - 2011年11月09日 16:32:01
On 11/9/11 11:20 AM, Howard wrote:
> On 11/9/11 11:13 AM, Joe Kington wrote:
>> On Wed, Nov 9, 2011 at 10:07 AM, Howard <ho...@re... 
>> <mailto:ho...@re...>> wrote:
>>
>> Hi all
>>
>> I'm a new user to matplotlib, and I'm having a little difficulty
>> with something I feel must be basic. When I plot our data, I'm
>> using a canvas that is 4"x4" at 128 DPI and saving the canvas as
>> a png. Here's the basics of the code:
>>
>> imageWidth = 4
>> imageHeight = 4
>> DPI = 128
>>
>> figure1 = plt.figure(figsize=(imageWidth,imageHeight))
>> plt.axis("off")
>> plt.tricontourf(theTriangulation,
>> modelData,
>> theLookupTable.N,
>> cmap=theLookupTable)
>> canvas = FigureCanvasAgg(figure1)
>> canvas.print_figure(prefix + ".png", dpi=DPI)
>>
>> The png is 512x512 as I would expect, but the contoured image
>> doesn't fill the whole image. How do I tell the library to map
>> the plotted are to the entire canvas and not leave a border
>> around the rendered image?
>>
>>
>> You need to make an axis that fills up the entire figure.
>>
>> By default, axes don't fill up the entire figure to leave room for 
>> tick labels, axis lables, titles, etc.
>>
>> Try something like:
>>
>> import matplotlib as plt
>>
>> dpi = 128
>> fig = plt.figure(figsize=(4,4))
>>
>> # Specifies an axis at 0, 0 with a width and height of 1 (the full 
>> width of the figure)
>> ax = fig.add_axes([0,0,1,1])
>>
>> ax.tricontourf(...)
>>
>> fig.savefig('output.png', dpi=dpi)
>>
>> Hope that helps,
>> -Joe
> Hi Joe
>
> That did it! Thanks much. Can I also turn off the tick marks on the 
> new axis?
>
> Howard
 For the sake of reply, this seems to work to get rid of the tick marks:
ax.tick_params(axis="both", length=0, width=0)
Thanks
Howard
>
> -- 
> Howard Lander <mailto:ho...@re...>
> Senior Research Software Developer
> Renaissance Computing Institute (RENCI) <http://www.renci.org>
> The University of North Carolina at Chapel Hill
> Duke University
> North Carolina State University
> 100 Europa Drive
> Suite 540
> Chapel Hill, NC 27517
> 919-445-9651
-- 
Howard Lander <mailto:ho...@re...>
Senior Research Software Developer
Renaissance Computing Institute (RENCI) <http://www.renci.org>
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651
From: Howard <ho...@re...> - 2011年11月09日 16:20:13
On 11/9/11 11:13 AM, Joe Kington wrote:
> On Wed, Nov 9, 2011 at 10:07 AM, Howard <ho...@re... 
> <mailto:ho...@re...>> wrote:
>
> Hi all
>
> I'm a new user to matplotlib, and I'm having a little difficulty
> with something I feel must be basic. When I plot our data, I'm
> using a canvas that is 4"x4" at 128 DPI and saving the canvas as a
> png. Here's the basics of the code:
>
> imageWidth = 4
> imageHeight = 4
> DPI = 128
>
> figure1 = plt.figure(figsize=(imageWidth,imageHeight))
> plt.axis("off")
> plt.tricontourf(theTriangulation,
> modelData,
> theLookupTable.N,
> cmap=theLookupTable)
> canvas = FigureCanvasAgg(figure1)
> canvas.print_figure(prefix + ".png", dpi=DPI)
>
> The png is 512x512 as I would expect, but the contoured image
> doesn't fill the whole image. How do I tell the library to map
> the plotted are to the entire canvas and not leave a border around
> the rendered image?
>
>
> You need to make an axis that fills up the entire figure.
>
> By default, axes don't fill up the entire figure to leave room for 
> tick labels, axis lables, titles, etc.
>
> Try something like:
>
> import matplotlib as plt
>
> dpi = 128
> fig = plt.figure(figsize=(4,4))
>
> # Specifies an axis at 0, 0 with a width and height of 1 (the full 
> width of the figure)
> ax = fig.add_axes([0,0,1,1])
>
> ax.tricontourf(...)
>
> fig.savefig('output.png', dpi=dpi)
>
> Hope that helps,
> -Joe
Hi Joe
That did it! Thanks much. Can I also turn off the tick marks on the new 
axis?
Howard
-- 
Howard Lander <mailto:ho...@re...>
Senior Research Software Developer
Renaissance Computing Institute (RENCI) <http://www.renci.org>
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651
From: Joe K. <jki...@wi...> - 2011年11月09日 16:13:55
On Wed, Nov 9, 2011 at 10:07 AM, Howard <ho...@re...> wrote:
> Hi all
>
> I'm a new user to matplotlib, and I'm having a little difficulty with
> something I feel must be basic. When I plot our data, I'm using a canvas
> that is 4"x4" at 128 DPI and saving the canvas as a png. Here's the basics
> of the code:
>
> imageWidth = 4
> imageHeight = 4
> DPI = 128
>
> figure1 = plt.figure(figsize=(imageWidth,imageHeight))
> plt.axis("off")
> plt.tricontourf(theTriangulation,
> modelData,
> theLookupTable.N,
> cmap=theLookupTable)
> canvas = FigureCanvasAgg(figure1)
> canvas.print_figure(prefix + ".png", dpi=DPI)
>
> The png is 512x512 as I would expect, but the contoured image doesn't fill
> the whole image. How do I tell the library to map the plotted are to the
> entire canvas and not leave a border around the rendered image?
>
You need to make an axis that fills up the entire figure.
By default, axes don't fill up the entire figure to leave room for tick
labels, axis lables, titles, etc.
Try something like:
import matplotlib as plt
dpi = 128
fig = plt.figure(figsize=(4,4))
# Specifies an axis at 0, 0 with a width and height of 1 (the full width of
the figure)
ax = fig.add_axes([0,0,1,1])
ax.tricontourf(...)
fig.savefig('output.png', dpi=dpi)
 Hope that helps,
-Joe
From: Howard <ho...@re...> - 2011年11月09日 16:07:55
Hi all
I'm a new user to matplotlib, and I'm having a little difficulty with 
something I feel must be basic. When I plot our data, I'm using a canvas 
that is 4"x4" at 128 DPI and saving the canvas as a png. Here's the 
basics of the code:
 imageWidth = 4
 imageHeight = 4
 DPI = 128
 figure1 = plt.figure(figsize=(imageWidth,imageHeight))
 plt.axis("off")
 plt.tricontourf(theTriangulation,
 modelData,
 theLookupTable.N,
 cmap=theLookupTable)
 canvas = FigureCanvasAgg(figure1)
 canvas.print_figure(prefix + ".png", dpi=DPI)
The png is 512x512 as I would expect, but the contoured image doesn't 
fill the whole image. How do I tell the library to map the plotted are 
to the entire canvas and not leave a border around the rendered image?
Thanks
Howard
-- 
Howard Lander <mailto:ho...@re...>
Senior Research Software Developer
Renaissance Computing Institute (RENCI) <http://www.renci.org>
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651
From: Brent P. <bpe...@gm...> - 2011年11月09日 15:37:56
Hi,
I have an image like this:
https://docs.google.com/open?id=0B7eMlcFeoB_rMTU1OTU0NmMtMzM3MC00YWI3LWFlNTYtNzg0MTM4MWI3OWMz
with an axes inside of another. I'd like to set the background behind
the labels of the inner figure.
I've tried set_frame_on on the axis, set_frameon on the figure,
axisbg_color, and so on.
How can I set the color being the axes labels.
thanks,
-Brent
From: Richard R. <rr...@fi...> - 2011年11月09日 14:50:52
Hi,
I read the legend guide, so when I did this:
ax.legend([Circle((0,0),1,fc='red')], ['red circle'])
I expected the symbol in the legend to be a red circle, but got a red
rectangle. In fact, no matter what artists I pass in as the first
argument, the legend shows rectangles (the colors are correct, though).
 Why?
Matplotlib 1.1.0, python 2.6/2.7 on linux.
thanks
-Rick
From: Skipper S. <jss...@gm...> - 2011年11月09日 04:19:50
On Tue, Nov 8, 2011 at 8:53 PM, Benjamin Root <ben...@ou...> wrote:
> On Tuesday, November 8, 2011, Skipper Seabold <jss...@gm...> wrote:
>> On Tue, Nov 8, 2011 at 6:13 PM, Benjamin Root <ben...@ou...> wrote:
>>>
>>> On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jss...@gm...>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> Two related questions. Consider this plot
>>>>
>>>> -----
>>>>
>>>> import matplotlib.pyplot as plt
>>>> from mpl_toolkits.mplot3d import Axes3D
>>>>
>>>> fig = plt.figure()
>>>> ax = fig.add_subplot(111, projection='3d')
>>>> ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])
>>>>
>>>> ax.set_xlim3d(0,1)
>>>> ax.set_ylim3d(0,1)
>>>> #ax.set_ylim3d(1,0)
>>>> ax.set_zlim3d(0,1)
>>>>
>>>> plt.show()
>>>>
>>>> -----
>>>>
>>>> I want to uncomment the line above to reverse the y axis, but as soon
>>>> as I do, the tick labels disappear on the y axis and the z axis tick
>>>> label padding changing. Is there another way to reverse the y axis, or
>>>> should I fix thing after the fact. If so, how can I do this? I don't
>>>> see a zaxis in rcParams.
>>>>
>>>
>>> The first would be a bug (could you please file one?). The second should
>>> probably be a feature request, but I wouldn't expect anything for that
>>> right
>>> away.
>>>
>>
>> 1. https://github.com/matplotlib/matplotlib/issues/570
>
> Thanks.
>
>> 2. Surely there's another workaround in the meantime? I've never
>> worked much with rcParams, going the long way instead, but now that
>> I've discovered it, it's my preferred way of doing things. Anyone have
>> any ideas?
>>
>
> The problem is that mplot3d doesn't query for any params yet. A lot of
> defaults are hard-coded. I would like to start adding defaults, but we will
> need to figure out a consistent naming scheme.
>
File under duh. The answer is just to adjust my plot coordinates
accordingly and fix the label. For example,
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
alpha = [4,4,2]
nobs = 2000
# draw the r.v.s
p1,p2,p3 = np.random.dirichlet(alpha, size=nobs).T
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
#NOTE: 1 - p2 to reverse the y-axis
ax.scatter(p1, 1-p2, p3, zdir='z',s=2)
# plot the simplex with adjusted y coordinates
ax.plot([1,0,0,1],[1,0,1,1],[0,0,1,0])
ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
# reverse the tick labels
ax.set_yticklabels([1.0, .8, .6, .4, .2, 0.0])
ax.set_zlim3d(0,1)
ax.set_title("Dirichlet(4,4,2) on the 2-simplex")
plt.show()
Skipper
From: questions a. <que...@gm...> - 2011年11月09日 03:06:19
thanks, will look at these options.
On Fri, Nov 4, 2011 at 10:21 AM, Matt S. <sle...@gm...> wrote:
> I've used Pyshapelib and Polygon to do this type of analysis in the past.
> Thuban may get ya what you need.
>
> On Thu, Nov 3, 2011 at 3:40 PM, questions anon <que...@gm...>wrote:
>
>> Hi All,
>> Is there a way to select only the values within a particular shapefile to
>> analyse.
>> I would like to do something like:
>>
>> array=numpyarraycoveringtemperatureofwholestate
>> shapefile=forestedregions.shp
>>
>> newarray=ma.masked_values(array, shapefile)
>> meantemperatureofforestedregions=MA.mean(newarray)
>> print meantemperatureofforestedregions
>>
>>
>> Any ideas of functions I could use, examples I could follow?
>> thanks
>>
>>
>> ------------------------------------------------------------------------------
>> RSA(R) Conference 2012
>> Save 700ドル by Nov 18
>> Register now
>> http://p.sf.net/sfu/rsa-sfdev2dev1
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
From: Benjamin R. <ben...@ou...> - 2011年11月09日 01:53:30
On Tuesday, November 8, 2011, Skipper Seabold <jss...@gm...> wrote:
> On Tue, Nov 8, 2011 at 6:13 PM, Benjamin Root <ben...@ou...> wrote:
>>
>> On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jss...@gm...>
wrote:
>>>
>>> Hi,
>>>
>>> Two related questions. Consider this plot
>>>
>>> -----
>>>
>>> import matplotlib.pyplot as plt
>>> from mpl_toolkits.mplot3d import Axes3D
>>>
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111, projection='3d')
>>> ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])
>>>
>>> ax.set_xlim3d(0,1)
>>> ax.set_ylim3d(0,1)
>>> #ax.set_ylim3d(1,0)
>>> ax.set_zlim3d(0,1)
>>>
>>> plt.show()
>>>
>>> -----
>>>
>>> I want to uncomment the line above to reverse the y axis, but as soon
>>> as I do, the tick labels disappear on the y axis and the z axis tick
>>> label padding changing. Is there another way to reverse the y axis, or
>>> should I fix thing after the fact. If so, how can I do this? I don't
>>> see a zaxis in rcParams.
>>>
>>
>> The first would be a bug (could you please file one?). The second should
>> probably be a feature request, but I wouldn't expect anything for that
right
>> away.
>>
>
> 1. https://github.com/matplotlib/matplotlib/issues/570
Thanks.
> 2. Surely there's another workaround in the meantime? I've never
> worked much with rcParams, going the long way instead, but now that
> I've discovered it, it's my preferred way of doing things. Anyone have
> any ideas?
>
The problem is that mplot3d doesn't query for any params yet. A lot of
defaults are hard-coded. I would like to start adding defaults, but we will
need to figure out a consistent naming scheme.
Ben Root
From: magurling <mag...@gm...> - 2011年11月09日 00:49:40
I want a legend without the black border. I've tried a few things that have
been suggested on this forum and elsewhere to no avail. According to what
I've seen, it should be as simple as:
import matplotlib.pyplot as plt
import numpy as np
N = 5
Means1 = (20, 35, 30, 35, 27)
Means2 = (25, 32, 34, 20, 25)
ind = np.arange(N) # the x locations for the groups
width = 0.20 # the width of the bars
fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, Means1, width, color='k')
rects2 = ax.bar(ind+width, Means2, width, color='w')
ax.legend( (rects1[0], rects2[0]), ('set1', 'set2'), frameon=False )
plt.show()
It all works except for "frameon=False"
I get this:
/usr/lib/pymodules/python2.7/matplotlib/axes.pyc in legend(self, *args,
**kwargs)
 4042 
 4043 handles = cbook.flatten(handles)
-> 4044 self.legend_ = mlegend.Legend(self, handles, labels,
**kwargs)
 4045 return self.legend_
 4046 
TypeError: __init__() got an unexpected keyword argument 'frameon'
I've also checked my matplotlibrc under the "Legend" section and I don't see
a "legend.frameon" line.
It must be something simple that I am doing wrong. Any ideas?
-- 
View this message in context: http://old.nabble.com/legend-border%2C-frameon-keyword-tp32807933p32807933.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Skipper S. <jss...@gm...> - 2011年11月08日 23:53:50
On Tue, Nov 8, 2011 at 6:13 PM, Benjamin Root <ben...@ou...> wrote:
>
> On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jss...@gm...> wrote:
>>
>> Hi,
>>
>> Two related questions. Consider this plot
>>
>> -----
>>
>> import matplotlib.pyplot as plt
>> from mpl_toolkits.mplot3d import Axes3D
>>
>> fig = plt.figure()
>> ax = fig.add_subplot(111, projection='3d')
>> ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])
>>
>> ax.set_xlim3d(0,1)
>> ax.set_ylim3d(0,1)
>> #ax.set_ylim3d(1,0)
>> ax.set_zlim3d(0,1)
>>
>> plt.show()
>>
>> -----
>>
>> I want to uncomment the line above to reverse the y axis, but as soon
>> as I do, the tick labels disappear on the y axis and the z axis tick
>> label padding changing. Is there another way to reverse the y axis, or
>> should I fix thing after the fact. If so, how can I do this? I don't
>> see a zaxis in rcParams.
>>
>
> The first would be a bug (could you please file one?). The second should
> probably be a feature request, but I wouldn't expect anything for that right
> away.
>
1. https://github.com/matplotlib/matplotlib/issues/570
2. Surely there's another workaround in the meantime? I've never
worked much with rcParams, going the long way instead, but now that
I've discovered it, it's my preferred way of doing things. Anyone have
any ideas?
Skipper
From: Benjamin R. <ben...@ou...> - 2011年11月08日 23:13:42
On Tue, Nov 8, 2011 at 4:55 PM, Skipper Seabold <jss...@gm...> wrote:
> Hi,
>
> Two related questions. Consider this plot
>
> -----
>
> import matplotlib.pyplot as plt
> from mpl_toolkits.mplot3d import Axes3D
>
> fig = plt.figure()
> ax = fig.add_subplot(111, projection='3d')
> ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])
>
> ax.set_xlim3d(0,1)
> ax.set_ylim3d(0,1)
> #ax.set_ylim3d(1,0)
> ax.set_zlim3d(0,1)
>
> plt.show()
>
> -----
>
> I want to uncomment the line above to reverse the y axis, but as soon
> as I do, the tick labels disappear on the y axis and the z axis tick
> label padding changing. Is there another way to reverse the y axis, or
> should I fix thing after the fact. If so, how can I do this? I don't
> see a zaxis in rcParams.
>
>
The first would be a bug (could you please file one?). The second should
probably be a feature request, but I wouldn't expect anything for that
right away.
Ben Root
From: Benjamin R. <ben...@ou...> - 2011年11月08日 23:09:44
On Tue, Nov 8, 2011 at 4:50 PM, Alejandro Weinstein <
ale...@gm...> wrote:
> Hi:
>
> I am trying to use the event associated to motion_notify_event in a 3D
> plot, and I found that the event does not have the zdata property.
>
> The following code illustrate the problem:
>
> ##################################
> from mpl_toolkits.mplot3d import Axes3D
> import matplotlib.pyplot as plt
>
> def on_hover(event):
> print dir(event)
>
> fig = plt.figure()
> ax = fig.add_subplot(111, projection='3d')
> x = [1, 2, 3]
> y = [1, 5, 4]
> z = [3, 5, 6]
> ax.scatter(x, y, z)
>
> cid = fig.canvas.mpl_connect('motion_notify_event', on_hover)
>
> plt.show()
> ##################################
>
> When you move the mouse over the figure, you can see the properties of
> event:
>
> ['__doc__', '__init__', '__module__', '__str__',
> '_update_enter_leave', 'button', 'canvas', 'dblclick', 'guiEvent',
> 'inaxes', 'key', 'lastevent', 'name', 'step', 'x', 'xdata', 'y',
> 'ydata']
>
> There is xdata, ydata, but not zdata.
>
> Is zdata missing or should I be using a different event type?
>
> Alejandro.
>
>
Be careful, I don't think the xdata and ydata are in the coordinate system
that you believe they are in. Because of the way mplot3d works outside of
the proper projections transform framework, it can only guess at what the
3d coordinates are. The x/ydata are probably in the 2d axes coordinates and
not the coordinates that you are using for the 3d axes that is embedded in
the 2d axes, I can't recall for sure.
The following is the function from the Axes3D class used to report a 3d
coordinate that is displayed in the lower-right corner of the figure. You
might be able to adapt this for your use. Note that self.M is the internal
projection matrix for the Axes3D object.
 def format_coord(self, xd, yd):
 """
 Given the 2D view coordinates attempt to guess a 3D coordinate.
 Looks for the nearest edge to the point and then assumes that
 the point is at the same z location as the nearest point on the
edge.
 """
 if self.M is None:
 return ''
 if self.button_pressed in self._rotate_btn:
 return 'azimuth=%d deg, elevation=%d deg ' % (self.azim,
self.elev)
 # ignore xd and yd and display angles instead
 p = (xd, yd)
 edges = self.tunit_edges()
 #lines = [proj3d.line2d(p0,p1) for (p0,p1) in edges]
 ldists = [(proj3d.line2d_seg_dist(p0, p1, p), i) for \
 i, (p0, p1) in enumerate(edges)]
 ldists.sort()
 # nearest edge
 edgei = ldists[0][1]
 p0, p1 = edges[edgei]
 # scale the z value to match
 x0, y0, z0 = p0
 x1, y1, z1 = p1
 d0 = np.hypot(x0-xd, y0-yd)
 d1 = np.hypot(x1-xd, y1-yd)
 dt = d0+d1
 z = d1/dt * z0 + d0/dt * z1
 x, y, z = proj3d.inv_transform(xd, yd, z, self.M)
 xs = self.format_xdata(x)
 ys = self.format_ydata(y)
 zs = self.format_zdata(z)
 return 'x=%s, y=%s, z=%s' % (xs, ys, zs)
I hope this helps!
Ben Root
From: Skipper S. <jss...@gm...> - 2011年11月08日 22:56:13
Hi,
Two related questions. Consider this plot
-----
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot([1,0,0,1],[0,1,0,0],[0,0,1,0])
ax.set_xlim3d(0,1)
ax.set_ylim3d(0,1)
#ax.set_ylim3d(1,0)
ax.set_zlim3d(0,1)
plt.show()
-----
I want to uncomment the line above to reverse the y axis, but as soon
as I do, the tick labels disappear on the y axis and the z axis tick
label padding changing. Is there another way to reverse the y axis, or
should I fix thing after the fact. If so, how can I do this? I don't
see a zaxis in rcParams.
Thanks,
Skipper
From: Alejandro W. <ale...@gm...> - 2011年11月08日 22:50:50
Hi:
I am trying to use the event associated to motion_notify_event in a 3D
plot, and I found that the event does not have the zdata property.
The following code illustrate the problem:
##################################
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
def on_hover(event):
 print dir(event)
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x = [1, 2, 3]
y = [1, 5, 4]
z = [3, 5, 6]
ax.scatter(x, y, z)
cid = fig.canvas.mpl_connect('motion_notify_event', on_hover)
plt.show()
##################################
When you move the mouse over the figure, you can see the properties of event:
['__doc__', '__init__', '__module__', '__str__',
'_update_enter_leave', 'button', 'canvas', 'dblclick', 'guiEvent',
'inaxes', 'key', 'lastevent', 'name', 'step', 'x', 'xdata', 'y',
'ydata']
There is xdata, ydata, but not zdata.
Is zdata missing or should I be using a different event type?
Alejandro.
From: klo uo <kl...@gm...> - 2011年11月08日 20:31:58
OK, soon I found out that m.xmax... are dependant on projection, and I
wasn't using Lambert projection
For default projection result are degrees and this way meters it sems
On Tue, Nov 8, 2011 at 9:13 PM, klo uo <kl...@gm...> wrote:
> from http://matplotlib.github.com/basemap/users/examples.html:
>
> ----------------------------------------
> from mpl_toolkits.basemap import Basemap, shiftgrid, cm
> import numpy as np
> import matplotlib.pyplot as plt
> from netCDF4 import Dataset
>
> # read in etopo5 topography/bathymetry.
> etopodata =\
> Dataset('http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL/etopo5.nc')
> topoin = etopodata.variables['ROSE'][:]
> lons = etopodata.variables['ETOPO05_X'][:]
> lats = etopodata.variables['ETOPO05_Y'][:]
> # shift data so lons go from -180 to 180 instead of 20 to 380.
> topoin,lons = shiftgrid(180.,topoin,lons,start=False)
>
> # plot topography/bathymetry as an image.
>
> # create the figure and axes instances.
> fig = plt.figure()
> ax = fig.add_axes([0.1,0.1,0.8,0.8])
> # setup of basemap ('lcc' = lambert conformal conic).
> # use major and minor sphere radii from WGS84 ellipsoid.
> m =
> Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
> rsphere=(6378137.00,6356752.3142),\
> resolution='l',area_thresh=1000.,projection='lcc',\
> lat_1=50.,lon_0=-107.,ax=ax)
> # transform to nx x ny regularly spaced 5km native projection grid
> nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1
> topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
> ...
> ----------------------------------------
>
> Line (last but one):
> nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1
>
> (m.xmax-m.xmin) and (m.ymax-m.ymin) are very small compared to their
> divider 5000, so nx and ny are always 1
>
> Provided link for "etopo5.nc" is desperately slow (~20 Kb/s) so I can't
> test the code, but I tried with other dataset (ETOPO2) and I can't get what
> "topodat" varable should be. It's not clear to me from provided
> documentation.
>
> Thanks in advance for any help
>
From: klo uo <kl...@gm...> - 2011年11月08日 20:13:24
from http://matplotlib.github.com/basemap/users/examples.html:
----------------------------------------
from mpl_toolkits.basemap import Basemap, shiftgrid, cm
import numpy as np
import matplotlib.pyplot as plt
from netCDF4 import Dataset
# read in etopo5 topography/bathymetry.
etopodata =\
Dataset('http://ferret.pmel.noaa.gov/thredds/dodsC/data/PMEL/etopo5.nc')
topoin = etopodata.variables['ROSE'][:]
lons = etopodata.variables['ETOPO05_X'][:]
lats = etopodata.variables['ETOPO05_Y'][:]
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
# plot topography/bathymetry as an image.
# create the figure and axes instances.
fig = plt.figure()
ax = fig.add_axes([0.1,0.1,0.8,0.8])
# setup of basemap ('lcc' = lambert conformal conic).
# use major and minor sphere radii from WGS84 ellipsoid.
m =
Basemap(llcrnrlon=-145.5,llcrnrlat=1.,urcrnrlon=-2.566,urcrnrlat=46.352,\
 rsphere=(6378137.00,6356752.3142),\
 resolution='l',area_thresh=1000.,projection='lcc',\
 lat_1=50.,lon_0=-107.,ax=ax)
# transform to nx x ny regularly spaced 5km native projection grid
nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1
topodat = m.transform_scalar(topoin,lons,lats,nx,ny)
...
----------------------------------------
Line (last but one):
nx = int((m.xmax-m.xmin)/5000.)+1; ny = int((m.ymax-m.ymin)/5000.)+1
(m.xmax-m.xmin) and (m.ymax-m.ymin) are very small compared to their
divider 5000, so nx and ny are always 1
Provided link for "etopo5.nc" is desperately slow (~20 Kb/s) so I can't
test the code, but I tried with other dataset (ETOPO2) and I can't get what
"topodat" varable should be. It's not clear to me from provided
documentation.
Thanks in advance for any help
From: Benjamin R. <ben...@ou...> - 2011年11月08日 17:38:52
On Tue, Nov 8, 2011 at 11:18 AM, Andres Ordonez <
and...@gm...> wrote:
> I'm not sure this is the right place to report this, so if it isn't
> please redirect it to the right place and let me know where the right
> place is.
>
>
>
> The anim.py link
>
> http://matplotlib.sourceforge.net/examples/anim.py
>
> located at
>
> http://www.scipy.org/Cookbook/Matplotlib/Animations
>
> doesn't work.
>
>
That would be a problem with the scipy's website as that example no longer
exists.
Ben Root
From: Bedartha G. <go...@pi...> - 2011年11月08日 17:34:39
Hi,
I have recently installed Python 32/64bit from Python.org and then I proceeded to install bumpy, scipy, matplotlib and igraph on it. But the Matplotlib does not show the plots even if it opens a Figure window. Here is a summary of what I had done in my installation:
-----
I first did a "clean install" by following the instructions at (with an idea to reinstall Matplotlib and see if the rror repeats):
http://matplotlib.sourceforge.net/faq/installing_faq.html#clean-install
-----
So now my python does not have matplotlib:
Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
Bedarthas-MacBook-Air:Desktop bedartha$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>> 
Bedarthas-MacBook-Air:Desktop bedartha$
-----
Then I downloaded (again) the DMG file at: 
http://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.1.0/matplotlib-1.1.0-py2.7-python.org-macosx10.3.dmg/download
-----
and installed Matplotlib (which seems to go through fine). But after that:
Bedarthas-MacBook-Air:~ bedartha$ cd ~/Desktop/
Bedarthas-MacBook-Air:Desktop bedartha$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib as mpl
>>> from pylab import *
>>> plot([1,2,3])
[<matplotlib.lines.Line2D object at 0x2f87fb0>]
>>> show()
Exception in Tkinter callback
Traceback (most recent call last):
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 1410, in __call__
 return self.func(*args)
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 236, in resize
 self.show()
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 240, in draw
 tkagg.blit(self._tkphoto, self.renderer._renderer, colormode=2)
 File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/tkagg.py", line 19, in blit
 tk.call("PyAggImagePhoto", photoimage, id(aggimage), colormode, id(bbox_array))
TclError
>>> 
Bedarthas-MacBook-Air:Desktop bedartha$
-----
Here is the essential info about my machine and my Python and Matplotlib versions:
Bedarthas-MacBook-Air:~ bedartha$ uname -a
Darwin Bedarthas-MacBook-Air.local 11.0.1 Darwin Kernel Version 11.0.1: Wed Jun 29 19:53:22 PDT 2011; root:xnu-1699232~1/RELEASE_X86_64 x86_64
-----
Bedarthas-MacBook-Air:Desktop bedartha$ python
Python 2.7.2 (v2.7.2:8527427914a2, Jun 11 2011, 15:22:34) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib as mpl
>>> mpl.__version__
'1.1.0'
>>> 
Bedarthas-MacBook-Air:Desktop bedartha$
-----
I also have the following alias (in ~/.bash_profile) for my Python2.7 (to deal with some issues in igraph):
alias python="arch -i386 python"
-----
Can anyone please help me out?
Best regards,
and apologies for the lengthy post,
Bedartha
From: Andres O. <and...@gm...> - 2011年11月08日 17:19:09
I'm not sure this is the right place to report this, so if it isn't
please redirect it to the right place and let me know where the right
place is.
The anim.py link
http://matplotlib.sourceforge.net/examples/anim.py
located at
http://www.scipy.org/Cookbook/Matplotlib/Animations
doesn't work.
From: Blake, J. <Jam...@nu...> - 2011年11月08日 17:00:34
Ben,
Adjusting mew sorted it out. Somewhere along the line, I'd changed lines.markeredgewidth in my matplotlibrc to 0, so it wasn't drawing the lines.
Now I know the caps are drawn as a dashed marker, it meant that the lines around it weren't being drawn (or rather they were, but with zero width). With mew>0, if I change capsize, the width of the cap now adjusts accordingly.
Many thanks.
James
________________________________________
From: ben...@gm... [mailto:ben...@gm...] On Behalf Of Benjamin Root
Sent: 08 November 2011 16:41
To: Blake, James
Cc: mat...@li...
Subject: Re: [Matplotlib-users] capsize on errorbars
On Tue, Nov 8, 2011 at 9:57 AM, Blake, James <Jam...@nu...> wrote:
Dear MPL gurus,
I've probably failed to RTFM properly.
I'm trying to produce error bars with horizontal lines at the top of the
vertical error bars to cap them. I've tried adjusting capsize on both
plt.bar and plt.errorbar, but have not had any success. I think I had
this working previously with 1.0.1, but can't remember for definite.
Matplotlib: 1.1.0
Python version: 2.7.2
IPython: 0.11
Windows XP 32 bit
Many thanks for any pointers, and apologies if I have missed an obvious
setting.
James
=== begin example code ===
import matplotlib.pyplot as plt
import numpy as np
plt.ion()
X = np.array([.5,1.5,2.5,3.5])
Y = np.array([1,2,3,4])
dY = np.array([.1,.2,.3,.4])
f = plt.figure()
ax = f.add_subplot(111)
A = plt.bar(X, Y, yerr=dY, ecolor='red', capsize=10)
A[0].set_facecolor('black')
A[1].set_facecolor('gray')
A[2].set_facecolor('black')
A[3].set_facecolor('gray')
ax.set_xlim([0.,4.8])
plt.show()
Are you trying to widen the cap, or make it thicker? I forget which does which, but in my plots, I use "capsize" for one of them and "mew" (markeredgewidth) for the other. If I remember correctly, the errorbar caps are actually a dash marker turned on its side. If that is the case, then adjusting "mew" would adjust the thickness.
Ben Root
******************************************************************************************************************** 
This message may contain confidential information. If you are not the intended recipient please inform the
sender that you have received the message in error before deleting it.
Please do not disclose, copy or distribute information in this e-mail or take any action in reliance on its contents:
to do so is strictly prohibited and may be unlawful.
Thank you for your co-operation.
******************************************************************************************************************** 
This email has been processed by SmoothZap - www.smoothwall.net
From: Benjamin R. <ben...@ou...> - 2011年11月08日 16:41:31
On Tue, Nov 8, 2011 at 9:57 AM, Blake, James <Jam...@nu...>wrote:
> Dear MPL gurus,
>
> I've probably failed to RTFM properly.
>
> I'm trying to produce error bars with horizontal lines at the top of the
> vertical error bars to cap them. I've tried adjusting capsize on both
> plt.bar and plt.errorbar, but have not had any success. I think I had
> this working previously with 1.0.1, but can't remember for definite.
>
> Matplotlib: 1.1.0
> Python version: 2.7.2
> IPython: 0.11
> Windows XP 32 bit
>
> Many thanks for any pointers, and apologies if I have missed an obvious
> setting.
>
> James
>
>
>
> === begin example code ===
> import matplotlib.pyplot as plt
> import numpy as np
> plt.ion()
> X = np.array([.5,1.5,2.5,3.5])
> Y = np.array([1,2,3,4])
> dY = np.array([.1,.2,.3,.4])
> f = plt.figure()
> ax = f.add_subplot(111)
> A = plt.bar(X, Y, yerr=dY, ecolor='red', capsize=10)
> A[0].set_facecolor('black')
> A[1].set_facecolor('gray')
> A[2].set_facecolor('black')
> A[3].set_facecolor('gray')
> ax.set_xlim([0.,4.8])
> plt.show()
>
Are you trying to widen the cap, or make it thicker? I forget which does
which, but in my plots, I use "capsize" for one of them and "mew"
(markeredgewidth) for the other. If I remember correctly, the errorbar
caps are actually a dash marker turned on its side. If that is the case,
then adjusting "mew" would adjust the thickness.
Ben Root
8 messages has been excluded from this view by a project administrator.

Showing results of 339

<< < 1 .. 8 9 10 11 12 .. 14 > >> (Page 10 of 14)
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 によって変換されたページ (->オリジナル) /