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




Showing 20 results of 20

From: Sandro T. <mo...@de...> - 2009年03月03日 21:46:19
Hi Eric,
thanks for the reply.
On Sat, Feb 28, 2009 at 20:56, Eric Firing <ef...@ha...> wrote:
> It is not really a bug; it is an inherent limitation in mpl's default
> automatic Axes positioning. Axes positions are given in normalized
> coordinates relative to the figure, so if you shrink the height of the
> figure (relative to the default, for which the default positioning
> parameters are designed), there is less physical space available for the
> x-axis ticks, ticklabels, and label--and things can get cut off. If you are
> adjusting the figsize and/or the font size, then chances are you need to
> adjust these normalized coordinate Axes position parameters as well. Trial
Oh, ok, now it's clear
> and error is typically needed; it can be facilitated by using the subplot
> adjuster widget in an interactive window (second to last button on the
> toolbar) to decide what looks good. Then use the figure.subplot.* entries
Yeah, I used this to find 0.13 to be my number...
> in matplotlibrc, or call plt.subplots_adjust(bottom=0.15) (for example), or
> call it as a method of the figure you have just created.
...that I added this command and it worked.
> For doing the interactive adjustment, you will want to use a smaller figure
> dpi, something to match your screen. Everything will scale correctly when
> you save the figure at higher dpi.
luckily, even at dpi=300, the image still fits my screen :)
Cheers,
-- 
Sandro Tosi (aka morph, morpheus, matrixhasu)
My website: http://matrixhasu.altervista.org/
Me at Debian: http://wiki.debian.org/SandroTosi
From: Christopher B. <c-...@as...> - 2009年03月03日 20:36:51
Hi Michael,
MD> With recent versions of matplotlib, you can set the "path.simplify"
MD> rcParam to True, which should reduce the data so that vertices that
MD> have no impact on the plot appearance (at the given dpi) are
MD> removed.
Wow. My time-domain waveform plots went from 3.3 mb to 84 kb. This was 
an incredibly timely tip too, because I was just about to go to print 
with my poster, which I did in Scribus, which would hang on the 3-4 mb 
pdf figure. I was about to go to png, but now I don't have to. Thanks.
-- 
Christopher Brown, Ph.D.
Department of Speech and Hearing Science
Arizona State University
From: Keoki S. <ke...@uo...> - 2009年03月03日 20:29:49
On Mar 3, 2009, at 12:19 PM, Eric Firing wrote:
> An argument could be made either way, but I think the present 
> behavior, in which autoscale_view is called after changing the 
> scale, will cause the least surprise in the majority of cases. The 
> default locator depends on the scale, and is used in the autoscaling 
> process.
Thanks for the quick reply. Will this be documented anywhere? It 
would be nice for others to know the behavior of xscale.
Keoki
From: Eric F. <ef...@ha...> - 2009年03月03日 20:19:30
Keoki Seu wrote:
> Greeting everyone,
> In pylab (matplotlib 0.98.3.001 on Mac OS X) I've discovered that 
> changing the xscale from linear to log removes the previously set xlim.
> 
> For example
> In [1]: import pylab
> In [2]: x = pylab.arange(100)
> In [3]: y = pylab.sin(x)
> In [4]: pylab.plot(x, y)
> Out[4]: [<matplotlib.lines.Line2D object at 0x1a0981f0>]
> In [5]: pylab.xlim(30, 50)
> Out[5]: (30, 50)
> In [6]: print pylab.xlim()
> (30.0, 50.0)
> In [7]: pylab.xscale('log')
> In [8]: print pylab.xlim()
> (1.0, 100.0)
> 
> There are easy workarounds, such as saving the axes before switching 
> to log and restoring them after, but is this expected behavior?
An argument could be made either way, but I think the present behavior, 
in which autoscale_view is called after changing the scale, will cause 
the least surprise in the majority of cases. The default locator 
depends on the scale, and is used in the autoscaling process.
The suggested way of preventing the autoscaling (using pylab syntax to 
go with your example above) is to use "gca().set_autoscale_on(False)" 
before changing the scale.
Eric
> 
> Thanks,
> Keoki
> 
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a 600ドル discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Keoki S. <ke...@uo...> - 2009年03月03日 19:57:36
Greeting everyone,
In pylab (matplotlib 0.98.3.001 on Mac OS X) I've discovered that 
changing the xscale from linear to log removes the previously set xlim.
For example
In [1]: import pylab
In [2]: x = pylab.arange(100)
In [3]: y = pylab.sin(x)
In [4]: pylab.plot(x, y)
Out[4]: [<matplotlib.lines.Line2D object at 0x1a0981f0>]
In [5]: pylab.xlim(30, 50)
Out[5]: (30, 50)
In [6]: print pylab.xlim()
(30.0, 50.0)
In [7]: pylab.xscale('log')
In [8]: print pylab.xlim()
(1.0, 100.0)
There are easy workarounds, such as saving the axes before switching 
to log and restoring them after, but is this expected behavior?
Thanks,
Keoki
From: Jouni K. S. <jk...@ik...> - 2009年03月03日 16:45:45
Daniel Soto <dan...@gm...> writes:
> are there any other options or backends that might help?
One thing that might be worth trying if this is a real problem for 
you -- but it will require some programming -- is to make use of the
start_rasterizing and stop_rasterizing methods of MixedModeRenderer. 
You would have to create your own artist class or modify one of the 
existing artists to call start_rasterizing before the expensive part and
stop_rasterizing afterwards, so that the expensive part becomes a bitmap
image in the pdf file.
I think quad meshes used to do this, but I don't see any calls to
start_rasterizing in the current code. Perhaps there was some difficulty
with this approach.
-- 
Jouni K. Seppänen
http://www.iki.fi/jks
From: Jose Gomez-D. <jgo...@gm...> - 2009年03月03日 16:41:20
Jeff,
I've been doing some more tests today.
2009年3月3日 Jeff Whitaker <js...@fa...>
>
> Jose: I think the key is to only create the basemap instance only
>> once (for the main plot and for the inset), then re-use that
>> basemap instance each time you create an animation frame.
>>
>> That helps in memory consumption, and that's something I looked into.
>> However, my basemap instances are defined (in the case of the inset) as:
>> m2 = Basemap(projection='ortho',lon_0=6,lat_0=-12,ax=ax2)
>> Actually, they both have references to axes. The bit I don't really
>> understand is how to define my basemap only once and then just "hang it"
>> from some axes.
>>
>
> Jose: You can create the Basemap instance once, and then pass the axes
> with the ax keyword whenever you call a basemap method.
>
OK, I wasn't aware of this. However, memory consumption still flies. I am
aware that it could be other bits of the program that are eating up loads of
memory, but I don't know how to test where the bottleneck is. In the end, I
resorted to getting rid of basemap instances, but the problem persists.
There must be something in what I'm doing that's eating memory up, but I'm
not sure how to check what it is.
I'll try installing guppy and see whether that shines a light...
Thanks!
Jose
From: Michael D. <md...@st...> - 2009年03月03日 16:11:50
path.simplify was added some time after 0.98.3. You'll have to upgrade 
to 0.98.5.x for that feature.
pdf.compression should have some impact on file size, but I doubt it 
will have much impact on display times, since it doesn't actually remove 
any data. I'm surprised this isn't having any effect -- perhaps the 
matplotlibrc file you're editing is not the one being loaded? You can 
see where the file is being loaded from with:
 import matplotlib
 matplotlib.get_configdir()
agg.path.chunksize has no effect on PDF output.
Is it possible you're using the Cairo backend, and not matplotlib's own 
Python-based PDF backend?
As a cheap workaround, you can also easily decimate your data using 
Numpy with something like:
 data = data[::skip]
where 'skip' is the number of data points to skip.
Cheers,
Mike
Daniel Soto wrote:
> thanks for the suggestion. i'm running 0.98.3 and have tried
>
> pdf.compression
> path.simplify
> agg.path.chunksize
>
> without any change in filesize (176KB) or time to open file (13 sec).
>
> are there any other options or backends that might help?
>
> drs
>
> On 3 Mar 2009, at 05:29, Michael Droettboom wrote:
>
>> With recent versions of matplotlib, you can set the "path.simplify" 
>> rcParam to True, which should reduce the data so that vertices that 
>> have no impact on the plot appearance (at the given dpi) are removed.
>>
>> You can do either, in your script:
>>
>> from matplotlib import rcParam
>> rcParam['path.simplify'] = True
>>
>> or in your matplotlibrc file:
>>
>> path.simplify: True
>>
>> Hope that helps. The amount of reduction this produces is somewhat 
>> data-dependent.
>>
>> Cheers,
>> Mike
>>
>> Daniel Soto wrote:
>>> hello,
>>>
>>> i'm using matplotlib on os x and am having issues with plots of 
>>> large data sets. i have some plots which contain about ~10000 
>>> points and the pdf files generated bring preview.app and quicklook 
>>> to their knees when they open the pdf files.
>>>
>>> here is a small file that reproduces my issues. at 1000 points it 
>>> is snappy and at 10000 it is a pig.
>>>
>>> is there a setting to downsample or otherwise compress?
>>>
>>> best,
>>> drs
>>>
>>>
>>>
>>> import matplotlib.pyplot
>>> import scipy
>>>
>>> x = scipy.rand(10000)
>>> matplotlib.pyplot.plot(x)
>>> matplotlib.pyplot.savefig('rand.pdf')
>>>
>>> ------------------------------------------------------------------------------ 
>>>
>>> Open Source Business Conference (OSBC), March 24-25, 2009, San 
>>> Francisco, CA
>>> -OSBC tackles the biggest issue in open source: Open Sourcing the 
>>> Enterprise
>>> -Strategies to boost innovation and cut costs with open source 
>>> participation
>>> -Receive a 600ドル discount off the registration fee with the source 
>>> code: SFAD
>>> http://p.sf.net/sfu/XcvMzF8H
>>> _______________________________________________
>>> 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: Peter S. <pet...@gm...> - 2009年03月03日 15:42:22
Mike,
Thanks for the tip, I was also thinking of using some kind of nonlinear
transform onto a 1D segmented colormap... I'll let you know if I come up
with a solution.
-Pete
On Tue, Mar 3, 2009 at 8:27 AM, Michael Droettboom <md...@st...> wrote:
> I don't think there's anything that will directly do what you want.
>
> However, you can provide a list of colors (one entry for each point) to
> scatter(), (the c kwarg) so you can generate your colors however you need to
> beforehand. If you come up with a solution that's generic enough, we would
> definitely consider it for inclusion in matplotlib.
>
> Cheers,
> Mike
>
> Peter Skomoroch wrote:
>
>> Is there any way to encode 2 variables in a matplotlib colormap? The idea
>> is to replicate this dataspora R scatterplot in matplotlib:
>>
>> http://www.dataspora.com/gameday/pitcher/daisuke-matsuzaka/493137
>>
>> "The bottom strip of charts encode two dimensions with color -- blue or
>> red hue indicates pitch velocity -- while the lightness or darkness of the
>> hue indicates how many pitches were thrown in a given region. "
>>
>>
>> --
>> Peter N. Skomoroch
>> 617.285.8348
>> http://www.datawrangling.com
>> http://delicious.com/pskomoroch
>> http://twitter.com/peteskomoroch
>> ------------------------------------------------------------------------
>>
>>
>> ------------------------------------------------------------------------------
>> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
>> CA
>> -OSBC tackles the biggest issue in open source: Open Sourcing the
>> Enterprise
>> -Strategies to boost innovation and cut costs with open source
>> participation
>> -Receive a 600ドル discount off the registration fee with the source code:
>> SFAD
>> http://p.sf.net/sfu/XcvMzF8H
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> 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
>
>
-- 
Peter N. Skomoroch
617.285.8348
http://www.datawrangling.com
http://delicious.com/pskomoroch
http://twitter.com/peteskomoroch
From: Daniel S. <dan...@gm...> - 2009年03月03日 15:26:56
thanks for the suggestion. i'm running 0.98.3 and have tried
pdf.compression
path.simplify
agg.path.chunksize
without any change in filesize (176KB) or time to open file (13 sec).
are there any other options or backends that might help?
drs
On 3 Mar 2009, at 05:29, Michael Droettboom wrote:
> With recent versions of matplotlib, you can set the "path.simplify" 
> rcParam to True, which should reduce the data so that vertices that 
> have no impact on the plot appearance (at the given dpi) are removed.
>
> You can do either, in your script:
>
> from matplotlib import rcParam
> rcParam['path.simplify'] = True
>
> or in your matplotlibrc file:
>
> path.simplify: True
>
> Hope that helps. The amount of reduction this produces is somewhat 
> data-dependent.
>
> Cheers,
> Mike
>
> Daniel Soto wrote:
>> hello,
>>
>> i'm using matplotlib on os x and am having issues with plots of 
>> large data sets. i have some plots which contain about ~10000 
>> points and the pdf files generated bring preview.app and quicklook 
>> to their knees when they open the pdf files.
>>
>> here is a small file that reproduces my issues. at 1000 points it 
>> is snappy and at 10000 it is a pig.
>>
>> is there a setting to downsample or otherwise compress?
>>
>> best,
>> drs
>>
>>
>>
>> import matplotlib.pyplot
>> import scipy
>>
>> x = scipy.rand(10000)
>> matplotlib.pyplot.plot(x)
>> matplotlib.pyplot.savefig('rand.pdf')
>>
>> ------------------------------------------------------------------------------
>> Open Source Business Conference (OSBC), March 24-25, 2009, San 
>> Francisco, CA
>> -OSBC tackles the biggest issue in open source: Open Sourcing the 
>> Enterprise
>> -Strategies to boost innovation and cut costs with open source 
>> participation
>> -Receive a 600ドル discount off the registration fee with the source 
>> code: SFAD
>> http://p.sf.net/sfu/XcvMzF8H
>> _______________________________________________
>> 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...> - 2009年03月03日 13:30:10
With recent versions of matplotlib, you can set the "path.simplify" 
rcParam to True, which should reduce the data so that vertices that have 
no impact on the plot appearance (at the given dpi) are removed.
You can do either, in your script:
 from matplotlib import rcParam
 rcParam['path.simplify'] = True
or in your matplotlibrc file:
 path.simplify: True
Hope that helps. The amount of reduction this produces is somewhat 
data-dependent.
Cheers,
Mike
Daniel Soto wrote:
> hello,
>
> i'm using matplotlib on os x and am having issues with plots of large 
> data sets. i have some plots which contain about ~10000 points and 
> the pdf files generated bring preview.app and quicklook to their knees 
> when they open the pdf files.
>
> here is a small file that reproduces my issues. at 1000 points it is 
> snappy and at 10000 it is a pig.
>
> is there a setting to downsample or otherwise compress?
>
> best,
> drs
>
>
>
> import matplotlib.pyplot
> import scipy
>
> x = scipy.rand(10000)
> matplotlib.pyplot.plot(x)
> matplotlib.pyplot.savefig('rand.pdf')
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a 600ドル discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> 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...> - 2009年03月03日 13:28:28
I don't think there's anything that will directly do what you want.
However, you can provide a list of colors (one entry for each point) to 
scatter(), (the c kwarg) so you can generate your colors however you 
need to beforehand. If you come up with a solution that's generic 
enough, we would definitely consider it for inclusion in matplotlib.
Cheers,
Mike
Peter Skomoroch wrote:
> Is there any way to encode 2 variables in a matplotlib colormap? The 
> idea is to replicate this dataspora R scatterplot in matplotlib:
>
> http://www.dataspora.com/gameday/pitcher/daisuke-matsuzaka/493137
>
> "The bottom strip of charts encode two dimensions with color -- blue 
> or red hue indicates pitch velocity -- while the lightness or darkness 
> of the hue indicates how many pitches were thrown in a given region. "
>
>
> -- 
> Peter N. Skomoroch
> 617.285.8348
> http://www.datawrangling.com
> http://delicious.com/pskomoroch
> http://twitter.com/peteskomoroch
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a 600ドル discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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: Blake F. <pla...@gm...> - 2009年03月03日 10:56:00
Hi,
I have started to use pyplot to create graphs, saving the images and
generating an animation from the collection. Pyplot autoscale the
axes, which isn't suitable for an animation. At the moment I reset
them (for every frame) using the xlim / ylim functions:
import matplotlib.pyplot as plt
...
def draw(self):
 self.fig = plt.figure()
 self.ax = self.fig.add_subplot(1,1,1)
 for e in self.graph.E:
 x, y = [e.u.x, e.v.x], [e.u.y, e.v.y]
 plt.plot(x, y, 'b', zorder=2, lw=3)
 for v in self.graph.V:
 x, y = [v.x, v.x], [v.y, v.y]
 plt.scatter(x, y, c='g', zorder=1, s=120)
 # XXX: There should be a better way than this?
 plt.xlim( (0, 100) )
 plt.ylim( (0, 100) )
Is there a better way to do this?
Thanks,
Blake
From: Gökhan S. <gok...@gm...> - 2009年03月03日 06:50:56
I am willing to add this functionality to the documentation. Unfortunately,
I have still not been able to figure out how sphinx inserting functions or
classes in order and how the module index is being created.
Once I found my way I will try to come up with a generic way for this. Maybe
someone can give some more insight to the subject?
Thanks,
Gökhan
From: Aaron R> <ant...@gm...> - 2009年03月03日 05:39:45
Sorry for the delay in responding.
This worked perfectly! Thanks so much for the time saver.
Kind regards,
Aaron R>
On Thu, Feb 26, 2009 at 12:28 PM, Eric Firing <ef...@ha...> wrote:
> Aaron R> wrote:
>>
>> I have an app which adds data to a plot. Everything is working, but
>> when I add data to a plot that was zoomed in, it switches the display
>> to a zoomed out view.
>
>>
>>  def addData(self, xdata, ydata):
>>    # Need to save off current zoom level before adding new plot data
>>    # But don't know how
>
> Try this:
>    self.axes.set_autoscale_on(False)
>
> Eric
>
>>    self.axes.plot(xdata, ydata)
>>
>>    # Restore view here, then redraw
>>    self.canvas.draw()
>>
>
From: Wai Y. T. <tun...@ya...> - 2009年03月03日 05:08:00
I second this suggestion. Right now it is quite hard to navigate to an 
individual function within the chapter of matplotlib.pyplot API in the PDF.
Wai Yip
> Hello,
>
> My first message in the list. I would like to mention a few things about 
> the
> matplotlib PDF document.
>
> Firstly, the download link for the pdf document (@
> http://matplotlib.sourceforge.net/contents.html) is for release 0.98.5.1,
> compiled on December 17, instead of 0.98.5.2, on Dec-18.
>
> Next, is there a way to get functions separately listed under each 
> bookmark
> listing in the pdf file? For example if I go IV Matplotlib API section 
> from
> the bookmarks menu and click the matplotlib.pyplot seb-menu I would like 
> to
> see the function names listed. In addition to module indexing (where
> keywords highlighted back to original names) this would be a nice 
> feature to
> add the pdf documentation.
>
> If this needs a manual configuration, I am volunteering to spend time to 
> add
> this functionality.
>
> Regards,
> Gökhan SEVER
From: Daniel S. <dan...@gm...> - 2009年03月03日 02:50:13
hello,
i'm using matplotlib on os x and am having issues with plots of large 
data sets. i have some plots which contain about ~10000 points and 
the pdf files generated bring preview.app and quicklook to their knees 
when they open the pdf files.
here is a small file that reproduces my issues. at 1000 points it is 
snappy and at 10000 it is a pig.
is there a setting to downsample or otherwise compress?
best,
drs
import matplotlib.pyplot
import scipy
x = scipy.rand(10000)
matplotlib.pyplot.plot(x)
matplotlib.pyplot.savefig('rand.pdf')
From: Wai Y. T. <tun...@ya...> - 2009年03月03日 01:41:03
I was trying to setup matplotlib to use interactively with wxPython as the 
backend. I run into the issue that when I call draw(), it blocks the 
interpreter. Since then I've found out it is a issue with some GUI backend 
that the mainloop blocks. The suggested solution is to use ipython, which 
I do not use for various reasons.
I think I have come across the problem stated in the user's guide:
"For other user interface toolkits and their corresponding matplotlib 
backends, the situation is complicated by the GUI mainloop which takes 
over the entire process. The solution is to run the GUI in a separate 
thread, and this is the tricky part that ipython solves for all the major 
toolkits that matplotlib supports."
http://matplotlib.sourceforge.net/users/shell.html#other-python-interpreters
I end up spending sometime hacking some code. And I think I manage to run 
the interpreter and GUI mainloop in separate threads. So I'd post my code 
here for review and perhaps someone may find it useful. I'm very new to 
matplotlib so I don't know if what I do really make sense.
pylab.py
------------------------------------------------------------------------
""" Run matplotlib interactively with the Python interpreter and the 
wxPython
backend.
This script launches the interpreter in a second thread while keeping 
matplotlib
and the wxPython mainloop on the main thread. It resolves the issue that 
calling
draw() starts the GUI mainloop and blocks the main thread.
"For other user interface toolkits and their corresponding matplotlib 
backends,
the situation is complicated by the GUI mainloop which takes over the 
entire
process. The solution is to run the GUI in a separate thread, and this is 
the
tricky part that ipython solves for all the major toolkits that matplotlib
supports."
http://matplotlib.sourceforge.net/users/shell.html#other-python-interpreters
To use, just launch this script from command line, e.g
 c:\> python pylab.py
 Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit 
(Intel)] on win32
 Type "help", "copyright", "credits" or "license" for more information.
 (MatplotlibConsole)
 >>>
Alternatively it is recommended to use the Ipython shell with matplotlib.
"""
import code
import Queue
import sys
import threading
import matplotlib.pyplot as plt
import numpy as np
import wx
BaseConsole = code.InteractiveConsole
class MatplotlibConsole(BaseConsole):
 """
 MatplotlibConsole is an interactive Python console that splits I/O and 
code
 execution in separate threads. This address the issue that in the 
Matplotlib
 and wxPython environment, some functions do not work well when called 
from
 an abitrary thread and should be run from the main thread only. Here 
code
 are queued instead of executed immediately. execute_queued_code() 
should be
 called regularly from the main thread.
 """
 def __init__(self, *args):
 self.code_q = Queue.Queue(1)
 self.shutdown = False
 BaseConsole.__init__(self, *args)
 def runcode(self, code):
 # queue the code so that it may run in the main thread
 self.code_q.put(code, block=True)
 self.code_q.join()
 def execute_queued_code(self, event):
 if self.shutdown:
 # make sure shutdown action don't run more than once
 self.shutdown = False
 plt.close()
 return
 try:
 code = self.code_q.get_nowait()
 except Queue.Empty:
 return
 try:
 BaseConsole.runcode(self, code)
 finally:
 self.code_q.task_done()
 def interact(self):
 BaseConsole.interact(self)
 print 'Console Closing...'
 self.shutdown = True
def main(argv):
 # instantiate MatplotlibConsole
 mp_locals = {
 "np":np,
 "plt":plt,
 }
 console = MatplotlibConsole(mp_locals)
 # launch console in a new thread
 shell_thread = threading.Thread(target=console.interact, 
name='shell_thread')
 shell_thread.start()
 # setup pyplot
 fig = plt.figure(1)
 # setup timer to run the execute_queued_code()
 id = wx.NewId()
 actor = fig.canvas.manager.frame
 timer = wx.Timer(actor, id=id)
 timer.Start(100)
 wx.EVT_TIMER(actor, id, console.execute_queued_code)
# this doesn't work. why?
# plt.ion()
 # show() starts the wx main loop
 plt.show()
if __name__ =='__main__':
 main(sys.argv)
------------------------------------------------------------------------
There is still some issue I'm trying to solve. For some reason I don't 
understand I can't run plt.ion() before show(). Also I like to do an 
import like "from pylab import *" for the console.
Wai Yip
From: Jeff W. <js...@fa...> - 2009年03月03日 00:19:01
Jose Gomez-Dans wrote:
> Jeff, thanks for your comment
>
> 2009年3月2日 Jeff Whitaker <js...@fa... <mailto:js...@fa...>>
>
>
> Jose: I think the key is to only create the basemap instance only
> once (for the main plot and for the inset), then re-use that
> basemap instance each time you create an animation frame. 
>
>
> That helps in memory consumption, and that's something I looked into. 
> However, my basemap instances are defined (in the case of the inset) as:
> m2 = Basemap(projection='ortho',lon_0=6,lat_0=-12,ax=ax2)
> Actually, they both have references to axes. The bit I don't really 
> understand is how to define my basemap only once and then just "hang 
> it" from some axes.
Jose: You can create the Basemap instance once, and then pass the axes 
with the ax keyword whenever you call a basemap method.
>
> Additionally, I am warping a fairly large image (not shown in my 
> example), so that it takes quite a long time to process. This is only 
> seldom updated, so I could just save the background and overlay on it 
> my data. As I see it, even if I recycle the basemap instance, I'd 
> still have to go through the process of warping my image, extracting 
> coastlines, etc. It would be faster to just save it, and recreate it 
> whenever it is necessary. I don't really know how to do this.
The image is only warped the first time you call the bluemarble method 
for a given basemap instance. Subsequent calls used the cached image.
>
> I have changed my code by shamelessly copying from your previous 
> advice ;p (see <http://pastebin.com/f4eaedd7>). Things improve a bit, 
> but my parllels/meridians are not aligned with the map. Clearly I'm 
> still missing something!
I don't have time right now to look at that code, I'll try to play with 
it tomorrow.
-Jeff
>
> Many thanks for your help,
> Jose
>
-- 
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jef...@no...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
From: Jose Gomez-D. <jgo...@gm...> - 2009年03月03日 00:08:23
Jeff, thanks for your comment
2009年3月2日 Jeff Whitaker <js...@fa...>
>
> Jose: I think the key is to only create the basemap instance only once (for
> the main plot and for the inset), then re-use that basemap instance each
> time you create an animation frame.
That helps in memory consumption, and that's something I looked into.
However, my basemap instances are defined (in the case of the inset) as:
 m2 = Basemap(projection='ortho',lon_0=6,lat_0=-12,ax=ax2)
Actually, they both have references to axes. The bit I don't really
understand is how to define my basemap only once and then just "hang it"
from some axes.
Additionally, I am warping a fairly large image (not shown in my example),
so that it takes quite a long time to process. This is only seldom updated,
so I could just save the background and overlay on it my data. As I see it,
even if I recycle the basemap instance, I'd still have to go through the
process of warping my image, extracting coastlines, etc. It would be faster
to just save it, and recreate it whenever it is necessary. I don't really
know how to do this.
I have changed my code by shamelessly copying from your previous advice ;p
(see <http://pastebin.com/f4eaedd7>). Things improve a bit, but my
parllels/meridians are not aligned with the map. Clearly I'm still missing
something!
Many thanks for your help,
Jose
2 messages has been excluded from this view by a project administrator.

Showing 20 results of 20

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