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




Showing results of 312

<< < 1 .. 8 9 10 11 12 13 > >> (Page 10 of 13)
From: Jae-Joon L. <lee...@gm...> - 2010年11月09日 07:50:05
On Sat, Oct 30, 2010 at 2:16 PM, Paul Ivanov <piv...@gm...> wrote:
>> Thanks Paul! Your suggestion got me part of the way, but I've run
>> into another problem...I'm using draggable legends, I'm also wanting
>> to fetch the current position of the legend after a drag. The
>> draggable legend always updates 'loc', and not 'bbox_to_anchor', so
>> I'm afraid that I'm stuck manipulating 'loc' for my purposes and not
>> the bbox_to_anchor property.
>
>From svn r8784, you can optionally make legend to update
bbox_to_anchor parameter (and leave *loc* untouched) when dragged.
d = my_legend.draggable(update="bbox")
The default is to update *loc*.
Regards,
-JJ
From: Aman T. <ama...@gm...> - 2010年11月09日 03:56:56
Honestly, I can't even remember why it is wrapped. I think this is just a
relic of some old example that I had lying around. Serves me right for just
copying and pasting without thinking :P . A straight call to
itertools.cycle is definitely much cleaner. Also, is there an example of
this in the docs? If not, it would be a useful addition. Seems like a
common feature to address.
Cheers,
Aman
On Mon, Nov 8, 2010 at 10:41 PM, Ryan May <rm...@gm...> wrote:
> On Fri, Nov 5, 2010 at 8:07 AM, Aman Thakral <ama...@gm...>
> wrote:
> > Hi,
> >
> > The best way to do this is to use a generator:
> >
> > import itertools
> > import matplotlib.pyplot as plt
> > import numpy as np
> >
> > def _ncycle(iterable,n):
> > """
> > Method to create a generator from an iterable. It keeps the
> > current position of the iterable in memory. Each time the
> > next() method for the iterable is called, it will return the
> > next item. If there are no more items, it will cycle to the
> > first item.
> > """
> >
> > for item in itertools.cycle(iterable):
> > yield item
> >
> > colors = _ncycle(('r','g','b','c','y','m','k'),1)
> > markers = _ncycle(('o','s','v'),1)
>
> I like the thought, but I'm not sure why you're making it so
> complicated by wrapping it. itertools.cycle by itself is perfect, and
> there's no reason to prime it by calling next() before the plot. The
> following is a bit more succint IMO:
>
> import itertools
> import matplotlib.pyplot as plt
> import numpy as np
>
> colors = itertools.cycle(['r','g','b','c','y','m','k'])
> markers = itertools.cycle(['o','s','v'])
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
> for i in range(10):
> x = np.linspace(0, 2*np.pi)
> y = np.sin(x) + np.random.randn(*x.shape)
> ax.plot(x, y, c=colors.next(), marker=markers.next())
>
> plt.show()
>
> Also, you can avoid calling colors.next() and markers.next() if you
> put them in a zip command along with range().
>
> Ryan
>
> --
> Ryan May
> Graduate Research Assistant
> School of Meteorology
> University of Oklahoma
>
From: Ryan M. <rm...@gm...> - 2010年11月09日 03:41:41
On Fri, Nov 5, 2010 at 8:07 AM, Aman Thakral <ama...@gm...> wrote:
> Hi,
>
> The best way to do this is to use a generator:
>
> import itertools
> import matplotlib.pyplot as plt
> import numpy as np
>
> def _ncycle(iterable,n):
>   """
>   Method to create a generator from an iterable. It keeps the
>   current position of the iterable in memory. Each time the
>   next() method for the iterable is called, it will return the
>   next item. If there are no more items, it will cycle to the
>   first item.
>   """
>
>   for item in itertools.cycle(iterable):
>     yield item
>
> colors = _ncycle(('r','g','b','c','y','m','k'),1)
> markers = _ncycle(('o','s','v'),1)
I like the thought, but I'm not sure why you're making it so
complicated by wrapping it. itertools.cycle by itself is perfect, and
there's no reason to prime it by calling next() before the plot. The
following is a bit more succint IMO:
import itertools
import matplotlib.pyplot as plt
import numpy as np
colors = itertools.cycle(['r','g','b','c','y','m','k'])
markers = itertools.cycle(['o','s','v'])
fig = plt.figure()
ax = fig.add_subplot(111)
for i in range(10):
 x = np.linspace(0, 2*np.pi)
 y = np.sin(x) + np.random.randn(*x.shape)
 ax.plot(x, y, c=colors.next(), marker=markers.next())
plt.show()
Also, you can avoid calling colors.next() and markers.next() if you
put them in a zip command along with range().
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Nicolas B. <nbi...@gm...> - 2010年11月09日 03:21:01
>
> How can I automatically cycle through distinctive line markers?
>>
>> I want a semilog plot, composed of a number of lines. Each line should
>> have
>> a different color and marker.
>
>
I simply use:
colors = ['b', 'r', 'c', 'm', 'k', 'g', 'y']
symbols = ['-', '--', '-.', ':']
nc = len(colors)
ns = len(symbols)
cs = 0
cc = 0
for i in numpy.arange(len(parameters_list)):
 plt.plot(x, y, colors[cc%nc] + symbols[cs%ns], label=r'$\Delta x_{min} =
' + str(dxmin[j]) + ', N = ' + str(Ns[i]) + r'$')
 cc += 1
 if (cc == nc):
 cc = 0
 cs += 1
This will cycle through symbols when colors run out. You can indent or not
"cs" to cycle through symbols too.
From: Jae-Joon L. <lee...@gm...> - 2010年11月09日 00:51:23
On Tue, Nov 9, 2010 at 12:21 AM, Werner F. Bruhin <wer...@fr...> wrote:
> I like to have 2 or 3 text elements "stacked" on top of each other on
> top of a bar.
>
> Currently it works for the first text element by doing:
>
> height = bar.get_height()
> xCorr = bar.get_x()
> yCorr = 0.20 + height
>
> txtax = axes.text(xCorr, yCorr, hstr)
>
> trying to add the second text just above the previous one I tried this:
>
> pCorr = yCorr + txtax.get_size() + 0.4
> txtax = axes.text(xCorr, pCorr, hstrPerc)
>
I recommend you to use "annotate".
http://matplotlib.sourceforge.net/api/pyplot_api.html?highlight=annotate#matplotlib.pyplot.annotate
you may begin with something like below.
txt=plt.text(0.5, 0.5, "Test1")
plt.annotate("My Test2",
 xy=(0.5, 1.), xycoords=txt,
 xytext=(0, 5), textcoords="offset points",
 ha="center", va="bottom")
See belows for more details.
http://matplotlib.sourceforge.net/users/annotations_guide.html#using-complex-coordinate-with-annotation
http://matplotlib.sourceforge.net/users/annotations_guide.html#using-complex-coordinate-with-annotation
-JJ
> It looks like my problem is that get_x() returns a value in ticks and
> txtax.get_size() is in pixels and I can't find a way to get at the
> height of the text element in ticks.
>
> Can anyone please push me in the right direction.
>
> Werner
>
>
>
>
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Philip S. <ph...@se...> - 2010年11月08日 15:26:08
On Nov 8, 2010, at 9:51 AM, Ryan May wrote:
> On Mon, Nov 8, 2010 at 8:34 AM, Philip Semanchuk <ph...@se...> wrote:
>> Hi Ryan,
>> Thanks. I don't know why sudo behaves the way it does with regard to $HOME, but the behavior of sudo is not under my control (nor matplotlib's). Also, I expect that *lots* of software depends on this behavior of sudo so changing it is probably not an option.
>> 
> 
> Sounds like you've found your solution (which is great), but to set
> the record straight, you *can* control the behavior of sudo. In
> /etc/sudoers, you can set env_reset to reset the environment, so none
> of your variables (like $HOME). You can also just specify certain
> variables to be reset. There is also an option always_set_home which
> seems to do the right thing. In fact, on my machine, sudo works just
> fine:
> 
> ~> sudo python -c 'import os;print os.environ["HOME"]'
> /root
> 
> So, so long as you can edit /etc/sudoers, you are *very much* in
> control of how sudo works in this regard.
Thanks for the education, Ryan. 
I checked my Ubuntu 9.04 virtual install where I first saw this problem, and the contents of /etc/sudoers are as described here:
https://help.ubuntu.com/community/Sudoers#The%20Default%20Ubuntu%20Sudoers%20File
Sure enough, $HOME isn't altered by sudo:
~$ sudo python -c 'import os;print os.environ["HOME"]'
/home/philip
I observe the same under OS X, so this configuration of /etc/sudoers might not be ideal, but it's popular.
Thanks
P
From: Werner F. B. <wer...@fr...> - 2010年11月08日 15:21:23
I like to have 2 or 3 text elements "stacked" on top of each other on 
top of a bar.
Currently it works for the first text element by doing:
height = bar.get_height()
xCorr = bar.get_x()
yCorr = 0.20 + height
txtax = axes.text(xCorr, yCorr, hstr)
trying to add the second text just above the previous one I tried this:
pCorr = yCorr + txtax.get_size() + 0.4
txtax = axes.text(xCorr, pCorr, hstrPerc)
It looks like my problem is that get_x() returns a value in ticks and 
txtax.get_size() is in pixels and I can't find a way to get at the 
height of the text element in ticks.
Can anyone please push me in the right direction.
Werner
From: Ryan M. <rm...@gm...> - 2010年11月08日 14:51:51
On Mon, Nov 8, 2010 at 8:34 AM, Philip Semanchuk <ph...@se...> wrote:
> Hi Ryan,
> Thanks. I don't know why sudo behaves the way it does with regard to $HOME, but the behavior of sudo is not under my control (nor matplotlib's). Also, I expect that *lots* of software depends on this behavior of sudo so changing it is probably not an option.
>
Sounds like you've found your solution (which is great), but to set
the record straight, you *can* control the behavior of sudo. In
/etc/sudoers, you can set env_reset to reset the environment, so none
of your variables (like $HOME). You can also just specify certain
variables to be reset. There is also an option always_set_home which
seems to do the right thing. In fact, on my machine, sudo works just
fine:
~> sudo python -c 'import os;print os.environ["HOME"]'
/root
So, so long as you can edit /etc/sudoers, you are *very much* in
control of how sudo works in this regard.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Philip S. <ph...@se...> - 2010年11月08日 14:34:15
On Nov 8, 2010, at 9:13 AM, Ryan May wrote:
> On Thu, Nov 4, 2010 at 10:49 AM, Philip Semanchuk <ph...@se...> wrote:
>> Hi all,
>> I've run into an aspect of matplotlib's setup that seems awkward. I'm seeing this on Ubuntu, but I imagine it would happen on any *nix platform.
>> 
>> If python is running under sudo the first time matplotlib is imported, then matplotlib creates its config dir (~/.matplotlib) with root as the owner. Subsequent attempts to import matplotlib while running python as a non-privileged user result in this:
>> 
>> -----------------------------------------------------------------
>> RuntimeError: '/home/philip' is not a writable dir; you must set /home/philip/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored
>> -----------------------------------------------------------------
>> 
>> A simple way to re-create this --
>> 1. Delete or rename ~/.matplotlib
>> 2. sudo python -c "import matplotlib"
>> 3. python -c "import matplotlib"
>> 
>> 
>> This not-improbable real-world scenario would create ~/.matplotlib owned by root --
>> 1) Download app FooBar that has matplotlib as a dependency
>> 2) Install matplotlib
>> 3) Run FooBar's setup.py as sudo. It imports matplotlib, perhaps just to ensure that matplotlib is installed and working.
>> 
>> 
>> We ran into a similar situation with our app ('sudo python setup.py install' created desktop icons owned by root) and we resolved it by invoking chown after using a getenv() call to sniff out who we really wanted to own the file.
>> 
>> It looks like the diff below (untested!) applied to lib/matplotlib/__init__.py would prevent this from happening. Does it seems reasonable to add it?
>> 
>> 474a475,485
>>> if not sys.platform.lower().startswith("win"):
>>> # Ensure that we didn't just create a root-owned directory in the
>>> # user's HOME directory. That happens if this is being run under
>>> # sudo. If the SUDO_USER env. var (which contains the user that
>>> # invoked sudo) then we're running under sudo. If it doesn't
>>> # exist, we're not running under sudo.
>>> current_user = os.getenv("SUDO_USER")
>>> if current_user:
>>> subprocess.call(["chown", "-R", current_user, p])
> 
> I'm not sure how I feel about this. On one hand, it is a pain to have
> this not work under sudo. On the other, I consider the fact that $HOME
> is not set to "/root" when running as root to be a bit of a problem.
> Personally, the better solution to me would be to make sure $HOME is
> one of the variables that gets reset by sudo.
Hi Ryan,
Thanks. I don't know why sudo behaves the way it does with regard to $HOME, but the behavior of sudo is not under my control (nor matplotlib's). Also, I expect that *lots* of software depends on this behavior of sudo so changing it is probably not an option.
@Matthieu --
Merci Matthieu, yours is an elegant solution. In our setup.py we're just importing matplotlib to ensure it exists, so that fits your scenario. 
The workaround I used was this --
 MATPLOTLIB_CONFIG_PATH = os.path.join(os.path.expanduser('~'), ".matplotlib")
 if not sys.platform.lower().startswith("win"):
 if not os.path.exists(MATPLOTLIB_CONFIG_PATH):
 check_matplotlib_permissions = True
 
 
 # Do stuff that triggers an import of matplotlib...
 if check_matplotlib_permissions:
 if os.path.exists(MATPLOTLIB_CONFIG_PATH):
 sudo_user = os.getenv("SUDO_USER")
 if sudo_user:
 subprocess.call(["chown", "-R", sudo_user, MATPLOTLIB_CONFIG_PATH])
I think I like your idea better.
Cheers
Philip
PS - Matthieu, sorry for not quoting you directly but I was unable to subscribe to the list before I received your mail.
From: Ryan M. <rm...@gm...> - 2010年11月08日 14:14:11
On Thu, Nov 4, 2010 at 10:49 AM, Philip Semanchuk <ph...@se...> wrote:
> Hi all,
> I've run into an aspect of matplotlib's setup that seems awkward. I'm seeing this on Ubuntu, but I imagine it would happen on any *nix platform.
>
> If python is running under sudo the first time matplotlib is imported, then matplotlib creates its config dir (~/.matplotlib) with root as the owner. Subsequent attempts to import matplotlib while running python as a non-privileged user result in this:
>
> -----------------------------------------------------------------
> RuntimeError: '/home/philip' is not a writable dir; you must set /home/philip/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored
> -----------------------------------------------------------------
>
> A simple way to re-create this --
> 1. Delete or rename ~/.matplotlib
> 2. sudo python -c "import matplotlib"
> 3. python -c "import matplotlib"
>
>
> This not-improbable real-world scenario would create ~/.matplotlib owned by root --
> 1) Download app FooBar that has matplotlib as a dependency
> 2) Install matplotlib
> 3) Run FooBar's setup.py as sudo. It imports matplotlib, perhaps just to ensure that matplotlib is installed and working.
>
>
> We ran into a similar situation with our app ('sudo python setup.py install' created desktop icons owned by root) and we resolved it by invoking chown after using a getenv() call to sniff out who we really wanted to own the file.
>
> It looks like the diff below (untested!) applied to lib/matplotlib/__init__.py would prevent this from happening. Does it seems reasonable to add it?
>
> 474a475,485
>>     if not sys.platform.lower().startswith("win"):
>>       # Ensure that we didn't just create a root-owned directory in the
>>       # user's HOME directory. That happens if this is being run under
>>       # sudo. If the SUDO_USER env. var (which contains the user that
>>       # invoked sudo) then we're running under sudo. If it doesn't
>>       # exist, we're not running under sudo.
>>       current_user = os.getenv("SUDO_USER")
>>       if current_user:
>>         subprocess.call(["chown", "-R", current_user, p])
I'm not sure how I feel about this. On one hand, it is a pain to have
this not work under sudo. On the other, I consider the fact that $HOME
is not set to "/root" when running as root to be a bit of a problem.
Personally, the better solution to me would be to make sure $HOME is
one of the variables that gets reset by sudo.
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Matthieu H. <mat...@wa...> - 2010年11月08日 09:07:46
If you don't have any special use for the config dir, this might be a 
more straightforward solution that doesn't require patching matplotlib.
Simply paste this in your code, before importing matplotlib :
import os
os.environ['HOME'] = '/tmp/'
Might be safer to use 'MPLCONFIGDIR' instead of 'HOME'.
Hope this helps.
Matthieu
Le 04/11/2010 16:49, Philip Semanchuk a écrit :
> Hi all,
> I've run into an aspect of matplotlib's setup that seems awkward. I'm seeing this on Ubuntu, but I imagine it would happen on any *nix platform.
>
> If python is running under sudo the first time matplotlib is imported, then matplotlib creates its config dir (~/.matplotlib) with root as the owner. Subsequent attempts to import matplotlib while running python as a non-privileged user result in this:
>
> -----------------------------------------------------------------
> RuntimeError: '/home/philip' is not a writable dir; you must set /home/philip/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored
> -----------------------------------------------------------------
>
> A simple way to re-create this --
> 1. Delete or rename ~/.matplotlib
> 2. sudo python -c "import matplotlib"
> 3. python -c "import matplotlib"
>
>
> This not-improbable real-world scenario would create ~/.matplotlib owned by root --
> 1) Download app FooBar that has matplotlib as a dependency
> 2) Install matplotlib
> 3) Run FooBar's setup.py as sudo. It imports matplotlib, perhaps just to ensure that matplotlib is installed and working.
>
>
> We ran into a similar situation with our app ('sudo python setup.py install' created desktop icons owned by root) and we resolved it by invoking chown after using a getenv() call to sniff out who we really wanted to own the file.
>
> It looks like the diff below (untested!) applied to lib/matplotlib/__init__.py would prevent this from happening. Does it seems reasonable to add it?
>
> 474a475,485
>> if not sys.platform.lower().startswith("win"):
>> # Ensure that we didn't just create a root-owned directory in the
>> # user's HOME directory. That happens if this is being run under
>> # sudo. If the SUDO_USER env. var (which contains the user that
>> # invoked sudo) then we're running under sudo. If it doesn't
>> # exist, we're not running under sudo.
>> current_user = os.getenv("SUDO_USER")
>> if current_user:
>> subprocess.call(["chown", "-R", current_user, p])
>
> Thanks
> Philip
>
>
>
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Jae-Joon L. <lee...@gm...> - 2010年11月08日 00:43:21
Hi,
I am pleased to announce the release of pywcsgrid2 0.1b1.
pywcsgrid2 is a python module to be used with matplotlib for
displaying astronomical fits images. It provides a custom Axes class
(derived from mpl's original Axes class) suitable for displaying fits
images. Its main functionality is to draw ticks, ticklabels, and grids
in an appropriate sky coordinates.
For a sampling, take a look at the gallery
http://leejjoon.github.com/matplotlib_astronomy_gallery/
 * Provide a custom Matplotlib Axes class based on
mpl_toolkits.axisartist module
 * Easy integration with mpl_toolkits.axes_grid1 module
Requirement
------------------
 * matplotlib v1.0 (or later)
 * a wcs module (pywcs or Kapteyn)
 * pyfits.
Supported OS
--------------------
 * Linux & OS X
 * pywcsgrid2 itself is a pure python module.
URLs
------
Home page : http://leejjoon.github.com/pywcsgrid2/
Overview doc. : http://leejjoon.github.com/pywcsgrid2/users/overview.html
Download : http://github.com/leejjoon/pywcsgrid2/downloads
github : http://github.com/leejjoon/pywcsgrid2
For questions, bug reports or feature suggestions, please use the
issue tracker in the github or contact me via email.
Regards,
-JJ
From: LB <bra...@gm...> - 2010年11月07日 15:40:30
Hi,
I'm trying to draw a bar chart according to
http://matplotlib.sourceforge.net/examples/api/barchart_demo.html, and I'm
having to difficulties :
 - when the first bar has a zero height, it is no taken into account during
the axis limits calculation and is not visible
 - texts objects can exceed chart area and collide with the chart title.
Is there a way to calculate the axis limit to use to include all texts
objects into the chart area ?
Here is the code I used :
[code]
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
menMeans = [ 0. , 998. , 1210. , 1449. ,
 1496. , 1493. , 1593.40002441, 1517.5 ]
ind = np.arange(len(menMeans)) # the x locations for the groups
width = 0.8 # the width of the bars
fig = plt.figure()
ax = fig.add_subplot(111)
rects1 = ax.bar(ind, menMeans, width, color='r')
# add some
ax.set_ylabel('Scores')
ax.set_title('A very very long title for testing.')
def autolabel(rects):
 # attach some text labels
 for rect in rects:
 height = rect.get_height()
 ax.text(rect.get_x()+rect.get_width()/2., 1.05*height,
'%d'%int(height),
 ha='center', va='bottom')
autolabel(rects1)
plt.show()
[/code]
Best regards,
-- 
LB
From: ohern <olg...@gm...> - 2010年11月07日 12:00:13
http://old.nabble.com/file/p30152341/scale.jpg 
Hello,
I would like to create a colorbar as scale.jpg. (log scale colorbar)
I don't know how do it.
Someone can help me?
Thanks,
Olga
-- 
View this message in context: http://old.nabble.com/log-scale-colorbar-tp30152341p30152341.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Ralf G. <ral...@go...> - 2010年11月07日 06:03:18
On Sun, Nov 7, 2010 at 5:10 AM, Friedrich Romstedt
<fri...@gm...> wrote:
> Hi,
>
> A.S.: Ralf, wasn't the reason why we shifted to Vincent's build
> machine running 10.5, because numpy didn't run on 10.4 when built on
> 10.6?
No, the numpy installers have never had a problem on 10.4 AFAIK. The
issue was that installers built on 10.6 would (on some but not all
machines) fail on 10.5.
>
> 2010年11月2日 pablomos <pa...@pr...>:
>> I attempted to install Pylab on my own computer and so far have had no
>> success. I followed these steps:
>> 1) downloaded Python 2.6 for OS 10.4
>> 2) downloaded the corresponding numpy and installed it (successfully)
>
>> 3) downloaded the corresponding matplotlib
>> (matplotlib-1.0.0-python.org-py2.6-macosx10.4.dmg) and installed it [One
>> possible cause for the error is that, though the package includes
>> "macosx10.4", the actual installing package (which one can see if one tries
>> a customized install) says "macosx10.5".]
>
> This is due to a bug in bdist_mpkg probably, used to generate those
> binaries on a 10.5 system, although the MACOSX_DEPLOYMENT_TARGET was
> 10.4 or 10.3 (as I strongly believe), the installer outputs somehow
> "-10.5" when run. I don't know details.
This is just a file name, not necessarily the cause of any error
during installation.
Cheers,
Ralf
From: Friedrich R. <fri...@gm...> - 2010年11月06日 21:52:56
2010年11月1日 Timothy W. Hilton <hi...@me...>:
> [...]
>
> I want to have blue water, some other (bright) color for missing data,
> and a nice-looking color transition (matplotlib.cm.Blues or something
> similar) for the valid data over land (values from 0 to 50). The
> Cookbook example at
> <http://www.scipy.org/Cookbook/Matplotlib/Plotting_Images_with_Special_Values>
> addresses my problem, but I cannot get it to work. After changing
> instances of matplotlib.numerix to numpy, I get a long list of
> exceptions, the last of which is
> TypeError: __call__() got an unexpected keyword argument 'bytes'.
> This has to do with sentinelNorm, I think, but I'm not sure how to fix it.
I think I would tackle this by writing a Norm that doesn't change
negative values, and you might mask then the oceans by -0.5, and the
nans by -1.5. Then, you might create a colormap comprised of the
ocean color for [-1, 0] and the nan color for [-2, -1], and for the
normal normed range [0, 1] the normal Blues cm. Have a look at cm.py
and _cm.py how it works. Basically, you can specify for all sections
of the colormap the left and right color. So you can mix discrete
maps with continuous ones, because the continuous ones are just
linearly interpolated with matching colors for left/right at each
boundary position. Looking at the code will clarify things a lot I
believe.
I don't know what went wrong with the cb example you said. From a
quick look, it seems to have "sentinel rgb values", but this is not
what we want, right?
> Eventually I would like to sub-classify missing data by the type of
> missing input that caused a missing value, but for now a single
> missing data color is enough.
That would be possible with the approach above, by just adding
sections below zero.
_cm.py: Definitions of colormaps, like Blues.
cm.py: among other things, how to load such specifications.
colors.py: Defines Colormaps, and Norms. Have a look at both of them,
esp. at :class:`Normalize`. I would subclass the Norm mentioned above
from Normalize.
I hope this helps you,
Friedrich
From: Friedrich R. <fri...@gm...> - 2010年11月06日 21:10:36
Hi,
A.S.: Ralf, wasn't the reason why we shifted to Vincent's build
machine running 10.5, because numpy didn't run on 10.4 when built on
10.6?
2010年11月2日 pablomos <pa...@pr...>:
> I attempted to install Pylab on my own computer and so far have had no
> success. I followed these steps:
> 1) downloaded Python 2.6 for OS 10.4
> 2) downloaded the corresponding numpy and installed it (successfully)
> 3) downloaded the corresponding matplotlib
> (matplotlib-1.0.0-python.org-py2.6-macosx10.4.dmg) and installed it [One
> possible cause for the error is that, though the package includes
> "macosx10.4", the actual installing package (which one can see if one tries
> a customized install) says "macosx10.5".]
This is due to a bug in bdist_mpkg probably, used to generate those
binaries on a 10.5 system, although the MACOSX_DEPLOYMENT_TARGET was
10.4 or 10.3 (as I strongly believe), the installer outputs somehow
"-10.5" when run. I don't know details.
Of course it is contradictory to my above assumtion that the build was
carried out on a 10.6 ...
> 4) Attempted to run Python and import Pylab. I got an error related to
> _tkinter not being found (even though it is installed). I looked all over
> the forums for this error, and it seems that the only solution is to edit
> the setup.py file and recompile matplotlib. However, because I installed
> from a binary, I cannot do this. So I attempted to install from source:
Can you give more details on the _tkinter error, is it matplotlib
specific, or does it mean the Python _tkinter if such one exists at
all? It's kinda strange.
> 5) I downloaded matplotlib-1.0.0.tar.gz and untarred it. Then I ran:
> 'make' (which supposedly takes care of finding out where all the Mac stuff
> is located) and
For Python packages, ``make`` is *usually* not used. Indeed,
matplotlib is an exception here (see below).
> 'python setup.py build', the default command for building Python modules.
> Now I get a ton of errors, the first one being:
> freetype2: found, but unknown version (no pkg-config)
> * WARNING: Could not find 'freetype2' headers in any
> * of '.', './freetype2'.
You got it. If you have freetype2 and libpng installed on your
system, just have a look at setupext.py, and add the installation root
path (most likely '/usr/local') to the 'darwin' section. It is left
out because of problems on > 10.4, but on your 10.4 system it should
work. It's the most easy solution if.
If you don't have freetype2 installed / libpng, and you really want to
compile from source (if we cannot sort out the _tkinter thingy), then
there are two ways: Hard-core installation by compiling them yourself,
or assisted by make.osx. I personally cannot give you advice with the
more easy make.osx way, but be aware of that also this compiles and
installs the libs. For the hard-core way you might find my docs on
that useful (it's intended for 10.6, so feedback from 10.4 users is
welcome): http://vincentdavis.info/Shared/Docs/matplotlib-installation/build/html/.
 Vincent is hosting that site, gratefully acknowledged.
> As a third try, I attempted to install using easy_install, a tool for
> installing Python modules:
> 6) I ran 'easy_install matplotlib'. This runs very quickly (suspicious)
> 7) The same error as in step 4 comes up when trying to import pylab
> I went into
> /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> and deleted all matplotlib-related stuff, thinking that maybe easy_install
> didn't do anything because matplotlib was already installed
> 9) Repeated step 6, and saw the same errors that came up when trying to
> install from source
You mean easy_install wanted to install from source??
Btw, the binaries *should* work. It looks like kind of failure of the
binaries. Might be that I'm missing something, though.
Hope you find this useful,
Friedrich
[Don't forget to "reply to all" and not only me.]
From: starz1010101 <ama...@ya...> - 2010年11月05日 19:28:42
Fixed by switching the backend from WXAgg to MacOSX.
starz1010101 wrote:
> 
> I can't force pyplot to draw in the middle a function. For example, this
> function does not plot the sine before the user prompt, only after the
> entire function executes:
> 
> import matplotlib.pyplot as plt
> import numpy as np
> 
> def plot_now():
> plt.ion()
> plt.figure()
> x = 2*np.pi*np.linspace(0.0, 1.0, 100)
> plt.plot( x, np.sin(x) )
> plt.draw()
> plt.draw()
> q = raw_input( 'anything: ')
> 
> I'm using the enthought python distribution for mac in ipython. 
> 
> 
> 
> 
> 
-- 
View this message in context: http://old.nabble.com/Can%27t-force-draw-tp30107286p30144358.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Alan G I. <ai...@am...> - 2010年11月05日 15:41:40
On 10/25/2010 9:23 AM, Stan West wrote:
> markerline.set_zorder(stemlines[0].get_zorder() + 0.1)
Thanks.
Now I can easily get what I want.
But back to the underlying question:
do people really prefer the stems to overlay the markers?
I.e., are the ``stem`` defaults possibly incorrect?
Thanks,
Alan
From: Ryan M. <rm...@gm...> - 2010年11月05日 13:57:51
On Fri, Nov 5, 2010 at 7:12 AM, John M. Densmore (Cont, ARL/WMRD)
<joh...@us...> wrote:
> Hi All,
> I have multiple figures set up at the start of my code. through out the
> script I add data to the plots and at the end I would like to set all
> the figure parameters, like xlim, ylim, legend etc. But I can not figure
> out how to do it. Eample code
>
> fig1 = plt.figure(1)
> ax1 = fig1.add_subplot(111)
>
>
> fig2 = plt.figure(2)
> ax2 = fig2.add_subplot(111)
>
>
> fig3 = plt.figure(3)
> ax3 = fig3.add_subplot(111)
>
> ax1.plot(...)
> ax2.plot(...)
> ax3.plot(...)
>
>
> ax1.plot(...)
> ax2.plot(...)
> ax3.plot(...)
>
> # set the x and y lim <- how do I do this?
ax1.set_xlim(xmin, xmax)
ax1.set_ylim(ymin, ymax)
...
Ryan
-- 
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma
From: Oz N. T. <na...@gm...> - 2010年11月05日 13:29:41
A small suggestion to the examples ...
I really like the new subplot mechanism, so I tried it:
fig, (ax1, ax2, ax3, ax4) = plt.subplots(2, 2, sharex=True, sharey=True)
And it actually gave me the following error:
Traceback (most recent call last):
 File "tes.py", line 21, in <module>
 f, (ax1, ax2, ax3, ax4) = subplots(2, 2, sharey=True)
ValueError: need more than 2 values to unpack
I got over with with a small modification:
f, ((ax1,ax2),(ax3,ax4)) = subplots(2, 2, sharey=True)
Which now worked !
Cheers,
-- 
Oz Nahum
Graduate Student
Zentrum für Angewandte Geologie
Universität Tübingen
---
Imagine there's no countries
it isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
From: Aman T. <ama...@gm...> - 2010年11月05日 13:08:13
Hi,
The best way to do this is to use a generator:
import itertools
import matplotlib.pyplot as plt
import numpy as np
def _ncycle(iterable,n):
 """
 Method to create a generator from an iterable. It keeps the
 current position of the iterable in memory. Each time the
 next() method for the iterable is called, it will return the
 next item. If there are no more items, it will cycle to the
 first item.
 """
 for item in itertools.cycle(iterable):
 yield item
colors = _ncycle(('r','g','b','c','y','m','k'),1)
markers = _ncycle(('o','s','v'),1)
n = 20
fig = plt.figure()
ax = fig.add_subplot(111)
for i in range(n):
 x = np.arange(0,10)
 y = np.sin(x)+i-n/2
 c = colors.next()
 if c == 'r':
 marker = markers.next()
 ax.plot(x,y,c=c,marker=marker)
plt.show()
On Fri, Nov 5, 2010 at 8:29 AM, Neal Becker <ndb...@gm...> wrote:
> How can I automatically cycle through distinctive line markers?
>
> I want a semilog plot, composed of a number of lines. Each line should
> have
> a different color and marker.
>
> Cycling through the colors is automatic, but not the markers.
>
> BTW, shouldn't this behavior be the default? I would just like to say
> markers=True and get this behavior.
>
>
>
> ------------------------------------------------------------------------------
> The Next 800 Companies to Lead America's Growth: New Video Whitepaper
> David G. Thomson, author of the best-selling book "Blueprint to a
> Billion" shares his insights and actions to help propel your
> business during the next growth cycle. Listen Now!
> http://p.sf.net/sfu/SAP-dev2dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Aman Thakral
B.Eng & Biosci, M.Eng Design
From: John M. D. (C. ARL/WMRD) <joh...@us...> - 2010年11月05日 12:34:34
Hi All,
I have multiple figures set up at the start of my code. through out the 
script I add data to the plots and at the end I would like to set all 
the figure parameters, like xlim, ylim, legend etc. But I can not figure 
out how to do it. Eample code
fig1 = plt.figure(1)
ax1 = fig1.add_subplot(111)
fig2 = plt.figure(2)
ax2 = fig2.add_subplot(111)
fig3 = plt.figure(3)
ax3 = fig3.add_subplot(111)
ax1.plot(...)
ax2.plot(...)
ax3.plot(...)
ax1.plot(...)
ax2.plot(...)
ax3.plot(...)
# set the x and y lim <- how do I do this?
plt.show()
Thanks
From: Neal B. <ndb...@gm...> - 2010年11月05日 12:29:46
How can I automatically cycle through distinctive line markers?
I want a semilog plot, composed of a number of lines. Each line should have 
a different color and marker.
Cycling through the colors is automatic, but not the markers.
BTW, shouldn't this behavior be the default? I would just like to say
markers=True and get this behavior.
From: Scott S. <sco...@gm...> - 2010年11月05日 12:06:49
On 5 November 2010 14:05, Scott Sinclair <sco...@gm...> wrote:
> You probably want imshow, pcolor, pcolormash or matshow
I meant pcolormesh...
8 messages has been excluded from this view by a project administrator.

Showing results of 312

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