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

Showing results of 31

1 2 > >> (Page 1 of 2)
From: Andrew K. <ndr...@gm...> - 2010年04月02日 21:49:56
Slow on my OSX machine as well. I also get this strange warning which I
have never seen before (I usually only use MPL on my windows machine).
Warning (from warnings module):
 File
"/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pytz/__init__.py",
line 29
 from pkg_resources import resource_stream
UserWarning: Module numpy was already imported from
/Library/Frameworks/GDAL.framework/Versions/1.6/Python/site-packages/numpy/__init__.pyc,
but
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages
is being added to sys.path
On Fri, Apr 2, 2010 at 1:41 PM, Eric Firing <ef...@ha...> wrote:
> Andrew Kelly wrote:
>
>> import pytz only took 0.0 seconds.
>>
>>
>
> Sounds like it was already imported, so you were not really timing that
> import.
>
> On linux (ubuntu 9.10, Lenovo T60 laptop) importing pytz takes longer than
> importing numpy:
>
>
> efiring@manini:~$ time python -c "import pytz"
>
> real 0m0.203s
> user 0m0.144s
> sys 0m0.052s
> efiring@manini:~$ time python -c "import pylab"
>
> real 0m0.626s
> user 0m0.480s
> sys 0m0.124s
>
> efiring@manini:~$ time python -c "import numpy"
>
> real 0m0.113s
> user 0m0.088s
> sys 0m0.020s
>
> (Probably everything is in cache in these tests; repeats yielded similar
> results.)
>
> Eric
>
>
> I actually just ran that pstats module and there is one line that stuck
>> out at me:
>> ncalls tottime percall cumtime percall filename:lineno(function)
>> 1 0.000 0.000 0.000 0.000
>> C:\Python26\lib\os.py:35(_get_exports_list)
>> 560 3.107 0.006 3.107 0.006 {open}
>> That is ~50% of the load time. I have 0 idea what this is though.
>> Let me try this on my os machine.....
>> -Andy
>>
>> On Fri, Apr 2, 2010 at 12:31 PM, Michael Droettboom <md...@st...<mailto:
>> md...@st...>> wrote:
>>
>> It looks like most of the time is being taken up by pytz (timezone
>> library), which opens ~500 files. How does the total time of
>> "import pytz" compare?
>>
>> Mike
>>
>> Andrew Kelly wrote:
>>
>> I see. I was wondering why it spit out a binary file.
>>
>> test.out is attached...
>>
>> -Andy
>>
>> On Fri, Apr 2, 2010 at 10:55 AM, Michael Droettboom
>> <md...@st... <mailto:md...@st...>
>> <mailto:md...@st... <mailto:md...@st...>>> wrote:
>>
>> Can you provide the actual saved profiler data? The output
>> of the
>> command itself doesn't provide enough information to diagnose
>> the
>> problem, since it doesn't have full file paths etc.
>>
>> When you do (thanks Gökhan for the less verbose version):
>>
>> python.exe -c "import cProfile; cProfile.run('import pylab',
>> 'test.out')"
>>
>> this should produce a binary file "test.out" that can be loaded
>> with the pstats module and used by GUI tools such as KCacheGrind
>> to help us get to the bottom of this.
>>
>> Mike
>>
>> Andrew Kelly wrote:
>>
>> I'm back.
>>
>> My backend is wx. "Import wx" does not really take much
>> time
>> to import at all. In fact time.time() before and after =
>> 0.0
>>
>> Some computer details:
>> Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
>> RAM: 8.00 GB
>>
>> As for the cProfiler output on pylab, I have attached the
>> output as test.txt.
>> -Andy
>>
>> On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever
>> <gok...@gm... <mailto:gok...@gm...>
>> <mailto:gok...@gm... <mailto:gok...@gm...>>
>> <mailto:gok...@gm...
>> <mailto:gok...@gm...> <mailto:gok...@gm...
>> <mailto:gok...@gm...>>>>
>>
>> wrote:
>>
>>
>>
>> On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
>> <md...@st... <mailto:md...@st...>
>> <mailto:md...@st... <mailto:md...@st...>>
>> <mailto:md...@st... <mailto:md...@st...>
>> <mailto:md...@st... <mailto:md...@st...>>>> wrote:
>>
>> My gut says it's probably the GUI framework import
>> that is
>> dominating
>> the time. Which backend are you using? Does
>> importing it
>> take a large
>> amount of time as well?
>>
>> Can you provide a profiler output file we can examine
>> to narrow it
>> down? The following from a command prompt should be
>> sufficient to write
>> out a file called "import.prof":
>>
>> python.exe -c "import cProfile;
>> prof=cProfile.Profile();
>> prof.run('import pylab', 'import.prof')"
>>
>> Mike
>>
>>
>> Just for the records,
>>
>> It reads as:
>>
>> python -c "import cProfile; cProfile.run('import pylab',
>> filename='test.out')
>>
>> in Python 2.6.2
>>
>> These helped me to load the profile output:
>>
>> import pstats
>> stats = pstats.Stats("test.out")
>> stats.print_stats()
>>
>> -- Gökhan
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling,
>> find bugs
>> proactively, and fine-tune applications for parallel
>> performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> <mailto:Mat...@li...>
>> <mailto:Mat...@li...
>> <mailto:Mat...@li...>>
>> <mailto:Mat...@li...
>> <mailto:Mat...@li...>
>> <mailto:Mat...@li...
>> <mailto:Mat...@li...>>>
>>
>>
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>> -- Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>>
>>
>> -- Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>>
>>
>> ------------------------------------------------------------------------
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
From: Thomas R. <tho...@gm...> - 2010年04月02日 21:13:43
Hi,
I have been trying to use the Affine2D transformation with pcolor and contour, with no success. The following script and comments illustrates my problems:
matplotlib.use('Agg')
import matplotlib.pyplot as mpl
from matplotlib.transforms import Affine2D
import numpy as np
image = np.random.random((100,100))
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.pcolor(image, transform=Affine2D()) # Does not work - the image is not there!
fig.savefig('test1.png')
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.contour(image, transform=Affine2D()) # Ok, but transformation wouldn't change anything anyway
fig.savefig('test2.png')
fig = mpl.figure()
ax = fig.add_subplot(1,1,1)
ax.contour(image, transform=Affine2D().scale(10.,10.)) # Does not work - the image is unchanged
fig.savefig('test3.png')
Is there a reason why transform doesn't work for contour and pcolor?
Thanks for any help,
Thomas
From: Eric F. <ef...@ha...> - 2010年04月02日 20:41:59
Andrew Kelly wrote:
> import pytz only took 0.0 seconds.
> 
Sounds like it was already imported, so you were not really timing that 
import.
On linux (ubuntu 9.10, Lenovo T60 laptop) importing pytz takes longer 
than importing numpy:
efiring@manini:~$ time python -c "import pytz"
real	0m0.203s
user	0m0.144s
sys	0m0.052s
efiring@manini:~$ time python -c "import pylab"
real	0m0.626s
user	0m0.480s
sys	0m0.124s
efiring@manini:~$ time python -c "import numpy"
real	0m0.113s
user	0m0.088s
sys	0m0.020s
(Probably everything is in cache in these tests; repeats yielded similar 
results.)
Eric
> I actually just ran that pstats module and there is one line that stuck 
> out at me:
> ncalls tottime percall cumtime percall filename:lineno(function)
> 1 0.000 0.000 0.000 0.000 
> C:\Python26\lib\os.py:35(_get_exports_list)
> 560 3.107 0.006 3.107 0.006 {open}
> 
> That is ~50% of the load time. I have 0 idea what this is though.
> 
> Let me try this on my os machine.....
> 
> -Andy
> 
> On Fri, Apr 2, 2010 at 12:31 PM, Michael Droettboom <md...@st... 
> <mailto:md...@st...>> wrote:
> 
> It looks like most of the time is being taken up by pytz (timezone
> library), which opens ~500 files. How does the total time of
> "import pytz" compare?
> 
> Mike
> 
> Andrew Kelly wrote:
> 
> I see. I was wondering why it spit out a binary file.
> 
> test.out is attached...
> 
> -Andy
> 
> On Fri, Apr 2, 2010 at 10:55 AM, Michael Droettboom
> <md...@st... <mailto:md...@st...>
> <mailto:md...@st... <mailto:md...@st...>>> wrote:
> 
> Can you provide the actual saved profiler data? The output
> of the
> command itself doesn't provide enough information to diagnose the
> problem, since it doesn't have full file paths etc.
> 
> When you do (thanks Gökhan for the less verbose version):
> 
> python.exe -c "import cProfile; cProfile.run('import pylab',
> 'test.out')"
> 
> this should produce a binary file "test.out" that can be loaded
> with the pstats module and used by GUI tools such as KCacheGrind
> to help us get to the bottom of this.
> 
> Mike
> 
> Andrew Kelly wrote:
> 
> I'm back.
> 
> My backend is wx. "Import wx" does not really take much time
> to import at all. In fact time.time() before and after = 0.0
> 
> Some computer details:
> Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
> RAM: 8.00 GB
> 
> As for the cProfiler output on pylab, I have attached the
> output as test.txt.
> -Andy
> 
> On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever
> <gok...@gm... <mailto:gok...@gm...>
> <mailto:gok...@gm... <mailto:gok...@gm...>>
> <mailto:gok...@gm...
> <mailto:gok...@gm...> <mailto:gok...@gm...
> <mailto:gok...@gm...>>>>
> 
> wrote:
> 
> 
> 
> On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
> <md...@st... <mailto:md...@st...>
> <mailto:md...@st... <mailto:md...@st...>>
> <mailto:md...@st... <mailto:md...@st...>
> <mailto:md...@st... <mailto:md...@st...>>>> wrote:
> 
> My gut says it's probably the GUI framework import
> that is
> dominating
> the time. Which backend are you using? Does
> importing it
> take a large
> amount of time as well?
> 
> Can you provide a profiler output file we can examine
> to narrow it
> down? The following from a command prompt should be
> sufficient to write
> out a file called "import.prof":
> 
> python.exe -c "import cProfile;
> prof=cProfile.Profile();
> prof.run('import pylab', 'import.prof')"
> 
> Mike
> 
> 
> Just for the records,
> 
> It reads as:
> 
> python -c "import cProfile; cProfile.run('import pylab',
> filename='test.out')
> 
> in Python 2.6.2
> 
> These helped me to load the profile output:
> 
> import pstats
> stats = pstats.Stats("test.out")
> stats.print_stats()
> 
> -- Gökhan
> 
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling,
> find bugs
> proactively, and fine-tune applications for parallel
> performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> <mailto:Mat...@li...>
> <mailto:Mat...@li...
> <mailto:Mat...@li...>>
> <mailto:Mat...@li...
> <mailto:Mat...@li...>
> <mailto:Mat...@li...
> <mailto:Mat...@li...>>>
> 
> 
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
> 
> 
> -- Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
> 
> 
> 
> -- 
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Andrew K. <ndr...@gm...> - 2010年04月02日 20:00:02
import pytz only took 0.0 seconds.
I actually just ran that pstats module and there is one line that stuck out
at me:
 ncalls tottime percall cumtime percall filename:lineno(function)
 1 0.000 0.000 0.000 0.000
C:\Python26\lib\os.py:35(_get_exports_list)
 560 3.107 0.006 3.107 0.006 {open}
That is ~50% of the load time. I have 0 idea what this is though.
Let me try this on my os machine.....
-Andy
On Fri, Apr 2, 2010 at 12:31 PM, Michael Droettboom <md...@st...> wrote:
> It looks like most of the time is being taken up by pytz (timezone
> library), which opens ~500 files. How does the total time of "import pytz"
> compare?
>
> Mike
>
> Andrew Kelly wrote:
>
>> I see. I was wondering why it spit out a binary file.
>>
>> test.out is attached...
>>
>> -Andy
>>
>> On Fri, Apr 2, 2010 at 10:55 AM, Michael Droettboom <md...@st...<mailto:
>> md...@st...>> wrote:
>>
>> Can you provide the actual saved profiler data? The output of the
>> command itself doesn't provide enough information to diagnose the
>> problem, since it doesn't have full file paths etc.
>>
>> When you do (thanks Gökhan for the less verbose version):
>>
>> python.exe -c "import cProfile; cProfile.run('import pylab',
>> 'test.out')"
>>
>> this should produce a binary file "test.out" that can be loaded
>> with the pstats module and used by GUI tools such as KCacheGrind
>> to help us get to the bottom of this.
>>
>> Mike
>>
>> Andrew Kelly wrote:
>>
>> I'm back.
>>
>> My backend is wx. "Import wx" does not really take much time
>> to import at all. In fact time.time() before and after = 0.0
>>
>> Some computer details:
>> Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
>> RAM: 8.00 GB
>>
>> As for the cProfiler output on pylab, I have attached the
>> output as test.txt.
>> -Andy
>>
>> On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever
>> <gok...@gm... <mailto:gok...@gm...>
>> <mailto:gok...@gm... <mailto:gok...@gm...>>>
>>
>> wrote:
>>
>>
>>
>> On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
>> <md...@st... <mailto:md...@st...>
>> <mailto:md...@st... <mailto:md...@st...>>> wrote:
>>
>> My gut says it's probably the GUI framework import that is
>> dominating
>> the time. Which backend are you using? Does importing it
>> take a large
>> amount of time as well?
>>
>> Can you provide a profiler output file we can examine
>> to narrow it
>> down? The following from a command prompt should be
>> sufficient to write
>> out a file called "import.prof":
>>
>> python.exe -c "import cProfile; prof=cProfile.Profile();
>> prof.run('import pylab', 'import.prof')"
>>
>> Mike
>>
>>
>> Just for the records,
>>
>> It reads as:
>>
>> python -c "import cProfile; cProfile.run('import pylab',
>> filename='test.out')
>>
>> in Python 2.6.2
>>
>> These helped me to load the profile output:
>>
>> import pstats
>> stats = pstats.Stats("test.out")
>> stats.print_stats()
>>
>> -- Gökhan
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling,
>> find bugs
>> proactively, and fine-tune applications for parallel
>> performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> <mailto:Mat...@li...>
>> <mailto:Mat...@li...
>> <mailto:Mat...@li...>>
>>
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>> -- Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>>
>>
> --
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
>
From: Michael D. <md...@st...> - 2010年04月02日 19:31:59
It looks like most of the time is being taken up by pytz (timezone 
library), which opens ~500 files. How does the total time of "import 
pytz" compare?
Mike
Andrew Kelly wrote:
> I see. I was wondering why it spit out a binary file.
>
> test.out is attached...
>
> -Andy
>
> On Fri, Apr 2, 2010 at 10:55 AM, Michael Droettboom <md...@st... 
> <mailto:md...@st...>> wrote:
>
> Can you provide the actual saved profiler data? The output of the
> command itself doesn't provide enough information to diagnose the
> problem, since it doesn't have full file paths etc.
>
> When you do (thanks Gökhan for the less verbose version):
>
> python.exe -c "import cProfile; cProfile.run('import pylab',
> 'test.out')"
>
> this should produce a binary file "test.out" that can be loaded
> with the pstats module and used by GUI tools such as KCacheGrind
> to help us get to the bottom of this.
>
> Mike
>
> Andrew Kelly wrote:
>
> I'm back.
>
> My backend is wx. "Import wx" does not really take much time
> to import at all. In fact time.time() before and after = 0.0
>
> Some computer details:
> Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
> RAM: 8.00 GB
>
> As for the cProfiler output on pylab, I have attached the
> output as test.txt.
> -Andy
>
> On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever
> <gok...@gm... <mailto:gok...@gm...>
> <mailto:gok...@gm... <mailto:gok...@gm...>>>
> wrote:
>
>
>
> On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
> <md...@st... <mailto:md...@st...>
> <mailto:md...@st... <mailto:md...@st...>>> wrote:
>
> My gut says it's probably the GUI framework import that is
> dominating
> the time. Which backend are you using? Does importing it
> take a large
> amount of time as well?
>
> Can you provide a profiler output file we can examine
> to narrow it
> down? The following from a command prompt should be
> sufficient to write
> out a file called "import.prof":
>
> python.exe -c "import cProfile; prof=cProfile.Profile();
> prof.run('import pylab', 'import.prof')"
>
> Mike
>
>
> Just for the records,
>
> It reads as:
>
> python -c "import cProfile; cProfile.run('import pylab',
> filename='test.out')
>
> in Python 2.6.2
>
> These helped me to load the profile output:
>
> import pstats
> stats = pstats.Stats("test.out")
> stats.print_stats()
>
> -- Gökhan
>
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling,
> find bugs
> proactively, and fine-tune applications for parallel
> performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> <mailto:Mat...@li...>
> <mailto:Mat...@li...
> <mailto:Mat...@li...>>
>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> -- 
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
>
>
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Michael D. <md...@st...> - 2010年04月02日 17:55:56
Can you provide the actual saved profiler data? The output of the 
command itself doesn't provide enough information to diagnose the 
problem, since it doesn't have full file paths etc.
When you do (thanks Gökhan for the less verbose version):
 python.exe -c "import cProfile; cProfile.run('import pylab', 'test.out')"
this should produce a binary file "test.out" that can be loaded with the 
pstats module and used by GUI tools such as KCacheGrind to help us get 
to the bottom of this.
Mike
Andrew Kelly wrote:
> I'm back.
>
> My backend is wx. "Import wx" does not really take much time to 
> import at all. In fact time.time() before and after = 0.0
>
> Some computer details:
> Processor: AMD Phenom IIx4 810 Processor 2.6 GHz
> RAM: 8.00 GB
>
> As for the cProfiler output on pylab, I have attached the output as 
> test.txt.
> 
> -Andy
>
> On Fri, Apr 2, 2010 at 7:22 AM, Gökhan Sever <gok...@gm... 
> <mailto:gok...@gm...>> wrote:
>
>
>
> On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom
> <md...@st... <mailto:md...@st...>> wrote:
>
> My gut says it's probably the GUI framework import that is
> dominating
> the time. Which backend are you using? Does importing it
> take a large
> amount of time as well?
>
> Can you provide a profiler output file we can examine to narrow it
> down? The following from a command prompt should be
> sufficient to write
> out a file called "import.prof":
>
> python.exe -c "import cProfile; prof=cProfile.Profile();
> prof.run('import pylab', 'import.prof')"
>
> Mike
>
>
> Just for the records,
>
> It reads as:
>
> python -c "import cProfile; cProfile.run('import pylab',
> filename='test.out')
>
> in Python 2.6.2
>
> These helped me to load the profile output:
>
> import pstats
> stats = pstats.Stats("test.out")
> stats.print_stats()
>
> -- 
> Gökhan
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> <mailto:Mat...@li...>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Eric F. <ef...@ha...> - 2010年04月02日 17:01:35
Bruce Ford wrote:
> Below is the example script (sorry!). I've tried all three methods of
> establishing a colormap to no avail. The most promising looked like
> option 2, but that gave me the "AttributeError: 'module' object has no
> attribute 'register_cmap'" error.
> 
> I'm getting this error with:
> Python 2.4 (user requirement because this application I'm building
> will live on a RHEL5 server)
> matplotlib 0.99.1.1
> numpy 1.3.0
> 
> Could this be a versioning issue?
Yes, register_cmap is quite new--but it is just a convenience, and not 
at all necessary. Use of a custom cmap without register_cmap is 
illustrated in the first subplot of the example; you could modify the 
example so that all of the subplots are made without register_cmap.
Eric
> 
> Bruce
> 
> #!/usr/bin/env python
> 
> import numpy as np
> import matplotlib.pyplot as plt
> from matplotlib.colors import LinearSegmentedColormap
> 
> """
> 
> Example: suppose you want red to increase from 0 to 1 over the bottom
> half, green to do the same over the middle half, and blue over the top
> half. Then you would use:
> 
> cdict = {'red': ((0.0, 0.0, 0.0),
> (0.5, 1.0, 1.0),
> (1.0, 1.0, 1.0)),
> 
> 'green': ((0.0, 0.0, 0.0),
> (0.25, 0.0, 0.0),
> (0.75, 1.0, 1.0),
> (1.0, 1.0, 1.0)),
> 
> 'blue': ((0.0, 0.0, 0.0),
> (0.5, 0.0, 0.0),
> (1.0, 1.0, 1.0))}
> 
> If, as in this example, there are no discontinuities in the r, g, and b
> components, then it is quite simple: the second and third element of
> each tuple, above, is the same--call it "y". The first element ("x")
> defines interpolation intervals over the full range of 0 to 1, and it
> must span that whole range. In other words, the values of x divide the
> 0-to-1 range into a set of segments, and y gives the end-point color
> values for each segment.
> 
> Now consider the green. cdict['green'] is saying that for
> 0 <= x <= 0.25, y is zero; no green.
> 0.25 < x <= 0.75, y varies linearly from 0 to 1.
> x > 0.75, y remains at 1, full green.
> 
> If there are discontinuities, then it is a little more complicated.
> Label the 3 elements in each row in the cdict entry for a given color as
> (x, y0, y1). Then for values of x between x[i] and x[i+1] the color
> value is interpolated between y1[i] and y0[i+1].
> 
> Going back to the cookbook example, look at cdict['red']; because y0 !=
> y1, it is saying that for x from 0 to 0.5, red increases from 0 to 1,
> but then it jumps down, so that for x from 0.5 to 1, red increases from
> 0.7 to 1. Green ramps from 0 to 1 as x goes from 0 to 0.5, then jumps
> back to 0, and ramps back to 1 as x goes from 0.5 to 1.
> 
> row i: x y0 y1
> /
> /
> row i+1: x y0 y1
> 
> Above is an attempt to show that for x in the range x[i] to x[i+1], the
> interpolation is between y1[i] and y0[i+1]. So, y0[0] and y1[-1] are
> never used.
> 
> """
> 
> 
> 
> cdict1 = {'red': ((0.0, 0.0, 0.0),
> (0.5, 0.0, 0.1),
> (1.0, 1.0, 1.0)),
> 
> 'green': ((0.0, 0.0, 0.0),
> (1.0, 0.0, 0.0)),
> 
> 'blue': ((0.0, 0.0, 1.0),
> (0.5, 0.1, 0.0),
> (1.0, 0.0, 0.0))
> }
> 
> cdict2 = {'red': ((0.0, 0.0, 0.0),
> (0.5, 0.0, 1.0),
> (1.0, 0.1, 1.0)),
> 
> 'green': ((0.0, 0.0, 0.0),
> (1.0, 0.0, 0.0)),
> 
> 'blue': ((0.0, 0.0, 0.1),
> (0.5, 1.0, 0.0),
> (1.0, 0.0, 0.0))
> }
> 
> cdict3 = {'red': ((0.0, 0.0, 0.0),
> (0.25,0.0, 0.0),
> (0.5, 0.8, 1.0),
> (0.75,1.0, 1.0),
> (1.0, 0.4, 1.0)),
> 
> 'green': ((0.0, 0.0, 0.0),
> (0.25,0.0, 0.0),
> (0.5, 0.9, 0.9),
> (0.75,0.0, 0.0),
> (1.0, 0.0, 0.0)),
> 
> 'blue': ((0.0, 0.0, 0.4),
> (0.25,1.0, 1.0),
> (0.5, 1.0, 0.8),
> (0.75,0.0, 0.0),
> (1.0, 0.0, 0.0))
> }
> 
> # Now we will use this example to illustrate 3 ways of
> # handling custom colormaps.
> # First, the most direct and explicit:
> 
> blue_red1 = LinearSegmentedColormap('BlueRed1', cdict1)
> 
> # Second, create the map explicitly and register it.
> # Like the first method, this method works with any kind
> # of Colormap, not just
> # a LinearSegmentedColormap:
> 
> blue_red2 = LinearSegmentedColormap('BlueRed2', cdict2)
> plt.register_cmap(cmap=blue_red2)
> 
> # Third, for LinearSegmentedColormap only,
> # leave everything to register_cmap:
> 
> plt.register_cmap(name='BlueRed3', data=cdict3) # optional lut kwarg
> 
> x = np.arange(0, np.pi, 0.1)
> y = np.arange(0, 2*np.pi, 0.1)
> X, Y = np.meshgrid(x,y)
> Z = np.cos(X) * np.sin(Y)
> 
> plt.figure(figsize=(10,4))
> plt.subplots_adjust(wspace=0.3)
> 
> plt.subplot(1,3,1)
> plt.imshow(Z, interpolation='nearest', cmap=blue_red1)
> plt.colorbar()
> 
> plt.subplot(1,3,2)
> cmap = plt.get_cmap('BlueRed2')
> plt.imshow(Z, interpolation='nearest', cmap=cmap)
> plt.colorbar()
> 
> # Now we will set the third cmap as the default. One would
> # not normally do this in the middle of a script like this;
> # it is done here just to illustrate the method.
> 
> plt.rcParams['image.cmap'] = 'BlueRed3'
> 
> # Also see below for an alternative, particularly for
> # interactive use.
> 
> plt.subplot(1,3,3)
> plt.imshow(Z, interpolation='nearest')
> plt.colorbar()
> 
> # Or as yet another variation, we could replace the rcParams
> # specification *before* the imshow with the following *after*
> # imshow:
> #
> # plt.set_cmap('BlueRed3')
> #
> # This sets the new default *and* sets the colormap of the last
> # image-like item plotted via pyplot, if any.
> 
> 
> plt.suptitle('Custom Blue-Red colormaps')
> 
> plt.show()
> ---------------------------------------
> Bruce W. Ford
> Clear Science, Inc.
> br...@cl...
> bru...@na...
> http://www.ClearScienceInc.com
> Phone/Fax: 904-379-9704
> 8241 Parkridge Circle N.
> Jacksonville, FL 32211
> Skype: bruce.w.ford
> Google Talk: fo...@gm...
> 
> 
> 
> On Thu, Apr 1, 2010 at 6:30 PM, Chloe Lewis <ch...@be...> wrote:
>> The example works for me; Python 2.6.4 (recent Enthought install).
>>
>> Can you use your new colormap without registering it?
>>
>> &C
>>
>> On Apr 1, 2010, at 1 Apr, 2:14 PM, Bruce Ford wrote:
>>
>>> I'm running into walls trying to create a custom cmap.
>>>
>>> Running the example custom_cmap.py unchanged, I get :
>>>
>>> AttributeError: 'module' object has no attribute 'register_cmap'
>>> args = ("'module' object has no attribute 'register_cmap'",)
>>>
>>> I've included custom_cmap.py below. It's a major shortcoming that
>>> there is not a suitable anomaly cmap (with white about the middle).
>>> Please consider this for an addition.
>>>
>>> Anyway, what am I missing with this error? Thanks so much!
>>>
>>> Bruce
>>> ---------------------------------------
>>> Bruce W. Ford
>>> Clear Science, Inc.
>>> br...@cl...
>>> http://www.ClearScienceInc.com
>>> Phone/Fax: 904-379-9704
>>> 8241 Parkridge Circle N.
>>> Jacksonville, FL 32211
>>> Skype: bruce.w.ford
>>> Google Talk: fo...@gm...
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Download Intel&#174; Parallel Studio Eval
>>> Try the new software tools for yourself. Speed compiling, find bugs
>>> proactively, and fine-tune applications for parallel performance.
>>> See why Intel Parallel Studio got high marks during beta.
>>> http://p.sf.net/sfu/intel-sw-dev
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>> Chloe Lewis
>> Graduate student, Amundson Lab
>> Ecosystem Sciences
>> 137 Mulford Hall
>> Berkeley, CA 94720-3114
>> http://nature.berkeley.edu/~chlewis
>>
>>
>>
>>
>>
>>
>>
>>
> 
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Thomas R. <tho...@gm...> - 2010年04月02日 15:44:47
I just tried running epstopdf, and this does work correctly, so maybe now the only issue is that Preview.app on mac always uses pstopdf, even for eps files? (which then is not a matplotlib issue) I also checked that giving the file the extension '.ps' produces a ps file, and that does open correctly in Preview.app.
Cheers,
Tom
On Apr 2, 2010, at 11:20 AM, Michael Droettboom wrote:
> At least on my Linux box with gs 7.07, I have to use epstopdf (not pstopdf) to convert an eps file to a pdf. ps2pdf does work for both .ps and .eps files however.
> 
> It looks like the 0.99.1.1 file is not in fact an .eps file, but a .ps file, (it certainly hasn't had the ps2eps function run on it) and I think it was probably a bug (now fixed) that 0.99.1.1 was writing out the wrong kind of file. 
> It seems the relevant change is in r8102: "fix some issues in the bbox after the postscript distiller is run". This change removed a commented out call to ps2eps. I'm a bit out of my depth here as to why that change was made, and why .eps files seemingly haven't been true .eps files for a long time prior to that change. Anyone else?
> 
> Mike
> 
> Thomas Robitaille wrote:
>> It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file fixes the problem, although I don't understand postscript well enough to understand why that is.
>> 
>> Thomas
>> 
>> On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:
>> 
>> 
>>> Can you provide us with the EPS file? What version of LaTeX is this?
>>> 
>>> Mike
>>> 
>>> Thomas Robitaille wrote:
>>> 
>>>> Hello,
>>>> 
>>>> I upgraded to the latest svn version of matplotlib today, and found that eps files produced with the system latex now seem to be invalid. For example, if I run the following script
>>>> 
>>>> import matplotlib
>>>> matplotlib.use('Agg')
>>>> import matplotlib.pyplot as mpl
>>>> 
>>>> mpl.rc('text', usetex=False)
>>>> 
>>>> fig = mpl.figure()
>>>> ax = fig.add_subplot(1,1,1)
>>>> fig.savefig('test_notex.eps')
>>>> 
>>>> mpl.rc('text', usetex=True)
>>>> 
>>>> fig = mpl.figure()
>>>> ax = fig.add_subplot(1,1,1)
>>>> fig.savefig('test_tex.eps')
>>>> 
>>>> and try running pstopdf on them (on MacOS 10.6) I get the following
>>>> 
>>>> air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file produced. ] %%
>>>> air:air tom$ pstopdf test_notex.eps air:air tom$ So the file with the system LaTeX enabled no longer works. ps2pdf still works, but the error with pstopdf is important, because for example Preview.app on mac relies on pstopdf, not ps2pdf.
>>>> 
>>>> I tried this on two different computers under MacOS 10.6, and tried with ghostscript 8.70 and 8.71 installed, and the problem occurs either way.
>>>> 
>>>> Does anyone know what might be causing this? I submitted a bug report a little while back about this
>>>> 
>>>> https://sourceforge.net/tracker/?func=detail&aid=2974953&group_id=80706&atid=560720
>>>> 
>>>> Thanks in advance for any help,
>>>> 
>>>> Thomas
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> Download Intel&#174; Parallel Studio Eval
>>>> Try the new software tools for yourself. Speed compiling, find bugs
>>>> proactively, and fine-tune applications for parallel performance.
>>>> See why Intel Parallel Studio got high marks during beta.
>>>> http://p.sf.net/sfu/intel-sw-dev
>>>> _______________________________________________
>>>> Matplotlib-users mailing list
>>>> Mat...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>> 
>>> -- 
>>> Michael Droettboom
>>> Science Software Branch
>>> Operations and Engineering Division
>>> Space Telescope Science Institute
>>> Operated by AURA for NASA
>>> 
>>> 
>> 
>> 
> 
> -- 
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
> 
From: Michael D. <md...@st...> - 2010年04月02日 15:20:34
At least on my Linux box with gs 7.07, I have to use epstopdf (not 
pstopdf) to convert an eps file to a pdf. ps2pdf does work for both .ps 
and .eps files however.
It looks like the 0.99.1.1 file is not in fact an .eps file, but a .ps 
file, (it certainly hasn't had the ps2eps function run on it) and I 
think it was probably a bug (now fixed) that 0.99.1.1 was writing out 
the wrong kind of file. 
It seems the relevant change is in r8102: "fix some issues in the bbox 
after the postscript distiller is run". This change removed a commented 
out call to ps2eps. I'm a bit out of my depth here as to why that 
change was made, and why .eps files seemingly haven't been true .eps 
files for a long time prior to that change. Anyone else?
Mike
Thomas Robitaille wrote:
> It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file fixes the problem, although I don't understand postscript well enough to understand why that is.
>
> Thomas
>
> On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:
>
> 
>> Can you provide us with the EPS file? What version of LaTeX is this?
>>
>> Mike
>>
>> Thomas Robitaille wrote:
>> 
>>> Hello,
>>>
>>> I upgraded to the latest svn version of matplotlib today, and found that eps files produced with the system latex now seem to be invalid. For example, if I run the following script
>>>
>>> import matplotlib
>>> matplotlib.use('Agg')
>>> import matplotlib.pyplot as mpl
>>>
>>> mpl.rc('text', usetex=False)
>>>
>>> fig = mpl.figure()
>>> ax = fig.add_subplot(1,1,1)
>>> fig.savefig('test_notex.eps')
>>>
>>> mpl.rc('text', usetex=True)
>>>
>>> fig = mpl.figure()
>>> ax = fig.add_subplot(1,1,1)
>>> fig.savefig('test_tex.eps')
>>>
>>> and try running pstopdf on them (on MacOS 10.6) I get the following
>>>
>>> air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file produced. ] %%
>>> air:air tom$ pstopdf test_notex.eps air:air tom$ 
>>> So the file with the system LaTeX enabled no longer works. ps2pdf still works, but the error with pstopdf is important, because for example Preview.app on mac relies on pstopdf, not ps2pdf.
>>>
>>> I tried this on two different computers under MacOS 10.6, and tried with ghostscript 8.70 and 8.71 installed, and the problem occurs either way.
>>>
>>> Does anyone know what might be causing this? I submitted a bug report a little while back about this
>>>
>>> https://sourceforge.net/tracker/?func=detail&aid=2974953&group_id=80706&atid=560720
>>>
>>> Thanks in advance for any help,
>>>
>>> Thomas
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Download Intel&#174; Parallel Studio Eval
>>> Try the new software tools for yourself. Speed compiling, find bugs
>>> proactively, and fine-tune applications for parallel performance.
>>> See why Intel Parallel Studio got high marks during beta.
>>> http://p.sf.net/sfu/intel-sw-dev
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> 
>>> 
>> -- 
>> Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>> 
>
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Jae-Joon L. <lee...@gm...> - 2010年04月02日 15:04:12
I just had a quick look, but while extra "restore" could be a problem,
the erroneous one may not be the one at line 1073, but the one at line
1066.
I believe that the "restore" at 1073 is written by "pstoeps" function
in backend_ps.py, and this function did write a matching "save" at
line 11.
Regards,
-JJ
On Fri, Apr 2, 2010 at 10:35 AM, Thomas Robitaille
<tho...@gm...> wrote:
> It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file fixes the problem, although I don't understand postscript well enough to understand why that is.
>
> Thomas
>
> On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:
>
>> Can you provide us with the EPS file? What version of LaTeX is this?
>>
>> Mike
>>
>> Thomas Robitaille wrote:
>>> Hello,
>>>
>>> I upgraded to the latest svn version of matplotlib today, and found that eps files produced with the system latex now seem to be invalid. For example, if I run the following script
>>>
>>> import matplotlib
>>> matplotlib.use('Agg')
>>> import matplotlib.pyplot as mpl
>>>
>>> mpl.rc('text', usetex=False)
>>>
>>> fig = mpl.figure()
>>> ax = fig.add_subplot(1,1,1)
>>> fig.savefig('test_notex.eps')
>>>
>>> mpl.rc('text', usetex=True)
>>>
>>> fig = mpl.figure()
>>> ax = fig.add_subplot(1,1,1)
>>> fig.savefig('test_tex.eps')
>>>
>>> and try running pstopdf on them (on MacOS 10.6) I get the following
>>>
>>> air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file produced. ] %%
>>> air:air tom$ pstopdf test_notex.eps air:air tom$
>>> So the file with the system LaTeX enabled no longer works. ps2pdf still works, but the error with pstopdf is important, because for example Preview.app on mac relies on pstopdf, not ps2pdf.
>>>
>>> I tried this on two different computers under MacOS 10.6, and tried with ghostscript 8.70 and 8.71 installed, and the problem occurs either way.
>>>
>>> Does anyone know what might be causing this? I submitted a bug report a little while back about this
>>>
>>> https://sourceforge.net/tracker/?func=detail&aid=2974953&group_id=80706&atid=560720
>>>
>>> Thanks in advance for any help,
>>>
>>> Thomas
>>>
>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Download Intel&#174; Parallel Studio Eval
>>> Try the new software tools for yourself. Speed compiling, find bugs
>>> proactively, and fine-tune applications for parallel performance.
>>> See why Intel Parallel Studio got high marks during beta.
>>> http://p.sf.net/sfu/intel-sw-dev
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>> --
>> Michael Droettboom
>> Science Software Branch
>> Operations and Engineering Division
>> Space Telescope Science Institute
>> Operated by AURA for NASA
>>
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Bruce F. <br...@cl...> - 2010年04月02日 14:41:42
Below is the example script (sorry!). I've tried all three methods of
establishing a colormap to no avail. The most promising looked like
option 2, but that gave me the "AttributeError: 'module' object has no
attribute 'register_cmap'" error.
I'm getting this error with:
Python 2.4 (user requirement because this application I'm building
will live on a RHEL5 server)
matplotlib 0.99.1.1
numpy 1.3.0
Could this be a versioning issue?
Bruce
#!/usr/bin/env python
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
"""
Example: suppose you want red to increase from 0 to 1 over the bottom
half, green to do the same over the middle half, and blue over the top
half. Then you would use:
cdict = {'red': ((0.0, 0.0, 0.0),
 (0.5, 1.0, 1.0),
 (1.0, 1.0, 1.0)),
 'green': ((0.0, 0.0, 0.0),
 (0.25, 0.0, 0.0),
 (0.75, 1.0, 1.0),
 (1.0, 1.0, 1.0)),
 'blue': ((0.0, 0.0, 0.0),
 (0.5, 0.0, 0.0),
 (1.0, 1.0, 1.0))}
If, as in this example, there are no discontinuities in the r, g, and b
components, then it is quite simple: the second and third element of
each tuple, above, is the same--call it "y". The first element ("x")
defines interpolation intervals over the full range of 0 to 1, and it
must span that whole range. In other words, the values of x divide the
0-to-1 range into a set of segments, and y gives the end-point color
values for each segment.
Now consider the green. cdict['green'] is saying that for
0 <= x <= 0.25, y is zero; no green.
0.25 < x <= 0.75, y varies linearly from 0 to 1.
x > 0.75, y remains at 1, full green.
If there are discontinuities, then it is a little more complicated.
Label the 3 elements in each row in the cdict entry for a given color as
(x, y0, y1). Then for values of x between x[i] and x[i+1] the color
value is interpolated between y1[i] and y0[i+1].
Going back to the cookbook example, look at cdict['red']; because y0 !=
y1, it is saying that for x from 0 to 0.5, red increases from 0 to 1,
but then it jumps down, so that for x from 0.5 to 1, red increases from
0.7 to 1. Green ramps from 0 to 1 as x goes from 0 to 0.5, then jumps
back to 0, and ramps back to 1 as x goes from 0.5 to 1.
row i: x y0 y1
 /
 /
row i+1: x y0 y1
Above is an attempt to show that for x in the range x[i] to x[i+1], the
interpolation is between y1[i] and y0[i+1]. So, y0[0] and y1[-1] are
never used.
"""
cdict1 = {'red': ((0.0, 0.0, 0.0),
 (0.5, 0.0, 0.1),
 (1.0, 1.0, 1.0)),
 'green': ((0.0, 0.0, 0.0),
 (1.0, 0.0, 0.0)),
 'blue': ((0.0, 0.0, 1.0),
 (0.5, 0.1, 0.0),
 (1.0, 0.0, 0.0))
 }
cdict2 = {'red': ((0.0, 0.0, 0.0),
 (0.5, 0.0, 1.0),
 (1.0, 0.1, 1.0)),
 'green': ((0.0, 0.0, 0.0),
 (1.0, 0.0, 0.0)),
 'blue': ((0.0, 0.0, 0.1),
 (0.5, 1.0, 0.0),
 (1.0, 0.0, 0.0))
 }
cdict3 = {'red': ((0.0, 0.0, 0.0),
 (0.25,0.0, 0.0),
 (0.5, 0.8, 1.0),
 (0.75,1.0, 1.0),
 (1.0, 0.4, 1.0)),
 'green': ((0.0, 0.0, 0.0),
 (0.25,0.0, 0.0),
 (0.5, 0.9, 0.9),
 (0.75,0.0, 0.0),
 (1.0, 0.0, 0.0)),
 'blue': ((0.0, 0.0, 0.4),
 (0.25,1.0, 1.0),
 (0.5, 1.0, 0.8),
 (0.75,0.0, 0.0),
 (1.0, 0.0, 0.0))
 }
# Now we will use this example to illustrate 3 ways of
# handling custom colormaps.
# First, the most direct and explicit:
blue_red1 = LinearSegmentedColormap('BlueRed1', cdict1)
# Second, create the map explicitly and register it.
# Like the first method, this method works with any kind
# of Colormap, not just
# a LinearSegmentedColormap:
blue_red2 = LinearSegmentedColormap('BlueRed2', cdict2)
plt.register_cmap(cmap=blue_red2)
# Third, for LinearSegmentedColormap only,
# leave everything to register_cmap:
plt.register_cmap(name='BlueRed3', data=cdict3) # optional lut kwarg
x = np.arange(0, np.pi, 0.1)
y = np.arange(0, 2*np.pi, 0.1)
X, Y = np.meshgrid(x,y)
Z = np.cos(X) * np.sin(Y)
plt.figure(figsize=(10,4))
plt.subplots_adjust(wspace=0.3)
plt.subplot(1,3,1)
plt.imshow(Z, interpolation='nearest', cmap=blue_red1)
plt.colorbar()
plt.subplot(1,3,2)
cmap = plt.get_cmap('BlueRed2')
plt.imshow(Z, interpolation='nearest', cmap=cmap)
plt.colorbar()
# Now we will set the third cmap as the default. One would
# not normally do this in the middle of a script like this;
# it is done here just to illustrate the method.
plt.rcParams['image.cmap'] = 'BlueRed3'
# Also see below for an alternative, particularly for
# interactive use.
plt.subplot(1,3,3)
plt.imshow(Z, interpolation='nearest')
plt.colorbar()
# Or as yet another variation, we could replace the rcParams
# specification *before* the imshow with the following *after*
# imshow:
#
# plt.set_cmap('BlueRed3')
#
# This sets the new default *and* sets the colormap of the last
# image-like item plotted via pyplot, if any.
plt.suptitle('Custom Blue-Red colormaps')
plt.show()
---------------------------------------
Bruce W. Ford
Clear Science, Inc.
br...@cl...
bru...@na...
http://www.ClearScienceInc.com
Phone/Fax: 904-379-9704
8241 Parkridge Circle N.
Jacksonville, FL 32211
Skype: bruce.w.ford
Google Talk: fo...@gm...
On Thu, Apr 1, 2010 at 6:30 PM, Chloe Lewis <ch...@be...> wrote:
> The example works for me; Python 2.6.4 (recent Enthought install).
>
> Can you use your new colormap without registering it?
>
> &C
>
> On Apr 1, 2010, at 1 Apr, 2:14 PM, Bruce Ford wrote:
>
>> I'm running into walls trying to create a custom cmap.
>>
>> Running the example custom_cmap.py unchanged, I get :
>>
>> AttributeError: 'module' object has no attribute 'register_cmap'
>>   args = ("'module' object has no attribute 'register_cmap'",)
>>
>> I've included custom_cmap.py below. It's a major shortcoming that
>> there is not a suitable anomaly cmap (with white about the middle).
>> Please consider this for an addition.
>>
>> Anyway, what am I missing with this error? Thanks so much!
>>
>> Bruce
>> ---------------------------------------
>> Bruce W. Ford
>> Clear Science, Inc.
>> br...@cl...
>> http://www.ClearScienceInc.com
>> Phone/Fax: 904-379-9704
>> 8241 Parkridge Circle N.
>> Jacksonville, FL 32211
>> Skype: bruce.w.ford
>> Google Talk: fo...@gm...
>>
>>
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
> Chloe Lewis
> Graduate student, Amundson Lab
> Ecosystem Sciences
> 137 Mulford Hall
> Berkeley, CA 94720-3114
> http://nature.berkeley.edu/~chlewis
>
>
>
>
>
>
>
>
From: Thomas R. <tho...@gm...> - 2010年04月02日 14:35:56
It seems that removing 'restore' on line 1073 of the test_tex_r8216.eps file fixes the problem, although I don't understand postscript well enough to understand why that is.
Thomas
On Apr 2, 2010, at 9:30 AM, Michael Droettboom wrote:
> Can you provide us with the EPS file? What version of LaTeX is this?
> 
> Mike
> 
> Thomas Robitaille wrote:
>> Hello,
>> 
>> I upgraded to the latest svn version of matplotlib today, and found that eps files produced with the system latex now seem to be invalid. For example, if I run the following script
>> 
>> import matplotlib
>> matplotlib.use('Agg')
>> import matplotlib.pyplot as mpl
>> 
>> mpl.rc('text', usetex=False)
>> 
>> fig = mpl.figure()
>> ax = fig.add_subplot(1,1,1)
>> fig.savefig('test_notex.eps')
>> 
>> mpl.rc('text', usetex=True)
>> 
>> fig = mpl.figure()
>> ax = fig.add_subplot(1,1,1)
>> fig.savefig('test_tex.eps')
>> 
>> and try running pstopdf on them (on MacOS 10.6) I get the following
>> 
>> air:air tom$ pstopdf test_tex.eps %%[ Warning: Empty job. No PDF file produced. ] %%
>> air:air tom$ pstopdf test_notex.eps air:air tom$ 
>> So the file with the system LaTeX enabled no longer works. ps2pdf still works, but the error with pstopdf is important, because for example Preview.app on mac relies on pstopdf, not ps2pdf.
>> 
>> I tried this on two different computers under MacOS 10.6, and tried with ghostscript 8.70 and 8.71 installed, and the problem occurs either way.
>> 
>> Does anyone know what might be causing this? I submitted a bug report a little while back about this
>> 
>> https://sourceforge.net/tracker/?func=detail&aid=2974953&group_id=80706&atid=560720
>> 
>> Thanks in advance for any help,
>> 
>> Thomas
>> 
>> 
>> 
>> 
>> 
>> ------------------------------------------------------------------------------
>> Download Intel&#174; Parallel Studio Eval
>> Try the new software tools for yourself. Speed compiling, find bugs
>> proactively, and fine-tune applications for parallel performance.
>> See why Intel Parallel Studio got high marks during beta.
>> http://p.sf.net/sfu/intel-sw-dev
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
> 
> -- 
> Michael Droettboom
> Science Software Branch
> Operations and Engineering Division
> Space Telescope Science Institute
> Operated by AURA for NASA
> 
From: Gökhan S. <gok...@gm...> - 2010年04月02日 14:22:29
On Fri, Apr 2, 2010 at 8:28 AM, Michael Droettboom <md...@st...> wrote:
> My gut says it's probably the GUI framework import that is dominating
> the time. Which backend are you using? Does importing it take a large
> amount of time as well?
>
> Can you provide a profiler output file we can examine to narrow it
> down? The following from a command prompt should be sufficient to write
> out a file called "import.prof":
>
> python.exe -c "import cProfile; prof=cProfile.Profile();
> prof.run('import pylab', 'import.prof')"
>
> Mike
>
Just for the records,
It reads as:
python -c "import cProfile; cProfile.run('import pylab',
filename='test.out')
in Python 2.6.2
These helped me to load the profile output:
import pstats
stats = pstats.Stats("test.out")
stats.print_stats()
-- 
Gökhan
From: Thomas R. <tho...@gm...> - 2010年04月02日 14:09:33
Attached is a file made using matplotlib 0.99.1.1 (which opens correctly) and one using matplotlib r8216 (which doesn't). Here's what I get for LaTeX:
$ latex --version
pdfTeX 3.1415926-1.40.10-2.2 (TeX Live 2009)
kpathsea version 5.0.0
Copyright 2009 Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
There is NO warranty. Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Peter Breitenlohner (eTeX)/Han The Thanh (pdfTeX).
Compiled with libpng 1.2.39; using libpng 1.2.39
Compiled with zlib 1.2.3; using zlib 1.2.3
Compiled with xpdf version 3.02pl3
It is the version that comes with MacTex 2009. Here is the ghostscript version:
$ gs --version
8.70
I just produced these two files on the same computer, and the only thing I changed was the matplotlib version. LaTeX and ghostscript are unchanged
I hope this helps,
Thomas
From: Thomas R. <tho...@gm...> - 2010年04月02日 13:52:24
Thomas Robitaille wrote:
> 
> It looks like the zlib website removes previous version of its library
> that were previously available for download, so the part in make.osx where
> http://www.zlib.net/zlib-1.2.3.tar.gz is fetched now fails (since the
> current version is 1.2.4). The error in the matplotlib building is not
> explicit enough (incorrect archive type) - maybe one could catch such 404s
> and print out an error suggesting to increase the ZLIBVERSION variable?
> 
> I tried changing ZLIBVERSION to 1.2.4 and the following occurs when
> building zlib:
> 
> ...
> make[1]: *** No rule to make target `libz.dylib', needed by
> `install-libs'. Stop.
> make[1]: *** Waiting for unfinished jobs....
> make: *** [zlib] Error 2
> 
I have submitted a simple patch that fixes all these issues:
https://sourceforge.net/tracker/?func=detail&aid=2981126&group_id=80706&atid=560722
Matplotlib then compiles 'out of the box' for 10.6.
Cheers,
Thomas
-- 
View this message in context: http://old.nabble.com/MacOS-10.6-install-dependency-building-fails-%28r8214%29-tp28069099p28119205.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Michael D. <md...@st...> - 2010年04月02日 13:38:35
Can you provide us with the EPS file? What version of LaTeX is this?
Mike
Thomas Robitaille wrote:
> Hello,
>
> I upgraded to the latest svn version of matplotlib today, and found that eps files produced with the system latex now seem to be invalid. For example, if I run the following script
>
> import matplotlib
> matplotlib.use('Agg')
> import matplotlib.pyplot as mpl
>
> mpl.rc('text', usetex=False)
>
> fig = mpl.figure()
> ax = fig.add_subplot(1,1,1)
> fig.savefig('test_notex.eps')
>
> mpl.rc('text', usetex=True)
>
> fig = mpl.figure()
> ax = fig.add_subplot(1,1,1)
> fig.savefig('test_tex.eps')
>
> and try running pstopdf on them (on MacOS 10.6) I get the following
>
> air:air tom$ pstopdf test_tex.eps 
> %%[ Warning: Empty job. No PDF file produced. ] %%
> air:air tom$ pstopdf test_notex.eps 
> air:air tom$ 
>
> So the file with the system LaTeX enabled no longer works. ps2pdf still works, but the error with pstopdf is important, because for example Preview.app on mac relies on pstopdf, not ps2pdf.
>
> I tried this on two different computers under MacOS 10.6, and tried with ghostscript 8.70 and 8.71 installed, and the problem occurs either way.
>
> Does anyone know what might be causing this? I submitted a bug report a little while back about this
>
> https://sourceforge.net/tracker/?func=detail&aid=2974953&group_id=80706&atid=560720
>
> Thanks in advance for any help,
>
> Thomas
>
>
>
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Michael D. <md...@st...> - 2010年04月02日 13:28:43
My gut says it's probably the GUI framework import that is dominating 
the time. Which backend are you using? Does importing it take a large 
amount of time as well? 
Can you provide a profiler output file we can examine to narrow it 
down? The following from a command prompt should be sufficient to write 
out a file called "import.prof":
 python.exe -c "import cProfile; prof=cProfile.Profile(); 
prof.run('import pylab', 'import.prof')"
Mike
C M wrote:
> On Thu, Apr 1, 2010 at 7:17 PM, Eric Firing <ef...@ha...> wrote:
> 
>> Andrew Kelly wrote:
>> 
>>> Has anyone had any success in speeding up the mpl imports?
>>>
>>> "import matplotlib.pyplot as plt"
>>> ( or "from matplotlib.figure import Figure")
>>>
>>> takes 6 full seconds to load. That seems excessive. Any ideas?
>>>
>>> -Andy
>>> 
>> Andy,
>>
>> A couple replies came back directly to me (probably intended for the
>> list, though), and both reported results similar to yours, on Windows
>> machines only. What OS and version are you running?
>> 
>
> Sorry Eric, that was indeed intended for the list. Just for the
> list's sake, I'll repeat it:
>
> It takes longer than any other Python module for me, too, about 5-6
> seconds on a "cold" load (on Windows), though faster on a "warm" load.
> I am running it locally on a laptop that is 1.7 GHz Intel Pentium
> laptop with 1Meg RAM.
>
> And I should add: I don't currently have Linux installed, but will
> soon again I hope, and I will take note of how long it takes on Linux.
>
> Thanks,
> Che
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
From: Michael D. <md...@st...> - 2010年04月02日 13:15:24
Can you set "verbose.level" to "debug-annoying" in your matplotlibrc 
file, and then send the output to this list. That may help us track 
down where the font lookup is failing. Also, what platform and version 
of matplotlib are you running?
Mike
Alex S wrote:
> Hi, sorry I wasn't too clear... I changed that, but I don't seem to be able
> to choose between the different serif fonts, it just always gives me the
> default...
>
>
>
> Alex S wrote:
> 
>> Hi there,
>> I'm trying to change the font default on my graph to New Century
>> Schoolbook. I'm trying to do this by editing the matplotlibrc file. 
>> Unfortunately, although I'm able to change the font.family, I can't figure
>> out how to make it use something other than the default in the family... 
>> I tried changing the list further down to only include the font I want,
>> like this:
>>
>> font.serif : New Century Schoolbook #Bitstream Vera Serif, New
>> Century Schoolbook, Century Schoolbook L, Utopia, ITC Bookman, Bookman,
>> Nimbus Roman No9 L, Times New Roman, Times, Palatino, Charter, serif
>>
>> (note I commented out the other fonts, just rearranging the list to put
>> New Century Schoolbook first didn't seem to work either)
>>
>> Could anyone tell me what I'm doing wrong?
>> Thanks a lot!
>> Alex
>>
>>
>> 
>
> 
-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA
On 4/2/10 6:32 AM, Will Hewson wrote:
> This is great Jeff, thanks for the help - I'll give it a try over the weekend
> (it's bank holiday here in the UK!) and get back to you, if I'm still having
> trouble I'll stick up the plotting data too... thanks again.
>
> Will
> 
Will: I forgot to mention that contourf will work on your data without 
having to interpolate to projection coordinates.
-Jeff
>
>
> Jeff Whitaker wrote:
> 
>> On 4/2/10 4:27 AM, Will Hewson wrote:
>> 
>>> Hi forum/ mailing list, When I plot in the orthographic projection I'm
>>> getting the large artefact shown below extending away from the north
>>> east of the globe. I'm not finding the same problem when plotting in a
>>> full globe projection so I'm presuming the problem is with the way I'm
>>> projecting everything rather than my data itself. I've included my
>>> plotting code below, if anyone is able to spot some glaring omissions/
>>> errors I'd be most grateful (I've been using python/ matplotlib for
>>> only a couple of weeks now!).
>>> 
>> Will: I think what's happening is that pcolormesh is having trouble
>> dealing with the higher curvlinear grid, which becomes nearly
>> pathological near the horizon of the projection. If you take a look at
>> the test.py file in the basemap examples directory, you'll see an
>> example orthographic plot that solves this problem by first
>> interpolating the data to a regular grid in projection coordinates (with
>> values over the plot horizon masked). The example uses imshow, but
>> pcolormesh works as well. A standalone version of the example using
>> pcolormesah is attached, which uses data files in the basemap examples
>> directory.
>>
>> -Jeff
>>
>> from mpl_toolkits.basemap import Basemap, shiftgrid
>> import numpy as np
>> import matplotlib.pyplot as plt
>> # read in topo data (on a regular lat/lon grid)
>> # longitudes go from 20 to 380.
>> topoin = np.loadtxt('etopo20data.gz')
>> lons = np.loadtxt('etopo20lons.gz')
>> lats = np.loadtxt('etopo20lats.gz')
>> # shift data so lons go from -180 to 180 instead of 20 to 380.
>> topoin,lons = shiftgrid(180.,topoin,lons,start=False)
>> m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
>> # transform to nx x ny regularly spaced native projection grid
>> nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
>> topodat,x,y =\
>> m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
>> # create the figure.
>> fig=plt.figure(figsize=(8,8))
>> im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
>> m.drawcoastlines()
>> m.drawparallels(np.arange(0.,80,20.))
>> m.drawmeridians(np.arange(10.,360.,30.))
>> m.drawmapboundary()
>> plt.show()
>>
>>
>> 
> 
This is great Jeff, thanks for the help - I'll give it a try over the weekend
(it's bank holiday here in the UK!) and get back to you, if I'm still having
trouble I'll stick up the plotting data too... thanks again.
Will
Jeff Whitaker wrote:
> 
> On 4/2/10 4:27 AM, Will Hewson wrote:
>> Hi forum/ mailing list, When I plot in the orthographic projection I'm 
>> getting the large artefact shown below extending away from the north 
>> east of the globe. I'm not finding the same problem when plotting in a 
>> full globe projection so I'm presuming the problem is with the way I'm 
>> projecting everything rather than my data itself. I've included my 
>> plotting code below, if anyone is able to spot some glaring omissions/ 
>> errors I'd be most grateful (I've been using python/ matplotlib for 
>> only a couple of weeks now!).
> Will: I think what's happening is that pcolormesh is having trouble 
> dealing with the higher curvlinear grid, which becomes nearly 
> pathological near the horizon of the projection. If you take a look at 
> the test.py file in the basemap examples directory, you'll see an 
> example orthographic plot that solves this problem by first 
> interpolating the data to a regular grid in projection coordinates (with 
> values over the plot horizon masked). The example uses imshow, but 
> pcolormesh works as well. A standalone version of the example using 
> pcolormesah is attached, which uses data files in the basemap examples 
> directory.
> 
> -Jeff
> 
> from mpl_toolkits.basemap import Basemap, shiftgrid
> import numpy as np
> import matplotlib.pyplot as plt
> # read in topo data (on a regular lat/lon grid)
> # longitudes go from 20 to 380.
> topoin = np.loadtxt('etopo20data.gz')
> lons = np.loadtxt('etopo20lons.gz')
> lats = np.loadtxt('etopo20lats.gz')
> # shift data so lons go from -180 to 180 instead of 20 to 380.
> topoin,lons = shiftgrid(180.,topoin,lons,start=False)
> m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
> # transform to nx x ny regularly spaced native projection grid
> nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
> topodat,x,y =\
> m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
> # create the figure.
> fig=plt.figure(figsize=(8,8))
> im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
> m.drawcoastlines()
> m.drawparallels(np.arange(0.,80,20.))
> m.drawmeridians(np.arange(10.,360.,30.))
> m.drawmapboundary()
> plt.show()
> 
> 
-- 
View this message in context: http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117654p28118555.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
from mpl_toolkits.basemap import Basemap, shiftgrid
import numpy as np
import matplotlib.pyplot as plt
# read in topo data (on a regular lat/lon grid)
# longitudes go from 20 to 380.
topoin = np.loadtxt('etopo20data.gz')
lons = np.loadtxt('etopo20lons.gz')
lats = np.loadtxt('etopo20lats.gz')
# shift data so lons go from -180 to 180 instead of 20 to 380.
topoin,lons = shiftgrid(180.,topoin,lons,start=False)
m = Basemap(projection='ortho',lon_0=-105,lat_0=40,resolution='l')
# transform to nx x ny regularly spaced native projection grid
nx = int((m.xmax-m.xmin)/40000.)+1; ny = int((m.ymax-m.ymin)/40000.)+1
topodat,x,y =\
m.transform_scalar(topoin,lons,lats,nx,ny,returnxy=True,masked=True,order=1)
# create the figure.
fig=plt.figure(figsize=(8,8))
im = m.pcolormesh(x,y,topodat,cmap=plt.cm.jet)
m.drawcoastlines()
m.drawparallels(np.arange(0.,80,20.))
m.drawmeridians(np.arange(10.,360.,30.))
m.drawmapboundary()
plt.show()
On 4/2/10 4:27 AM, Will Hewson wrote:
> Hi forum/ mailing list, When I plot in the orthographic projection I'm 
> getting the large artefact shown below extending away from the north 
> east of the globe. I'm not finding the same problem when plotting in a 
> full globe projection so I'm presuming the problem is with the way I'm 
> projecting everything rather than my data itself. I've included my 
> plotting code below, if anyone is able to spot some glaring omissions/ 
> errors I'd be most grateful (I've been using python/ matplotlib for 
> only a couple of weeks now!).
>
Will: You'll have to provide the data so we can actually run the script.
-Jeff
> #!/usr/local/bin/python2.6
> import numpy as np
> import matplotlib.pyplot as plt
> from mpl_toolkits.basemap import Basemap
> import sys, glob
>
> #input must be 3 col file of lons lats and data
> #bins input values into half degree grid, ignores negative values
>
> plts = glob.glob('*.plt')
> x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
> grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
> n_vals = np.zeros((360,720)) #mean divisor
> dat = np.zeros((360,720)) #2D grid of zeros
>
> for pt in plts:
>
> in_file = pt
> data = np.loadtxt(in_file, comments = ';')
> fname = in_file.split('.')[0]
>
> lon = data[:,0] #original 1D list
> lat = data[:,1] #original 1D list
> slcol = data[:,2] #z data
>
> lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
> lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5
>
> ##keep the below between files
>
> j=0
>
> for i in slcol:
> if lon[j] < 0:
> grid_lon_ind = 360+(lon[j]*2)
> grid_lat_ind = 180+(lat[j]*2)
> else:
> grid_lon_ind = 360-(lon[j]*2)
> grid_lat_ind = 180+(lat[j]*2)
>
> if i > 0:
> dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
> n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter by 1 
> for each extra value
> j+=1
>
> dat = np.nan_to_num(dat/n_vals)
>
> #create map object
> fig = plt.figure()
> m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0, 
> resolution='l', area_thresh=10000.)
> #m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=10000.)
>
> X,Y = m(grid_lon, grid_lat)
>
> #pass all 2d arrays to pcolor
> im = m.pcolormesh(X,Y,dat)
>
> #add coastlines, globe boundary and colourbar
> m.drawcoastlines()
> m.drawmapboundary()
> m.drawparallels(np.arange(-90, 90,30))
> m.drawmeridians(np.arange(-180,180,30))
>
> fig.colorbar(im)
> plt.title('CH20 and ting')
> plt.savefig('binplot.png')
>
> Thanks for your help,
> Will.
> ------------------------------------------------------------------------
> View this message in context: Basemap/ orthographic projection plot 
> doesn't respect globe boundary 
> <http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117654p28117654.html>
> Sent from the matplotlib - users mailing list archive 
> <http://old.nabble.com/matplotlib---users-f2906.html> at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: Will H. <wh...@le...> - 2010年04月02日 10:27:28
Hi forum/ mailing list,
When I plot in the orthographic projection I'm getting the large artefact
shown below extending away from the north east of the globe.
I'm not finding the same problem when plotting in a full globe projection so
I'm presuming the problem is with the way I'm projecting everything rather
than my data itself.
I've included my plotting code below, if anyone is able to spot some glaring
omissions/ errors I'd be most grateful (I've been using python/ matplotlib
for only a couple of weeks now!).
http://old.nabble.com/file/p28117654/binploterr.png 
#!/usr/local/bin/python2.6
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import sys, glob
#input must be 3 col file of lons lats and data
#bins input values into half degree grid, ignores negative values
plts = glob.glob('*.plt')
x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
n_vals = np.zeros((360,720)) #mean divisor
dat = np.zeros((360,720)) #2D grid of zeros 
for pt in plts:
 
 in_file = pt
 data = np.loadtxt(in_file, comments = ';')
 fname = in_file.split('.')[0]
 lon = data[:,0] #original 1D list
 lat = data[:,1] #original 1D list
 slcol = data[:,2] #z data
 lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
 lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5
 ##keep the below between files
 j=0
 for i in slcol:
 if lon[j] < 0:
 grid_lon_ind = 360+(lon[j]*2)
 grid_lat_ind = 180+(lat[j]*2)
 else:
 grid_lon_ind = 360-(lon[j]*2)
 grid_lat_ind = 180+(lat[j]*2)
 
 if i > 0:
 dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
 n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter
by 1 for each extra value
 j+=1
dat = np.nan_to_num(dat/n_vals)
#create map object
fig = plt.figure()
m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0,
resolution='l', area_thresh=10000.)
#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=10000.)
X,Y = m(grid_lon, grid_lat)
#pass all 2d arrays to pcolor
im = m.pcolormesh(X,Y,dat)
#add coastlines, globe boundary and colourbar
m.drawcoastlines()
m.drawmapboundary()
m.drawparallels(np.arange(-90, 90,30))
m.drawmeridians(np.arange(-180,180,30))
fig.colorbar(im)
plt.title('CH20 and ting')
plt.savefig('binplot.png')
Thanks for your help,
Will.
-- 
View this message in context: http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117654p28117654.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Will H. <wh...@le...> - 2010年04月02日 10:27:27
Hi forum/ mailing list,
When I plot in the orthographic projection I'm getting the large artefact
shown below extending away from the north east of the globe.
I'm not finding the same problem when plotting in a full globe projection so
I'm presuming the problem is with the way I'm projecting everything rather
than my data itself.
I've included my plotting code below, if anyone is able to spot some glaring
omissions/ errors I'd be most grateful (I've been using python/ matplotlib
for only a couple of weeks now!).
http://old.nabble.com/file/p28117655/binploterr.png 
#!/usr/local/bin/python2.6
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
import sys, glob
#input must be 3 col file of lons lats and data
#bins input values into half degree grid, ignores negative values
plts = glob.glob('*.plt')
x = np.arange(-180, 180, 0.5); y = np.arange(-90, 90, 0.5)
grid_lon, grid_lat = np.meshgrid(x,y) #regularly spaced 2D grid
n_vals = np.zeros((360,720)) #mean divisor
dat = np.zeros((360,720)) #2D grid of zeros 
for pt in plts:
 
 in_file = pt
 data = np.loadtxt(in_file, comments = ';')
 fname = in_file.split('.')[0]
 lon = data[:,0] #original 1D list
 lat = data[:,1] #original 1D list
 slcol = data[:,2] #z data
 lon = (np.around(lon*2))/2 #round to nearest .0 or 0.5
 lat = (np.around(lat*2))/2 #round to nearest .0 or 0.5
 ##keep the below between files
 j=0
 for i in slcol:
 if lon[j] < 0:
 grid_lon_ind = 360+(lon[j]*2)
 grid_lat_ind = 180+(lat[j]*2)
 else:
 grid_lon_ind = 360-(lon[j]*2)
 grid_lat_ind = 180+(lat[j]*2)
 
 if i > 0:
 dat[grid_lat_ind, grid_lon_ind] += i #add i'th value
 n_vals[grid_lat_ind, grid_lon_ind] += 1 #increase cell counter
by 1 for each extra value
 j+=1
dat = np.nan_to_num(dat/n_vals)
#create map object
fig = plt.figure()
m = Basemap(projection='ortho', lon_0=lon[(len(lon)/2)], lat_0=0,
resolution='l', area_thresh=10000.)
#m = Basemap(projection='moll',lon_0=0,resolution='c', area_thresh=10000.)
X,Y = m(grid_lon, grid_lat)
#pass all 2d arrays to pcolor
im = m.pcolormesh(X,Y,dat)
#add coastlines, globe boundary and colourbar
m.drawcoastlines()
m.drawmapboundary()
m.drawparallels(np.arange(-90, 90,30))
m.drawmeridians(np.arange(-180,180,30))
fig.colorbar(im)
plt.title('CH20 and ting')
plt.savefig('binplot.png')
Thanks for your help,
Will.
-- 
View this message in context: http://old.nabble.com/Basemap--orthographic-projection-plot-doesn%27t-respect-globe-boundary-tp28117655p28117655.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Marius 't H. <M.t...@ai...> - 2010年04月02日 09:52:54
Rac...@HM... wrote:
> Hello,
>
> I'm trying to create a heat map from two lists of corresponding X and Y coordinates.
>
> I've tried both numpy.histogram2d() and pyplot.hexbin().
>
> The histogram I get back doesn't correspond to the points I gave it. It seems as if it's sorting each X and Y list and then eliminating some points, which would definitely not give me the coordinates I want. (Also, I want to be able to switch the origin to the upper-left corner, but I can't figure out how to do this with imshow().)
> 
Histogram2d works fine for me, I use it more or less the same way you 
do, so I can't help there.
You can specify the origin in imshow by saying:
plt.imshow(heatmap, extent=axesExtent, origin='upper')
> The hexbin graph does correspond to my original points, but rather than having hexagons of equal size, some are super thin and tiny. (I'd also like to fill in the entire graph with background color (I want the axes to extend beyond the data) - is there a way to do that?) 
> 
You can specify the bins in histogram2d to cover the whole screen (you 
can also specify bins in hexbin, which should be similar):
xedges, yedges = linspace(0,1400,(1400/50)+1), linspace(0,600,(600/50)+1)
npy.histogram2d(xList, yList, bins=[xedges,yedges])
> Here's the code I wrote for the histogram and hexbin. Am I doing something wrong? I've attached three graphs - one is my coordinates as a scatter plot, one my histogram result, and the other the hexbin result.
>
> Thanks!
> ~Rachel
>
> def plotHistogram( coordsTuple ):
> 
> plt.clf() # Clears any previous figure
> 
> xList = coordsTuple[0]
> yList = coordsTuple[1]
>
> heatmap, xedges, yedges = npy.histogram2d(xList, yList)
> axesExtent = [0, xedges[-1], 0, yedges[-1]]
> plt.imshow(heatmap, extent = axesExtent)
>
> plt.title( "Heat Map of User Clicks" )
>
> name = raw_input("\nImage name and extension: ")
> plt.savefig(name)
>
>
> def plotHexbins( coordsTuple ):
> 
> plt.clf() # Clears any previous figure
> 
> xList = coordsTuple[0]
> yList = coordsTuple[1]
>
> plt.hexbin(xList, yList)
>
> plt.title( "Heat Map of User Clicks" )
>
> name = raw_input("\nImage name and extension: ")
> plt.savefig(name)
>
> 

Showing results of 31

1 2 > >> (Page 1 of 2)
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 によって変換されたページ (->オリジナル) /