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



Showing results of 355

1 2 3 .. 15 > >> (Page 1 of 15)
Howdy,
I built basemap 1.0.5 and matplotlib 1.2.0rc3 via the simple command
'python setup.py bdist_rpm' without an error that I can tell. When I
attempt to install them, I get a conflict between the two. For example:
file /usr/lib64/python2.6/site-packages/mpl_toolkits/__init__.pyc from
install of basemap-1.0.5-1.x86_64 conflicts with file from package
matplotlib-1.2.0rc3-1.x86_64
file /usr/lib64/python2.6/site-packages/mpl_toolkits/__init__.pyo from
install of basemap-1.0.5-1.x86_64 conflicts with file from package
matplotlib-1.2.0rc3-1.x86_64
Working around this error is easy with some rpm flags, but was curious what
the proper solution for this situation is?
thanks!
 daryl
PS. When i built matplotlib 1.2.0rc3 on RHEL6 64bit, I need to hard set
provide_dateutil to make the resulting build work when deployed. I think
the problem is that the build is seeing it already installed from the
previous install of matplotlib , which gets blown out with the rpm update?
 I am probably rehashing well known items, sorry.
From: Michael D. <md...@st...> - 2012年10月31日 01:22:31
The third and (crossing fingers) final release candidate for matplotlib 
1.2.0 has been posted.
Source tarballs and binaries for Windows and OS-X are available from the 
matplotlib github download page:
https://github.com/matplotlib/matplotlib/downloads
Please try it out and report any bugs so we can make this the best 
matplotlib release yet!
Mike
From: Damon M. <dam...@gm...> - 2012年10月30日 23:13:22
On Tuesday, October 30, 2012, Russell E. Owen wrote:
> In article <508...@st... <javascript:;>>,
> Michael Droettboom <md...@st... <javascript:;>>
> wrote:
>
> > Agreed! Thanks to everyone for their hard work. I think this has
> > shaped up to be a great release.
> >
> > I'm fortunate to have power and connectivity today, so I was able to get
> > a release tested, tagged and uploaded.
> >
> > To our binary builders: as able, it would be great to put the binaries
> > up (or send them to me to do so), and then I'll make an announcement on
> > matplotlib-users. I really intend (barring any really serious issues)
> > this to be the last rc before the 1.2.0 final.
> >
> > Thanks again,
> > Mike
>
> The Mac binaries are now up. This time it built perfectly on MacOS X
> 10.4; thanks to the folks that worked so hard fixing those build
> problems.
>
> The 32-bit version is not well tested because I have neither inkscape
> nor ghostscript installed on that ancient system, but it passes the
> tests that it can run under those circumstances.
>
> The 64-bit version passes all tests except 2 knownfail and 3 skipped.
>
> -- Russell
>
> P.S. I had to build the 64-bit version twice. The first time I tried to
> build it using the same directory of code that I used to build 32-bit
> version. I first deleted the "build" and "dist" subdirectories and ran
> "python setup.py clean", then built as usual. There were no errors or
> warnings during the build, but the unit tests would not run on the
> results -- complaining of missing modules.
>
> So I built again using a freshly unpacked code directory and that worked
> just fine.
>
> I'm pretty sure I've seen this problem before, but keep forgetting to
> ask about it.
>
> Is this a bug somewhere (e.g. in matplotlib's setup.py or somewhere in
> python) or is there some better way to clear out a python code directory?
>
Yes! I'm sending you a virtual high five! Thanks for thy Russell.
-- 
Damon McDougall
http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom
From: Eric F. <ef...@ha...> - 2012年10月30日 21:39:37
On 2012年10月29日 2:00 PM, Mike Kaufman wrote:
> On 10/29/12 1:08 PM, Jody Klymak wrote:
>>
>> On Oct 28, 2012, at 17:47 PM, Eric Firing <ef...@ha...> wrote:
>>>
>>> cb = colorbar()
>>> cb.solids.set_rasterized(True)
>>
>>
>> Great! Though I think it'd have taken me a while to figure that one out!
>
> I gotta agree. Is this (and the solids object) documented anywhere?
No, and it probably won't be any time soon. Rasterization here is a 
last resort work-around for buggy pdf renderers. The solids object is 
mentioned in the colorbar docstring as something one can modify for such 
workarounds (an alternative is given), but perhaps without saying what 
kind of a thing it is.
Eric
>
> M
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Michael D. <md...@st...> - 2012年10月30日 17:52:48
On 10/30/2012 12:25 PM, Brandon Heller wrote:
> Hi Phil,
>
> Next time I'll be more explicit. I added the question to SA after I 
> tried to get a public link to my message and saw that archives past 
> July of this year seem to be missing. It wasn't clear that this list 
> was even still alive:
> http://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-users
>
> Any idea why the archives seem to have stopped?
Thanks for pointing that out. I'm not sure what's wrong, but I'll look 
into it.
Mike
>
> Thanks,
> Brandon
>
> On Tue, Oct 30, 2012 at 2:23 AM, Phil Elson <pel...@gm... 
> <mailto:pel...@gm...>> wrote:
>
> Hi Brandon,
>
> I notice that this is cross-posted on StackOverflow
> (http://stackoverflow.com/questions/13132194/type-1-fonts-with-log-graphs).
> Personally, I have no problem with cross posting, but to save two
> people having to answer the same question, I would make sure it
> was explicit that this had also been posted elsewhere.
>
> Thanks,
>
> Phil
>
>
> On 30 October 2012 03:13, Brandon Heller <bra...@st...
> <mailto:bra...@st...>> wrote:
>
> Hi,
>
> I'm trying to use Matplotlib graphs as part of a camera-ready
> submission, and the publishing house requires the use of Type
> 1 fonts
> only.
>
> I'm finding that the PDF backend happily outputs Type-1 fonts for
> simple graphs with linear Y axes, but outputs Type-3 fonts for
> logarithmic Y axes.
>
> Using a logarithmic yscale incurs the use of mathtext, which
> seems to
> use Type 3 fonts, presumably because of the default use of
> exponential
> notation. I can use an ugly hack to get around this - using
> pyplot.yticks() to force the axis ticks to not use exponents - but
> this would require moving the plot region to accommodate large
> labels
> (like 10 ^ 6) or writing the axes as 10, 100, 1K, etc. so they
> fit.
>
> There's a minimum working example below, which I've tested
> with the
> matplotlib master branch as of today, as well as 1.1.1, which
> produces
> the same behavior, so I don't know that this is a bug,
> probably just
> unexpected behavior.
>
>
> #!/usr/bin/env python
> # Simple program to test for type 1 fonts.
> # Generate a line graph w/linear and log Y axes.
>
> from matplotlib import rc, rcParams
>
> #rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
>
> # These lines are needed to get type-1 results:
> #
> http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
> rcParams['ps.useafm'] = True
> rcParams['pdf.use14corefonts'] = True
> rcParams['text.usetex'] = False
>
> import matplotlib.pyplot as plt
>
> YSCALES = ['linear', 'log']
>
> def plot(filename, yscale):
> plt.figure(1)
> xvals = range(1, 2)
> yvals = xvals
> plt.plot(xvals, yvals)
> plt.yscale(yscale)
> #YTICKS = [1, 10]
> #plt.yticks(YTICKS, YTICKS) # locs, labels
> ax = plt.gca()
> #print ax.get_xticklabels()[0].get_text()
> print ",".join([a.get_label() for a in ax.get_yticklabels()])
> plt.savefig(filename + '.pdf')
>
>
> if __name__ == '__main__':
> for yscale in YSCALES:
> plot('linegraph-' + yscale, yscale)
>
>
>
> Does anyone know a clean way to get Type 1 fonts with log axes?
>
> Thanks,
> Brandon
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> <mailto:Mat...@li...>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Brandon H. <bra...@st...> - 2012年10月30日 17:06:18
On Tue, Oct 30, 2012 at 5:51 AM, Michael Droettboom <md...@st...> wrote:
> There are a couple of alternative formatters for log scaling that don't
> require mathtext.
>
> You can do:
>
> from matplotlib.tickers import LogFormatter, LogFormatterExponent
> ...
> ax.xaxis.set_major_formatter(LogFormatter())
> # or LogFormatterExponent(), which is just the exponent
>
>
To clarify the font issue. The PDF backend has no support for outputting
> Type 1 fonts. There is an rcParam "pdf.fonttype" that allows you to choose
> between Type 3 and Type 42 fonts, however. Type 3 stores each character as
> a path and then uses those to put strings together. It supports font
> subsetting, so an entire large font is not embedded in the file. Type 42
> (essentially) just embeds a TrueType font in the file, and we don't support
> subsetting there.
>
> There is also the "pdf.use14corefonts" that will use the 14 built-in PDF
> fonts whenever possible (and therefore not embed any fonts). However,
> mathtext requires a special font for the math symbols, and thus it starts
> to embed fonts.
>
> You may try setting "mathtext.default" to "regular", which will use the
> font used as the default for the rest of the text first. This should have
> the effect of not embedding any extra fonts in the file as long as you
> don't use any special symbols in the math.
>
Hi Mike,
Thanks for the suggestions - I tried both. The first (use a LogFormatter)
yields only Type 1 but doesn't look look as good as exponential notation
(my style preference). The second (mathtext.default = regular) defaulted
to CMR and kept the exponents as Type 1, but not the helvetica used by the
rest of the graph. It used CMR even when I had set another font as the
default:
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
... so maybe I'm not setting the default properly. Any ideas there?
A suggestion from my colleague Vimal Kumar was to post-process the output
to replace Type3 w/Type 1:
 sed -i.bak \
 -e "s/Type3/Type1/g" \
 -e "s/BitstreamVeraSans-Roman/Helvetica/g" \
 -e "s/DejaVuSans/Helvetica/g" \
 $file
This has the advantage that no mattext or tex is required, though I have to
assume the letter spacing is meant for the original font. In practice, the
only replaced fonts are on the Y axis, so even if the spacing between
letters seems a bit bigger, I don't think this is a huge issue. Of course,
it would still be nice to solve this problem in MPL itself, though.
Thanks,
Brandon
>
> Mike
>
>
> On 10/30/2012 05:23 AM, Phil Elson wrote:
>
> Hi Brandon,
>
> I notice that this is cross-posted on StackOverflow (
> http://stackoverflow.com/questions/13132194/type-1-fonts-with-log-graphs).
> Personally, I have no problem with cross posting, but to save two people
> having to answer the same question, I would make sure it was explicit that
> this had also been posted elsewhere.
>
> Thanks,
>
> Phil
>
>
> On 30 October 2012 03:13, Brandon Heller <bra...@st...> wrote:
>
>> Hi,
>>
>> I'm trying to use Matplotlib graphs as part of a camera-ready
>> submission, and the publishing house requires the use of Type 1 fonts
>> only.
>>
>> I'm finding that the PDF backend happily outputs Type-1 fonts for
>> simple graphs with linear Y axes, but outputs Type-3 fonts for
>> logarithmic Y axes.
>>
>> Using a logarithmic yscale incurs the use of mathtext, which seems to
>> use Type 3 fonts, presumably because of the default use of exponential
>> notation. I can use an ugly hack to get around this - using
>> pyplot.yticks() to force the axis ticks to not use exponents - but
>> this would require moving the plot region to accommodate large labels
>> (like 10 ^ 6) or writing the axes as 10, 100, 1K, etc. so they fit.
>>
>> There's a minimum working example below, which I've tested with the
>> matplotlib master branch as of today, as well as 1.1.1, which produces
>> the same behavior, so I don't know that this is a bug, probably just
>> unexpected behavior.
>>
>>
>> #!/usr/bin/env python
>> # Simple program to test for type 1 fonts.
>> # Generate a line graph w/linear and log Y axes.
>>
>> from matplotlib import rc, rcParams
>>
>> #rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
>>
>> # These lines are needed to get type-1 results:
>> #
>> http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
>> rcParams['ps.useafm'] = True
>> rcParams['pdf.use14corefonts'] = True
>> rcParams['text.usetex'] = False
>>
>> import matplotlib.pyplot as plt
>>
>> YSCALES = ['linear', 'log']
>>
>> def plot(filename, yscale):
>> plt.figure(1)
>> xvals = range(1, 2)
>> yvals = xvals
>> plt.plot(xvals, yvals)
>> plt.yscale(yscale)
>> #YTICKS = [1, 10]
>> #plt.yticks(YTICKS, YTICKS) # locs, labels
>> ax = plt.gca()
>> #print ax.get_xticklabels()[0].get_text()
>> print ",".join([a.get_label() for a in ax.get_yticklabels()])
>> plt.savefig(filename + '.pdf')
>>
>>
>> if __name__ == '__main__':
>> for yscale in YSCALES:
>> plot('linegraph-' + yscale, yscale)
>>
>>
>>
>> Does anyone know a clean way to get Type 1 fonts with log axes?
>>
>> Thanks,
>> Brandon
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_sfd2d_oct
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:http://p.sf.net/sfu/appdyn_sfd2d_oct
>
>
>
> _______________________________________________
> Matplotlib-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Brandon H. <bra...@st...> - 2012年10月30日 16:25:56
Hi Phil,
Next time I'll be more explicit. I added the question to SA after I tried
to get a public link to my message and saw that archives past July of this
year seem to be missing. It wasn't clear that this list was even still
alive:
http://sourceforge.net/mailarchive/forum.php?forum_name=matplotlib-users
Any idea why the archives seem to have stopped?
Thanks,
Brandon
On Tue, Oct 30, 2012 at 2:23 AM, Phil Elson <pel...@gm...> wrote:
> Hi Brandon,
>
> I notice that this is cross-posted on StackOverflow (
> http://stackoverflow.com/questions/13132194/type-1-fonts-with-log-graphs).
> Personally, I have no problem with cross posting, but to save two people
> having to answer the same question, I would make sure it was explicit that
> this had also been posted elsewhere.
>
> Thanks,
>
> Phil
>
>
> On 30 October 2012 03:13, Brandon Heller <bra...@st...> wrote:
>
>> Hi,
>>
>> I'm trying to use Matplotlib graphs as part of a camera-ready
>> submission, and the publishing house requires the use of Type 1 fonts
>> only.
>>
>> I'm finding that the PDF backend happily outputs Type-1 fonts for
>> simple graphs with linear Y axes, but outputs Type-3 fonts for
>> logarithmic Y axes.
>>
>> Using a logarithmic yscale incurs the use of mathtext, which seems to
>> use Type 3 fonts, presumably because of the default use of exponential
>> notation. I can use an ugly hack to get around this - using
>> pyplot.yticks() to force the axis ticks to not use exponents - but
>> this would require moving the plot region to accommodate large labels
>> (like 10 ^ 6) or writing the axes as 10, 100, 1K, etc. so they fit.
>>
>> There's a minimum working example below, which I've tested with the
>> matplotlib master branch as of today, as well as 1.1.1, which produces
>> the same behavior, so I don't know that this is a bug, probably just
>> unexpected behavior.
>>
>>
>> #!/usr/bin/env python
>> # Simple program to test for type 1 fonts.
>> # Generate a line graph w/linear and log Y axes.
>>
>> from matplotlib import rc, rcParams
>>
>> #rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
>>
>> # These lines are needed to get type-1 results:
>> #
>> http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
>> rcParams['ps.useafm'] = True
>> rcParams['pdf.use14corefonts'] = True
>> rcParams['text.usetex'] = False
>>
>> import matplotlib.pyplot as plt
>>
>> YSCALES = ['linear', 'log']
>>
>> def plot(filename, yscale):
>> plt.figure(1)
>> xvals = range(1, 2)
>> yvals = xvals
>> plt.plot(xvals, yvals)
>> plt.yscale(yscale)
>> #YTICKS = [1, 10]
>> #plt.yticks(YTICKS, YTICKS) # locs, labels
>> ax = plt.gca()
>> #print ax.get_xticklabels()[0].get_text()
>> print ",".join([a.get_label() for a in ax.get_yticklabels()])
>> plt.savefig(filename + '.pdf')
>>
>>
>> if __name__ == '__main__':
>> for yscale in YSCALES:
>> plot('linegraph-' + yscale, yscale)
>>
>>
>>
>> Does anyone know a clean way to get Type 1 fonts with log axes?
>>
>> Thanks,
>> Brandon
>>
>>
>> ------------------------------------------------------------------------------
>> Everyone hates slow websites. So do we.
>> Make your web apps faster with AppDynamics
>> Download AppDynamics Lite for free today:
>> http://p.sf.net/sfu/appdyn_sfd2d_oct
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>
>
From: Brickle M. <bri...@gm...> - 2012年10月30日 14:40:41
For some fun I am trying to plot a surface representation of 2D image 
where the height level corresponds to the intensity at each pixel. I 
have been able to change the cmap but would like to assign the original 
pixel colour values (Grayscale or RGB) to corresponding in the surface 
plot. Is this possible? To be honest, I not even sure if I have 
constructed the plot correctly.
Any help appreciated.
Regards,
Brickle.
----
----- Surface Representation of 2D Image --------
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
from skimage import data, color
import numpy as np
from scipy import ndimage
from matplotlib import cm
image = color.rgb2gray(data.lena())
image = ndimage.gaussian_filter(image, 8)
x = range(image.shape[0])
y = range(image.shape[1])
X,Y = np.meshgrid(x,y) # Is this the correct way?
Z = image # Not sure if this is correct?
fig = plt.figure()
ax = fig.add_subplot(1,1,1, projection='3d')
ax.plot_surface(X,Y,Z, cmap=cm.gray)
plt.show()
----------------------------------------------
From: Michael D. <md...@st...> - 2012年10月30日 12:51:41
There are a couple of alternative formatters for log scaling that don't 
require mathtext.
You can do:
from matplotlib.tickers import LogFormatter, LogFormatterExponent
...
ax.xaxis.set_major_formatter(LogFormatter())
# or LogFormatterExponent(), which is just the exponent
To clarify the font issue. The PDF backend has no support for 
outputting Type 1 fonts. There is an rcParam "pdf.fonttype" that allows 
you to choose between Type 3 and Type 42 fonts, however. Type 3 stores 
each character as a path and then uses those to put strings together. 
It supports font subsetting, so an entire large font is not embedded in 
the file. Type 42 (essentially) just embeds a TrueType font in the 
file, and we don't support subsetting there.
There is also the "pdf.use14corefonts" that will use the 14 built-in PDF 
fonts whenever possible (and therefore not embed any fonts). However, 
mathtext requires a special font for the math symbols, and thus it 
starts to embed fonts.
You may try setting "mathtext.default" to "regular", which will use the 
font used as the default for the rest of the text first. This should 
have the effect of not embedding any extra fonts in the file as long as 
you don't use any special symbols in the math.
Mike
On 10/30/2012 05:23 AM, Phil Elson wrote:
> Hi Brandon,
>
> I notice that this is cross-posted on StackOverflow 
> (http://stackoverflow.com/questions/13132194/type-1-fonts-with-log-graphs).
> Personally, I have no problem with cross posting, but to save two 
> people having to answer the same question, I would make sure it was 
> explicit that this had also been posted elsewhere.
>
> Thanks,
>
> Phil
>
>
> On 30 October 2012 03:13, Brandon Heller <bra...@st... 
> <mailto:bra...@st...>> wrote:
>
> Hi,
>
> I'm trying to use Matplotlib graphs as part of a camera-ready
> submission, and the publishing house requires the use of Type 1 fonts
> only.
>
> I'm finding that the PDF backend happily outputs Type-1 fonts for
> simple graphs with linear Y axes, but outputs Type-3 fonts for
> logarithmic Y axes.
>
> Using a logarithmic yscale incurs the use of mathtext, which seems to
> use Type 3 fonts, presumably because of the default use of exponential
> notation. I can use an ugly hack to get around this - using
> pyplot.yticks() to force the axis ticks to not use exponents - but
> this would require moving the plot region to accommodate large labels
> (like 10 ^ 6) or writing the axes as 10, 100, 1K, etc. so they fit.
>
> There's a minimum working example below, which I've tested with the
> matplotlib master branch as of today, as well as 1.1.1, which produces
> the same behavior, so I don't know that this is a bug, probably just
> unexpected behavior.
>
>
> #!/usr/bin/env python
> # Simple program to test for type 1 fonts.
> # Generate a line graph w/linear and log Y axes.
>
> from matplotlib import rc, rcParams
>
> #rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
>
> # These lines are needed to get type-1 results:
> #
> http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
> rcParams['ps.useafm'] = True
> rcParams['pdf.use14corefonts'] = True
> rcParams['text.usetex'] = False
>
> import matplotlib.pyplot as plt
>
> YSCALES = ['linear', 'log']
>
> def plot(filename, yscale):
> plt.figure(1)
> xvals = range(1, 2)
> yvals = xvals
> plt.plot(xvals, yvals)
> plt.yscale(yscale)
> #YTICKS = [1, 10]
> #plt.yticks(YTICKS, YTICKS) # locs, labels
> ax = plt.gca()
> #print ax.get_xticklabels()[0].get_text()
> print ",".join([a.get_label() for a in ax.get_yticklabels()])
> plt.savefig(filename + '.pdf')
>
>
> if __name__ == '__main__':
> for yscale in YSCALES:
> plot('linegraph-' + yscale, yscale)
>
>
>
> Does anyone know a clean way to get Type 1 fonts with log axes?
>
> Thanks,
> Brandon
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> <mailto:Mat...@li...>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Phil E. <pel...@gm...> - 2012年10月30日 09:23:12
Hi Brandon,
I notice that this is cross-posted on StackOverflow (
http://stackoverflow.com/questions/13132194/type-1-fonts-with-log-graphs).
Personally, I have no problem with cross posting, but to save two people
having to answer the same question, I would make sure it was explicit that
this had also been posted elsewhere.
Thanks,
Phil
On 30 October 2012 03:13, Brandon Heller <bra...@st...> wrote:
> Hi,
>
> I'm trying to use Matplotlib graphs as part of a camera-ready
> submission, and the publishing house requires the use of Type 1 fonts
> only.
>
> I'm finding that the PDF backend happily outputs Type-1 fonts for
> simple graphs with linear Y axes, but outputs Type-3 fonts for
> logarithmic Y axes.
>
> Using a logarithmic yscale incurs the use of mathtext, which seems to
> use Type 3 fonts, presumably because of the default use of exponential
> notation. I can use an ugly hack to get around this - using
> pyplot.yticks() to force the axis ticks to not use exponents - but
> this would require moving the plot region to accommodate large labels
> (like 10 ^ 6) or writing the axes as 10, 100, 1K, etc. so they fit.
>
> There's a minimum working example below, which I've tested with the
> matplotlib master branch as of today, as well as 1.1.1, which produces
> the same behavior, so I don't know that this is a bug, probably just
> unexpected behavior.
>
>
> #!/usr/bin/env python
> # Simple program to test for type 1 fonts.
> # Generate a line graph w/linear and log Y axes.
>
> from matplotlib import rc, rcParams
>
> #rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
>
> # These lines are needed to get type-1 results:
> #
> http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
> rcParams['ps.useafm'] = True
> rcParams['pdf.use14corefonts'] = True
> rcParams['text.usetex'] = False
>
> import matplotlib.pyplot as plt
>
> YSCALES = ['linear', 'log']
>
> def plot(filename, yscale):
> plt.figure(1)
> xvals = range(1, 2)
> yvals = xvals
> plt.plot(xvals, yvals)
> plt.yscale(yscale)
> #YTICKS = [1, 10]
> #plt.yticks(YTICKS, YTICKS) # locs, labels
> ax = plt.gca()
> #print ax.get_xticklabels()[0].get_text()
> print ",".join([a.get_label() for a in ax.get_yticklabels()])
> plt.savefig(filename + '.pdf')
>
>
> if __name__ == '__main__':
> for yscale in YSCALES:
> plot('linegraph-' + yscale, yscale)
>
>
>
> Does anyone know a clean way to get Type 1 fonts with log axes?
>
> Thanks,
> Brandon
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_sfd2d_oct
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Brandon H. <bra...@st...> - 2012年10月30日 03:13:25
Hi,
I'm trying to use Matplotlib graphs as part of a camera-ready
submission, and the publishing house requires the use of Type 1 fonts
only.
I'm finding that the PDF backend happily outputs Type-1 fonts for
simple graphs with linear Y axes, but outputs Type-3 fonts for
logarithmic Y axes.
Using a logarithmic yscale incurs the use of mathtext, which seems to
use Type 3 fonts, presumably because of the default use of exponential
notation. I can use an ugly hack to get around this - using
pyplot.yticks() to force the axis ticks to not use exponents - but
this would require moving the plot region to accommodate large labels
(like 10 ^ 6) or writing the axes as 10, 100, 1K, etc. so they fit.
There's a minimum working example below, which I've tested with the
matplotlib master branch as of today, as well as 1.1.1, which produces
the same behavior, so I don't know that this is a bug, probably just
unexpected behavior.
#!/usr/bin/env python
# Simple program to test for type 1 fonts.
# Generate a line graph w/linear and log Y axes.
from matplotlib import rc, rcParams
#rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
# These lines are needed to get type-1 results:
# http://nerdjusttyped.blogspot.com/2010/07/type-1-fonts-and-matplotlib-figures.html
rcParams['ps.useafm'] = True
rcParams['pdf.use14corefonts'] = True
rcParams['text.usetex'] = False
import matplotlib.pyplot as plt
YSCALES = ['linear', 'log']
def plot(filename, yscale):
 plt.figure(1)
 xvals = range(1, 2)
 yvals = xvals
 plt.plot(xvals, yvals)
 plt.yscale(yscale)
 #YTICKS = [1, 10]
 #plt.yticks(YTICKS, YTICKS) # locs, labels
 ax = plt.gca()
 #print ax.get_xticklabels()[0].get_text()
 print ",".join([a.get_label() for a in ax.get_yticklabels()])
 plt.savefig(filename + '.pdf')
if __name__ == '__main__':
 for yscale in YSCALES:
 plot('linegraph-' + yscale, yscale)
Does anyone know a clean way to get Type 1 fonts with log axes?
Thanks,
Brandon
From: Mike K. <mc...@gm...> - 2012年10月30日 00:00:18
On 10/29/12 1:08 PM, Jody Klymak wrote:
>
> On Oct 28, 2012, at 17:47 PM, Eric Firing <ef...@ha...> wrote:
>>
>> cb = colorbar()
>> cb.solids.set_rasterized(True)
>
>
> Great! Though I think it'd have taken me a while to figure that one out!
I gotta agree. Is this (and the solids object) documented anywhere?
M
From: Jody K. <jk...@uv...> - 2012年10月29日 17:08:49
On Oct 28, 2012, at 17:47 PM, Eric Firing <ef...@ha...> wrote:
> 
> cb = colorbar()
> cb.solids.set_rasterized(True)
Great! Though I think it'd have taken me a while to figure that one out!
Thanks, Jody
--
Jody Klymak 
http://web.uvic.ca/~jklymak/
From: Daryl H. <ak...@gm...> - 2012年10月29日 14:50:21
Attachments: contourf_clip.py
Hi,
I've been attempting to get basemap to clip a contourf display. I have not
had any luck! Attached is a self contained example. Could somebody kindly
point out what I am doing wrong!?!
If I remove the zorder settings, I get no data plotted!
The goal is to clip my contourf plots by political boundaries. I am
using a simple rectangle at the moment for illustration.
thanks,
 daryl
From: Eric F. <ef...@ha...> - 2012年10月29日 01:19:25
On 2012年10月26日 6:00 PM, Jody Klymak wrote:
>
> Hi all,
>
> So I figured out the magic of "rasterized=True", which is *really*
> helpful!
>
> However, the colorbar doesn't seem to accept rasterized=True, so
> there are little lines every facet (zoom on the attached pdf). Is
> there another way to get the colorbar colors rasterized?
Try:
cb = colorbar()
cb.solids.set_rasterized(True)
Incidentally, the lines in the pdf are an artifact of most pdf viewers, 
not a bug in the pdf file. It is possible that there is some way to 
construct the pdf files such that this does not happen, without 
introducing other artifacts, but we have never found one.
Eric
>
> Thanks Jody
> x = linspace(0,1,1000)
> X = outer(x,x)
> pcolormesh(X,cmap=get_cmap('RdBu_r',lut=32),rasterized=True)
> colorbar()
> savefig('Test.pdf',dpi=50)
>
>
>
>
> --
> Jody Klymak
> http://web.uvic.ca/~jklymak/
>
>
>
>
>
> ------------------------------------------------------------------------------
> WINDOWS 8 is here.
> Millions of people. Your app in 30 days.
> Visit The Windows 8 Center at Sourceforge for all your go to resources.
> http://windows8center.sourceforge.net/
> join-generation-app-and-make-money-coding-fast/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Benjamin R. <ben...@ou...> - 2012年10月28日 00:05:29
On Saturday, October 27, 2012, Andreas Hilboll wrote:
> Hi, maybe matplotlib is capable of doing this:
>
> I have two gridded datasets, A and B, for say Europe. Now I want to plot
> a 3d surface with the z-values given by dataset A. The surface should be
> colored using a given color palette and the values from dataset B.
>
> Any ideas on how to do this are greatly appreciated =)
>
> Cheers, Andreas.
>
>
Sorry, I have been bogged down with work with the impending "frankenstorm",
and I would expect Jeff to be as well.
Hybrid 3d transforms has been a goal of mine, but there are various
limitations that I have yet to have time to address. So, there isn't any
nice ways to do what you want.
Now for the dirty ways. Theoretically, you could still create an Axes3d
object, and have the Basemap object calculate all of the coordinate
transforms, and plot that data at the appropriate z coordinates. There are
also various methods in axes3d to transform normal artists into 3d artists,
so you could capture the output of drawcounties(), convert it into a 3d
object.
If you get this working, please let us know and share examples! We would
love to see them!
Ben Root
From: Ethan G. <eth...@gm...> - 2012年10月28日 00:00:39
Hi Andreas, 
Someone else, please correct me if I'm wrong, but I think the only way to do this is to provide your own "facecolors" map. Pick your preferred color map and apply it to dataset B, then now use mplot3d plot_surface(X,Y,Z_A,facecolors=B_colors). 
Assuming you are running inside pylab or have done similar imports, the following example should work
-------------------------------------------
import mpl_toolkits.mplot3d.axes3d
x=arange(10)
y=arange(10)
x,y=meshgrid(x,y)
za=sin(np.deg2rad(x))+20*cos(np.deg2rad(y))
zb=x*25
colors=cm.jet(zb)
ax = gca(projection='3d')
surf = ax.plot_surface(x,y,za,rstride=1,cstride=1,facecolors=colors)
draw() #I'm not sure why the draw command is necessary... anyone?
-------------------------------------------
Note, plot_surface will apply shading by default, you can turn it off and just use your supplied colors using the shade=False keyword arg
ethan
On Oct 27, 2012, at 2:09 AM, Andreas Hilboll wrote:
> Hi, maybe matplotlib is capable of doing this:
> 
> I have two gridded datasets, A and B, for say Europe. Now I want to plot
> a 3d surface with the z-values given by dataset A. The surface should be
> colored using a given color palette and the values from dataset B.
> 
> Any ideas on how to do this are greatly appreciated =)
> 
> Cheers, Andreas.
> 
> ------------------------------------------------------------------------------
> WINDOWS 8 is here. 
> Millions of people. Your app in 30 days.
> Visit The Windows 8 Center at Sourceforge for all your go to resources.
> http://windows8center.sourceforge.net/
> join-generation-app-and-make-money-coding-fast/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Andreas H. <li...@hi...> - 2012年10月27日 08:09:27
Hi, maybe matplotlib is capable of doing this:
I have two gridded datasets, A and B, for say Europe. Now I want to plot
a 3d surface with the z-values given by dataset A. The surface should be
colored using a given color palette and the values from dataset B.
Any ideas on how to do this are greatly appreciated =)
Cheers, Andreas.
From: Jody K. <jk...@uv...> - 2012年10月27日 04:01:09
Attachments: Test.pdf
Hi all,
So I figured out the magic of "rasterized=True", which is *really* helpful!
However, the colorbar doesn't seem to accept rasterized=True, so there are little lines every facet (zoom on the attached pdf). Is there another way to get the colorbar colors rasterized?
Thanks Jody
x = linspace(0,1,1000)
X = outer(x,x)
pcolormesh(X,cmap=get_cmap('RdBu_r',lut=32),rasterized=True)
colorbar()
savefig('Test.pdf',dpi=50)
From: Chloe L. <ch...@be...> - 2012年10月26日 17:49:18
Chloe Lewis 
PhD candidate, Harte Lab
Division of Ecosystem Sciences, ESPM
University of California, Berkeley
137 Mulford Hall
Berkeley, CA 94720
ch...@be...
Begin forwarded message:
> From: Chloe Lewis <ch...@be...>
> Subject: Re: [Matplotlib-users] how to express statistical data in colors
> Date: October 26, 2012 10:47:54 AM PDT
> To: ra...@0x...
> 
> you'll be doing something like the second color bar, but making the boundary and color definitions a lot more flexible. Where the discrete color bar uses
> 
> cmap = mpl.colors.ListedColormap(['r', 'g', 'b', 'c'])
> bounds = [1, 2, 4, 7, 8]
> you'll be making a whole LinearSegmentedColormap, see
> http://matplotlib.org/api/colors_api.html#matplotlib.colors.LinearSegmentedColormap
> and check out specifically the ascii-art explanation of interpolation between row[i] and row[i+1]. Red, green, blue will break based on your data density and how you want to express 'intensity'. And depending on whether you'll make it red-green-colorblindness neutral!
> Interesting problem. Has it been implemented in some other software?
> 
> Chloe Lewis 
> PhD candidate, Harte Lab
> Division of Ecosystem Sciences, ESPM
> University of California, Berkeley
> 137 Mulford Hall
> Berkeley, CA 94720
> ch...@be...
> 
From: <ra...@0x...> - 2012年10月23日 08:14:09
hi,
I'd like to present data in a colorbar-style graphic.
The data to plot is in this form: [1,2,4,4,4.1,4.3,6,7].
The colorbar with this data should show at the begin the color with low
intensity. In more or less the middle of the colorbar the intensity
should be much more because there are a lot values around 4-4.3 and at
the end the intensity should be low again. I imagine low to middle
intensity to show with the color blue and high intensity with nearly by
or with the color black.
With colobar-style I mean this:
http://matplotlib.org/examples/api/colorbar_only.html (the first bar).
I assume matplotlib already provides such a method I cant find.. so any
input is welcome:)
thank you
From: troyrock <tro...@ro...> - 2012年10月22日 23:22:25
I figured out the problem. I need to call self.canvas.draw() in order to
update the image. Sorry for the email.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Would-like-to-update-visible-plot-using-pyside-and-matplotlib-tp39576p39577.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: troyrock <tro...@ro...> - 2012年10月22日 23:04:27
I have a tool to show information extracted from various experiments and then
stored in a database. I would like to update a plot shown in the lower half
of the window when information such as the ranges of variables are modified
in the upper half. I can initially put data into the plot, however when I
want to change the contents (such as add another line to the plot), the 
changes don't get displayed. Here is some code to illustrate the problem:
import matplotlib
matplotlib.rcParams['backend.qt4'] = 'PySide'
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
matplotlib.use('Qt4Agg')
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as
FigureCanvas
from PySide import QtCore, QtGui
import sys
class TabDialog(QtGui.QDialog):
 def __init__(self):
 super(TabDialog, self).__init__()
 tabWidget = QtGui.QTabWidget()
 tabWidget.addTab(AnalyzeTab(), self.tr("Analyze"))
 buttonLayout = QtGui.QHBoxLayout()
 saveButton = QtGui.QPushButton(self.tr("Update"))
 saveButton.clicked[bool].connect(self.update)
 buttonLayout.addWidget(saveButton)
 mainLayout = QtGui.QVBoxLayout()
 mainLayout.addWidget(tabWidget)
 mainLayout.addLayout(buttonLayout)
 self.setLayout(mainLayout)
 def update(self):
 data.update()
class DataHolder():
 def __init__(self):
 self.gFig = Figure()
 self.ax = self.gFig.add_subplot(111)
 self.ax.plot([1,2,4,0.1])
 self.canvas = FigureCanvas(self.gFig)
 def update(self):
 self.ax.plot([8,6,4,2])
class AnalyzeTab(QtGui.QWidget):
 def __init__(self, parent=None):
 QtGui.QWidget.__init__(self, parent)
 analyzeLayout = QtGui.QGridLayout()
 analyzeLayout.addWidget(data.canvas, 2, 0, 6, 8)
 self.setLayout(analyzeLayout)
if __name__ == "__main__":
 app = QtGui.QApplication(sys.argv)
 data = DataHolder()
 tabdialog = TabDialog()
 tabdialog.show()
 sys.exit(app.exec_())
Any suggestions are very much appreciated.
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Would-like-to-update-visible-plot-using-pyside-and-matplotlib-tp39576.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: fiolj <fi...@ya...> - 2012年10月22日 17:00:55
Hi, some time ago I needed the same thing and hacked the function
histogram (from numpy or matplo. Here goes my function
## Calculates the histogram allowing for overlapping bins, which are
given by
#
# @param a
# @param bins a sequence of pairs (left,right), limits for each bin
#
# @return hist (numpy array)
# bin_centers (numpy array)
def myhistogram(a, bins):
 """
 Compute the histogram of a set of data.
 Parameters
 ----------
 a : array_like
 Input data.
 bins : sequence of pairs
 It defines the bin edges (left,right), allowing for non-uniform
bin widths.
 Returns
 -------
 hist : array
 The values of the histogram. See `normed` and `weights` for a
 description of the possible semantics.
 bin_centers : array of dtype float
 Return the bin centers ``(length(hist))``.
 Notes
 -----
 All but the last (righthand-most) bin is half-open. In other words, if
 `bins` is::
 [1, 2, 3, 4]
 then the first bin is ``[1, 2)`` (including 1, but excluding 2) and the
 second ``[2, 3)``. The last bin, however, is ``[3, 4]``, which *includes*
 4.
 Examples
 --------
 >>> myhistogram([1,2,1], bins=[(0,1),(1,1.5),(1.5,2.5),(2,3)])
 (array([0.5, 1.25, 2, 2.5]), array([0, 0, 1, 2, 3]))
 """
 bins = np.asarray(bins) # bins are 2-dimensional arrays
of shape (n,2)
 if len(bins.shape) != 2 or bins.shape[1] != 2:
 raise AttributeError, 'bins must be a list/array of 2-tuples.'
 a = np.asarray(a)
 a = a.ravel()
 n = np.zeros(len(bins), int)
 block = 65536
 for i in np.arange(0, len(a), block):
 sa = np.sort(a[i:i+block])
 n += np.r_[sa.searchsorted(bins[:-1,1], 'left'),
sa.searchsorted(bins[-1,1], 'right')]\
 - np.r_[sa.searchsorted(bins[:-1,0], 'left'),
sa.searchsorted(bins[-1,0], 'right')]
 return n, (bins[:,0]+bins[:,1])/2.
From: Larry C. <lar...@gm...> - 2012年10月22日 15:55:36
Hi
I have been doing some work that generates a lot of plots and since the
plots were taking a long time I looked into to whether I could speed up the
process.
I found some information on how I might improve things from the following
link:
http://stackoverflow.com/questions/11688318/how-to-speed-up-matplotlib-when-plotting-and-saving-lots-of-figureswhich
showa that you can speed things up by using the same axes and simply
updating the line data.
When I adapted this idea to my plots I noticed that, though the plot loop
was quicker my script was running slower. I wrote a code snippet to repeat
the problem - shown below:
#!/usr/bin/env python
import os, matplotlib, time
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import numpy as np
from cmpactionresultsbetweenviews_1 import getPlotHtml
allActionPlotLists = [[0, 1, 2 , 3, 4, 5, 6, 7, 8, 9],
 [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
 [9,8,7,6,5,4,3,2,1,0],
 [19,18,17,16,15,14,13,12,11,10]]
allActionLegendsLists = [str(i) for i in range(len(allActionPlotLists[0]))]
legendProps={'labelspacing':0.5, 'prop':{'size':8}}
colours=['b+-', 'r+-', 'g+-', 'k+-', 'c+-', 'm+-', 'bD:', 'rD:', 'gD:',
'kD:']
fig = plt.figure()
ax = None
plotlines = [None for i in range(len(allActionPlotLists))]
savedir = "tmpRes"
if not os.path.exists(savedir):
 os.makedirs(savedir)
figSrcFnRoot = "plotFil"
fil = open(os.path.join(savedir, "savepng.html"), 'w')
xlabel = "x label"
ylabel = "values"
colours=['b+-', 'r+-', 'g+-', 'k+-', 'c+-', 'm+-', 'bD:', 'rD:', 'gD:',
'kD:']
for i in range(20):
 start_plot_time = time.time()
 plottitle = "Plot %d" % (i)
 fig.suptitle("")
 fig.suptitle(plottitle)
 for subPltIdx in range(len(allActionPlotLists)):
 li = allActionPlotLists[subPltIdx]
 if ax == None:
 ax = fig.add_subplot(1,1,1)
 ax.set_xlabel(xlabel)
 ax.set_ylabel(ylabel)
 if plotlines[subPltIdx] == None:
 ax.set_xlabel(xlabel)
 ax.set_ylabel(ylabel)
 plotlines[subPltIdx] = ax.plot(range(len(li)), li,
colours[subPltIdx])[0]
 else:
 plotlines[subPltIdx].set_ydata(li)
 plotlines[subPltIdx].set_xdata(range(len(li)))
 fig.legend(plotlines, allActionLegendsLists, labelspacing=0.5,
prop=legendProps['prop'])
 # **** change the above line for the one below and the increasing save
time problem goes away
 #ax.legend(plotlines, allActionLegendsLists, labelspacing=0.5,
prop=legendProps['prop'])
 print "plot Execution time:", time.time()-start_plot_time
 figfn = "%s_%d" % (figSrcFnRoot, i)
 figfnlink = figfn.replace('%',
'%25').replace(';','%3b').replace(':','%3A')
 fn = os.path.join(savedir, "%s.png" % figfn)
 start_time = time.time()
 fig.savefig(fn, format='png',dpi=75)
 print "savefig Execution time:", time.time()-start_time
 htmlStr = ''
 htmlStr += '<center><img src="%s" alt="could not find %s
image"/></center>' % (os.path.join(".","%s.png" % figfnlink), figfn)
 fil.write(htmlStr + "<br>")
plt.close()
fil.close()
A little further investigation showed that savefig was taking longer each
run of the loop. I eventually noticed that replacing the call to
fig.legend() with ax.legend() solved the problem. Anyone know why the time
taken to save the plot increases when using fig.legend() in the code above ?
While doing this I also noticed a couple of other things:
1. I cannot seem to clear the figure title, so when I re-set it I get the
new title overlaying the old one in the plot output. Does anyone know how
to completely clear and reset the title of an existing figure ?
2. The call to figure.legend() puts the legends nicely outside the plot
boundaries (in the top right hand corner). The equivalent call to
ax.legend() places the legends inside the plot boundary. Does anyone know
a) why the behavior here is slightly different and b) how I can get the
legends outside the plot boundary using ax.legend() ?

Showing results of 355

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