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

Showing results of 368

<< < 1 2 3 4 5 .. 15 > >> (Page 3 of 15)
From: Jae-Joon L. <lee...@gm...> - 2012年03月27日 00:53:57
zorders are only meaningful among objects in a same axes.
An easy workaround is to move the legend in ax1 to ax2.
 ax2.add_artist(leg1)
 ax1.legend = None
Regards,
-JJ
On Thu, Mar 22, 2012 at 10:13 PM, David Verelst <dav...@gm...> wrote:
> Hi All,
>
> I am plotting on two different y-axes: one on the left (ax1) and one on
> the right (ax2). Both share the same x-axes. The problem I am facing
> relates back to the zorder of the legend (at least, that is what I
> think): I want it to be on the foreground at all times. In order to do
> so, I change the zorder of the ax1.legend (left y axes) such that the
> ax2.plots (right y-axes) are under ax1.legend. However, that doesn't
> work: all the plots on the right axes (so using ax2) end up above the
> legend 1 on the left, despite having a lower zorder.
>
> Note that I am also giving the grids on both ax1 and ax2 a lower zorder
> value compared to the legends, but the grid still ends up on top of
> legend 1 on the left.
>
> # version info:
>
> # Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2
>
> # NumPy 1.6.1, Matplotlib 1.1.0
>
> import pylab as plt
>
> import numpy as np
>
> # plotting on the left y-axes,
>
> ax1 = plt.axes(zorder=10)
>
> ax1.plot(range(0,5,1), 'r', label='ax1 ax1 ax1 ax1', zorder=11)
>
> ax1.plot(np.arange(3,4.1,1), 'r--', label='ax1 ax1 ax1 ax1', zorder=12)
>
> gr1 = ax1.grid(zorder=13)
>
> # legend of the left y-axes, force high zorder
>
> leg1 = ax1.legend(loc='upper left')
>
> leg1.set_zorder(30)
>
> # plotting on the right y-axes,
>
> ax2 = plt.twinx()
>
> ax2.set_zorder(20)
>
> ax2.plot(range(4,-1,-1), 'b', label='ax2 ax2 ax2 ax2', zorder=21)
>
> ax2.plot(np.arange(4,2.9,-1), np.arange(3,4.1,1), 'b--',
>
> label='ax2 ax2 ax2 ax2', zorder=22)
>
> gr2 = ax2.grid(zorder=23)
>
> # legend of the right y-axes, force high zorder
>
> leg2 = ax2.legend(loc='upper right')
>
> leg2.set_zorder(40)
>
> print '======= zorder:'
>
> print ' ax1: %i' % ax1.get_zorder()
>
> print ' ax2: %i' % ax2.get_zorder()
>
> print 'leg1: %i' % leg1.get_zorder()
>
> print 'leg2: %i' % leg2.get_zorder()
>
>
> What am I missing here?
> Thanks,
> David
>
>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Emmanuel M. <ema...@ya...> - 2012年03月27日 00:25:02
Hello,
I am programming using POO (object programming)
I cannot find a way to create a plot as an object
In concept, I would like to do something like
"""
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
self.figure = Figure(figsize=(600,600), dpi=72, facecolor=(1,1,1), edgecolor=(0,0,0))
self.figureCanvas = FigureCanvas(self.figure)
for i in range(2):
  plots.append(create_axis())  <-- create plot object
self.plots[1].xlabel = 'X1'
self.plots[2].xlabel = 'X2'
for plot in self.plots:
  self.figure.add_plots(plot)
self.figure.show()
self.plots[1].xlabel = 'XX1'
self.figure.updatedisplay()
"""
Is it possible?
If so, how?
From: klo uo <kl...@gm...> - 2012年03月27日 00:24:36
Does someone maybe knows of a project that allows exporting MPL 3D plot
(mpl_toolkits.mplot3d.Axes3D) to 3D file format, like OBJ, 3DS, BLEND ...
any kind?
From: Michael D. <md...@st...> - 2012年03月26日 23:11:08
On 03/26/2012 04:36 PM, Martin Mokrejs wrote:
> Hi,
> I wondered why the matplotlib.font_manager.rcParams contains sometimes
> escaped minus signs in font names:
>>>> font_manager.rcParams['mathtext.sf']
> 'sans\\-serif'
>>>> font_manager.findfont('sans-serif')
> Traceback (most recent call last):
> File "<stdin>", line 1, in<module>
> File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1327, in findfont
> font = fontManager.findfont(prop, **kw)
> File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1172, in findfont
> prop = FontProperties(prop)
> File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 673, in __init__
> self.set_fontconfig_pattern(family)
> File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 893, in set_fontconfig_pattern
> for key, val in self._parse_fontconfig_pattern(pattern).items():
> File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 685, in _parse_fontconfig_pattern
> return parse_fontconfig_pattern(pattern)
> File "/usr/lib64/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 127, in parse
> raise ValueError("Could not parse font string: '%s'\n%s" % (pattern, e))
> ValueError: Could not parse font string: 'sans-serif'
> Expected end of text (at char 4), (line:1, col:5)
>>>> font_manager.findfont('sans\\-serif')
> '/usr/share/fonts/mathematica-fonts/Vera.ttf'
>
> And there is nothing to read in the help string for this function, definitely
> a place where the escaping should be explained.
>
>>>> help(font_manager.findfont)
>>>>
> Anyway, I think the requirement for the escaping should be removed, it should be
> escaped internally in the routine. So why is it so? For historic reasons? ;-)
I've never seen this happen before. Are you setting "mathtext.sf" in a 
matplotlibrc file or in Python code? Can you provide either so I can 
see if I can reproduce the problem here?
>
>
>
>
> Isn't the escaping a cause for the seemingly missing fonts, like reported here?
> http://www.mail-archive.com/mat...@li.../msg22860.html
No -- that appears to be caused by either using the wrong font name or 
having an outdated font cache.
>
>
> I am also getting:
>
> /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmb10'] not found. Falling back to Bitstream Vera Sans
> (prop.get_family(), self.defaultFamily[fontext]))
> /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to Bitstream Vera Sans
> (prop.get_family(), self.defaultFamily[fontext]))
> /usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmss10'] not found. Falling back to Bitstream Vera Sans
> (prop.get_family(), self.defaultFamily[fontext]))
>
> The font to be used is assembled from several fields in the rcParams. I guess from:
>
>>>> [x for x in font_manager.rcParams.keys() if x.startswith('font')]
> ['font.cursive', 'font.family', 'font.fantasy', 'font.monospace', 'font.sans-serif', 'font.serif', 'font.size', 'font.stretch', 'font.style', 'font.variant', 'font.weight']
>>>> [x for x in font_manager.rcParams.values() if x.startswith('cm')]
> /usr/lib64/python2.7/site-packages/matplotlib/__init__.py:658: UserWarning: svg.embed_char_paths is deprecated and replaced with svg.fonttype; please use the latter.
> warnings.warn(self.msg_depr % (key, alt))
> Traceback (most recent call last):
> File "<stdin>", line 1, in<module>
> AttributeError: 'int' object has no attribute 'startswith'
>>>> [x for x in font_manager.rcParams.items() if x[1]=='cm']
> [('mathtext.fontset', 'cm')]
> What else is used to give out the 'cmb10', 'cmtt10' and 'cmss10'?
These are hardcoded in the mathtext engine and used when 
`mathtext.fontset` is set to `cm`.
Have you tried deleting your font cache? (~/.matplotlib/fontList.cache)
Mike
From: Magician <f_m...@ma...> - 2012年03月26日 22:14:48
Hi.
I want to install Matplotlib from source code on CentOS.
I've been using Matplotlib for a year.
But this is the first time for me to install CentOS by myself.
I installed CentOS 6.2 in basic install option.
Next, I installed NumPy and Matplotlib.
.matplotlibrc isn't set.
It looks successfully installed, but when I type show() command,
nothing appears.
I can export PNG image by using savefig() command, so maybe
I'm using invalid backend.
How can I display plots with show() command?
Magician
From: Martin M. <mmo...@fo...> - 2012年03月26日 20:35:28
Hi,
 I wondered why the matplotlib.font_manager.rcParams contains sometimes
escaped minus signs in font names:
>>> font_manager.rcParams['mathtext.sf']
'sans\\-serif'
>>> 
>>> font_manager.findfont('sans-serif')
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1327, in findfont
 font = fontManager.findfont(prop, **kw)
 File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 1172, in findfont
 prop = FontProperties(prop)
 File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 673, in __init__
 self.set_fontconfig_pattern(family)
 File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 893, in set_fontconfig_pattern
 for key, val in self._parse_fontconfig_pattern(pattern).items():
 File "/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py", line 685, in _parse_fontconfig_pattern
 return parse_fontconfig_pattern(pattern)
 File "/usr/lib64/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 127, in parse
 raise ValueError("Could not parse font string: '%s'\n%s" % (pattern, e))
ValueError: Could not parse font string: 'sans-serif'
Expected end of text (at char 4), (line:1, col:5)
>>> font_manager.findfont('sans\\-serif')
'/usr/share/fonts/mathematica-fonts/Vera.ttf'
>>> 
And there is nothing to read in the help string for this function, definitely
a place where the escaping should be explained.
>>> help(font_manager.findfont)
>>>
Anyway, I think the requirement for the escaping should be removed, it should be
escaped internally in the routine. So why is it so? For historic reasons? ;-)
Isn't the escaping a cause for the seemingly missing fonts, like reported here?
http://www.mail-archive.com/mat...@li.../msg22860.html
I am also getting:
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmb10'] not found. Falling back to Bitstream Vera Sans
 (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to Bitstream Vera Sans
 (prop.get_family(), self.defaultFamily[fontext]))
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmss10'] not found. Falling back to Bitstream Vera Sans
 (prop.get_family(), self.defaultFamily[fontext]))
The font to be used is assembled from several fields in the rcParams. I guess from:
>>> [x for x in font_manager.rcParams.keys() if x.startswith('font')]
['font.cursive', 'font.family', 'font.fantasy', 'font.monospace', 'font.sans-serif', 'font.serif', 'font.size', 'font.stretch', 'font.style', 'font.variant', 'font.weight']
>>> [x for x in font_manager.rcParams.values() if x.startswith('cm')]
/usr/lib64/python2.7/site-packages/matplotlib/__init__.py:658: UserWarning: svg.embed_char_paths is deprecated and replaced with svg.fonttype; please use the latter.
 warnings.warn(self.msg_depr % (key, alt))
Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
AttributeError: 'int' object has no attribute 'startswith'
>>> [x for x in font_manager.rcParams.items() if x[1]=='cm']
[('mathtext.fontset', 'cm')]
>>>
What else is used to give out the 'cmb10', 'cmtt10' and 'cmss10'?
>>> font_manager.findfont('cmb10')
'/usr/share/fonts/mathematica-fonts/Vera.ttf'
>>> font_manager.findfont('cmtt10')
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmtt10'] not found. Falling back to Bitstream Vera Sans
 (prop.get_family(), self.defaultFamily[fontext]))
'/usr/share/fonts/mathematica-fonts/Vera.ttf'
>>> font_manager.findfont('cmss10')
/usr/lib64/python2.7/site-packages/matplotlib/font_manager.py:1216: UserWarning: findfont: Font family ['cmss10'] not found. Falling back to Bitstream Vera Sans
 (prop.get_family(), self.defaultFamily[fontext]))
'/usr/share/fonts/mathematica-fonts/Vera.ttf'
>>>
Thanks,
Martin
From: Christopher G. <chr...@gm...> - 2012年03月26日 16:49:41
On Sun, Mar 11, 2012 at 2:32 PM, Christopher Graves <
chr...@gm...> wrote:
> On Sun, Mar 11, 2012 at 2:06 PM, Mike Kaufman <mc...@gm...> wrote:
>
>> On 3/11/12 8:14 AM, cgraves wrote:
>>
>>>
>>> Hi, here is an example script which places minor ticks with 2 per major
>>> tick
>>> (minor tick spacing is "fractional" of major tick spacing with relative
>>> interval of 1/2):
>>>
>>> from pylab import *
>>> fig=figure()
>>> ax=subplot(111)
>>> ax.autoscale(tight=True)
>>> plot([1,2,4],[1,2,3])
>>> x_ticks_maj_spacing =
>>> float(abs(ax.xaxis.get_**ticklocs()[0]-ax.xaxis.get_**ticklocs()[1]))
>>> x_ticks_min_spacing = x_ticks_maj_spacing/2
>>> ax.xaxis.set_minor_locator(**MultipleLocator(x_ticks_min_**spacing))
>>> y_ticks_maj_spacing =
>>> float(abs(ax.yaxis.get_**ticklocs()[0]-ax.yaxis.get_**ticklocs()[1]))
>>> y_ticks_min_spacing = y_ticks_maj_spacing/2
>>> ax.yaxis.set_minor_locator(**MultipleLocator(y_ticks_min_**spacing))
>>> show()
>>>
>>> This works fine. However, if one changes the axes limits then the major
>>> ticks get automatically adjusted to a different interval but the minor
>>> ticks
>>> remain at the positions they were already at. To see this, either use the
>>> zoom tools or do the following after running the above:
>>>
>>> xlim(1,2.5)
>>> fig.canvas.draw()
>>>
>>> The question is, what is the best way to maintain the fractional minor
>>> tick
>>> spacing? I suppose one could set up a way to update the set_minor_locator
>>> and redraw the figure each time the figure axes limits are adjusted, but
>>> is
>>> there a better way?
>>>
>>
>> Try this:
>>
>> from pylab import *
>> from matplotlib.ticker import AutoMinorLocator
>>
>> clf()
>> ax=subplot(111)
>> ax.autoscale(tight=True)
>> plot([1,2,4],[1,2,3])
>> ax.xaxis.set_minor_locator(**AutoMinorLocator(2))
>> ax.yaxis.set_minor_locator(**AutoMinorLocator(2))
>> draw()
>>
>> M
>>
>> PS: I believe this is a fairly new feature...
>>
>
> Thanks! Great news that AutoMinorLocator has been added and accomplishes
> this. Regarding the P.S. I can confirm that the feature was not in
> matplotlib 1.0.1 - I had to update to 1.1.0 to use it.
>
> Best /Chris
>
Hi Mike,
A follow-up question... When using that, if one then tries to manually use
the zoom-box tool available with a matplotlib plot, if one draws too small
of a box (less than 2 major ticks in x or y dimension, based on the
following error message), it gives the following error and further
operations on the plot do not work.
ValueError: Need at least two major ticks to find minor tick locations
( File "/usr/lib/pymodules/python2.7/matplotlib/ticker.py", line 1528, in
__call__ )
Any way to avoid this for now? (And ultimately, should this be made into a
bug fix request?)
Best /Chris
From: Tony Yu <ts...@gm...> - 2012年03月26日 13:56:56
On Mon, Mar 26, 2012 at 8:26 AM, Matthieu Brucher <
mat...@gm...> wrote:
> Indeed, a little bit less simple, but the solution nonetheless.
>
> Thank you!
>
>
> 2012年3月26日 Zachary Pincus <zac...@ya...>
>
>> > I'd like to display a scatter plot where the size for each element is
>> fixed. Currently, when I modify the size of the figure, the size of a
>> marker is fixed, and I would like it to be proportional to the window.
>> > I want this because the size of the marker indicates an extent, and I
>> would like it to confirm that the extents correctly cover the other points.
>>
>> If it's truly an extent, you might be better off drawing polygons of the
>> extent boundaries in the graph's coordinate system -- then things will
>> scale as you desire. This will require digging down a bit into the object
>> API -- make a new matplotlib.collections.PolyCollection (or
>> RegularPolyCollection), and add it to your axes with Axes.add_collection().
>>
>> Zach
>> ---------------------------------------------------------------------
>
>
I needed something similar a while back, and Jae-Joon Lee helped me find a
decent solution. Here're the results for square markers:
#~~~
import matplotlib.collections as collections
import matplotlib.transforms as transforms
class SquareCollection(collections.RegularPolyCollection):
 """Return a collection of squares."""
 def __init__(self, **kwargs):
 super(SquareCollection, self).__init__(4, rotation=np.pi/4.,
**kwargs)
 def get_transform(self):
 """Return transform scaling circle areas to data space."""
 ax = self.axes
 pts2pixels = 72.0 / ax.figure.dpi
 scale_x = pts2pixels * ax.bbox.width / ax.viewLim.width
 scale_y = pts2pixels * ax.bbox.height / ax.viewLim.height
 return transforms.Affine2D().scale(scale_x, scale_y)
#~~~
 Example use<https://github.com/tonysyu/mpltools/blob/master/mpltools/special/hinton.py>
.
Best,
-Tony
From: Matthieu B. <mat...@gm...> - 2012年03月26日 12:26:16
Indeed, a little bit less simple, but the solution nonetheless.
Thank you!
2012年3月26日 Zachary Pincus <zac...@ya...>
> > I'd like to display a scatter plot where the size for each element is
> fixed. Currently, when I modify the size of the figure, the size of a
> marker is fixed, and I would like it to be proportional to the window.
> > I want this because the size of the marker indicates an extent, and I
> would like it to confirm that the extents correctly cover the other points.
>
> If it's truly an extent, you might be better off drawing polygons of the
> extent boundaries in the graph's coordinate system -- then things will
> scale as you desire. This will require digging down a bit into the object
> API -- make a new matplotlib.collections.PolyCollection (or
> RegularPolyCollection), and add it to your axes with Axes.add_collection().
>
> Zach
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
-- 
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
From: Zachary P. <zac...@ya...> - 2012年03月26日 11:20:28
> I'd like to display a scatter plot where the size for each element is fixed. Currently, when I modify the size of the figure, the size of a marker is fixed, and I would like it to be proportional to the window.
> I want this because the size of the marker indicates an extent, and I would like it to confirm that the extents correctly cover the other points.
If it's truly an extent, you might be better off drawing polygons of the extent boundaries in the graph's coordinate system -- then things will scale as you desire. This will require digging down a bit into the object API -- make a new matplotlib.collections.PolyCollection (or RegularPolyCollection), and add it to your axes with Axes.add_collection().
Zach
From: Matthieu B. <mat...@gm...> - 2012年03月26日 09:06:07
hi,
I'd like to display a scatter plot where the size for each element is
fixed. Currently, when I modify the size of the figure, the size of a
marker is fixed, and I would like it to be proportional to the window.
I want this because the size of the marker indicates an extent, and I would
like it to confirm that the extents correctly cover the other points.
Thanks for any pointer,
Matthieu
-- 
Information System Engineer, Ph.D.
Blog: http://matt.eifelle.com
LinkedIn: http://www.linkedin.com/in/matthieubrucher
From: questions a. <que...@gm...> - 2012年03月26日 00:50:31
excellent, thanks, that worked and was able to plot using matplotlib
without ending up with the logical_or error.
thanks everyone
On Thu, Mar 22, 2012 at 3:59 AM, Goyo <goy...@gm...> wrote:
> El día 21 de marzo de 2012 01:03, questions anon
>
> > f=np.genfromtxt(inputfile, skip_header=6, dtype=None, names=True)
>
> I don't think you should be using dtype=None if you wand a 2D array.
> Also the names=True thing makes no sense to me since there isn't a row
> with field names. Try just this and I guess you'll get a 2D array:
>
> f=np.genfromtxt(inputfile, skip_header=6)
>
> Goyo
>
From: Tony Yu <ts...@gm...> - 2012年03月25日 15:58:36
On Thu, Mar 22, 2012 at 1:43 AM, C M <cmp...@gm...> wrote:
> For the following code, if I remove the transform=None a green patch is
> shown. If it is in, it is not shown. I would think that transform=None
> should have no effect. Why is this?
>
This is a weird one: When you set the transform, the artist notices (sets
the `_transformSet` flag) and remembers that you set it. If the axes sees
that you've set the artist's transform, it won't override the artist's
transform<https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/axes.py#L795>with
the data transform (which is what properly scales your patch to the
data coordinates).
Best,
-Tony
>
> Thanks,
> Che
>
>
> import matplotlib.pyplot as plt
> import matplotlib.patches as patches
> from matplotlib.path import Path
>
> fig = plt.figure()
> ax = fig.add_subplot(111)
>
> start = 0.2
> stop = .6
>
> verts = [
> (start, .2), # left, bottom
> (start, .4), # left, top
> (stop, .4), # right, top
> (stop, .2), # right, bottom
> (0., 0.), # ignored
> ]
> codes = [Path.MOVETO,
> Path.LINETO,
> Path.LINETO,
> Path.LINETO,
> Path.CLOSEPOLY,
> ]
>
> path = Path(verts, codes)
>
> patch = patches.PathPatch(path, facecolor='g',
> lw=1, edgecolor='grey',transform=None )
>
> ax.add_patch(patch)
>
> plt.show()
>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Ray O. <RO...@an...> - 2012年03月24日 19:52:33
I have a colleague experiencing similar issues. There seem to be known issues with PySide 1.1.0, e.g.,
http://bugs.pyside.org/show_bug.cgi?id=1119
I tried overriding the call to QApplication.setOverrideCursor(), which customizes the cursor within the Matplotlib navigation toolbar, but he then encountered another Shiboken-related segfault. It has been very frustrating, so I would be interested if anyone has a solution before the PySide team issues another release.
Ray
On Mar 24, 2012, at 1:10 PM, Wes McKinney wrote:
> Has anyone had much luck with PySide + matplotlib 1.1.0+? With stock
> EPD 7.2 full on Ubuntu 10.04 which comes with PySide 1.1.0, a simple
> plot like plot(arange(10)) with IPython in pylab mode causes a
> segfault. Joy.
> 
> Thanks,
> Wes
> 
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here 
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
-- 
Ray Osborn
Materials Science Division
Argonne National Laboratory
Argonne, IL 60439, USA
Phone: +1 (630) 252-9011
Email: RO...@an...
From: Wes M. <wes...@gm...> - 2012年03月24日 18:10:49
Has anyone had much luck with PySide + matplotlib 1.1.0+? With stock
EPD 7.2 full on Ubuntu 10.04 which comes with PySide 1.1.0, a simple
plot like plot(arange(10)) with IPython in pylab mode causes a
segfault. Joy.
Thanks,
Wes
From: David V. <dav...@gm...> - 2012年03月24日 10:59:38
A while ago I had exactly the same problem. I was running a script that 
create a lot of figures and saved them (as .png and .eps files) for 
viewing later (so not using the interactive viewing feature from 
pyplot). If I remember well, there was also a problem with the close() 
statement leaving some stuff in memory. Unfortunately I don't remember 
how the details went and how it got fixed. I guess I should have used 
the mailing list or created a bug report.
Anyway, when I need to generate a massive amount of figures these days I 
bypass the pyplot interface completely and go straight for the 
matplotlib API (at least as far as I understand this approach myself). 
When using pyplot, some figure tweaks did not persist upon saving, but 
that might as well have been due to my limited matplotlib knowledge. The 
procedure was inspired by this blog post: 
http://sjohannes.wordpress.com/2010/06/11/using-matplotlib-in-a-web-application/ 
and goes as follows:
from matplotlib.figure import Figure
# dependent on the backend you use
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as 
FigCanvas
# set figure size, dpi and initiate a workable fig object
fig = Figure(figsize=(figsize_x, figsize_y), dpi=dpi)
canvas = FigCanvas(fig)
fig.set_canvas(canvas)
# tweak white spacings
fig.subplots_adjust(left=wsleft, bottom=wsbottom, right=wsright,
top=wstop, wspace=wspace, hspace=hspace)
# big main title
fig.suptitle(grandtitle, size='x-large')
# create a subplot
ax = fig.add_subplot(nr_rows, nr_cols, plot_nr)
# do all your plotting stuff here on ax
# save the figure and close
fig.savefig('/path/to/figure/figname.png')
canvas.close()
fig.clear()
If interested, I can give you a more elaborate and working example of 
which parameters I tune how exactly.
Regards,
David
On 23/03/12 19:45, Eric Firing wrote:
> On 03/23/2012 08:05 AM, Albert Kottke wrote:
>> I am having problems clearing figures from memory. After saving the
>> figure, I use pyplot.close() on the figure handle and then del all of
>> the data and figure, as shown here:
>>
>> fig.savefig('plots/%(record_id)05i' % recording)
>> plt.close(fig)
>>
>> del accel, fourier_amp, fig, time, disp
>> gc.collect()
>>
>> Despite this, the figures don't appear to be closing. I am trying to
>> make 30k plots and I have to kill script every couple thousand and
>> restart because I run out of memory.
>>
>> Any suggestions?
> You are running a standalone script, correct? Make sure you are using
> only the agg backend. Before the first import of pyplot, do
>
> import matplotlib
> matplotlib.use("agg")
>
> I don't know if that will help, but it can't hurt.
>
> You might find matplotlib.cbook.report_memory() to be useful in tracking
> down the problem.
>
> Eric
>
>>
>> Albert
>>
>> ------------------------------------------------------------------------------
>> This SF email is sponsosred by:
>> Try Windows Azure free for 90 days Click Here
>> http://p.sf.net/sfu/sfd2d-msazure
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: John H. <jd...@gm...> - 2012年03月24日 03:49:24
On Fri, Mar 23, 2012 at 3:35 PM, Andrew Smart <and...@gm...>wrote:
> Hi,
> I'm running into this RuntimeError: Could not open facefile
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
> Cannot_Open_Resource when I'm trying to save out a series of *.png files in
> a loop. It crashes on this error after many passes through the loop and
> successful files get created, but then always on the same pass it does
> this. The full traceback is here:
>
> I wonder if the solution is as simple as doing font caching at the class
level rather than instance level. Andrew, could you try editing
matplotlib/backends/backend_agg.py and replace
class RendererAgg(RendererBase):
 """
 The renderer handles all the drawing primitives using a graphics
 context instance that controls the colors/styles
 """
 debug=1
 def __init__(self, width, height, dpi):
 if __debug__: verbose.report('RendererAgg.__init__',
'debug-annoying')
 RendererBase.__init__(self)
 self.texd = maxdict(50) # a cache of tex image rasters
 self._fontd = maxdict(50)
with
class RendererAgg(RendererBase):
 """
 The renderer handles all the drawing primitives using a graphics
 context instance that controls the colors/styles
 """
 debug=1
 _fontd = maxdict(50)
 texd = maxdict(50) # a cache of tex image rasters
 def __init__(self, width, height, dpi):
 if __debug__: verbose.report('RendererAgg.__init__',
'debug-annoying')
 RendererBase.__init__(self)
Does anyone see an issue with doing this caching at the class level? If
this works, we should have *many* fewer font files parsed.
w/o modifying the src code, a related way to test this idea is to reuse the
same figure instance and clear it at the start of the loop. Ie, rather than
for i in range(N):
 fig = plt.figure()
 ....plot_something
 fig.savefig(...)
do
fig = plt.figure()
for i in range(N):
 fig.clf()
 ....plot_something
 fig.savefig(...)
I would try the latter first, and if that works I would appreciate it if
you test the src code modification unless someone chimes in and tells us
that is a really bad idea.
JDH
From: Andrew S. <and...@gm...> - 2012年03月23日 21:28:53
Ok thank you - so one way to work around it is to just generate the files I
want in batches so Windows won't run out of file handles - but is there a
way to know how many handles are available? I'm trying to animate some data
and I don't really know how many frames there are - could be thousands.
Andy
On Fri, Mar 23, 2012 at 3:45 PM, Michael Droettboom <md...@st...> wrote:
> This is a known bug on Windows where it runs out of file handles after a
> while.
>
> This commit was an attempt to fix it, but it doesn't seem to work:
>
>
> https://github.com/matplotlib/matplotlib/commit/4cb2aaa87b0aa9efe7178d7510d3d091ef5206df
>
> I think we need a Windows user/developer/expert to get to the bottom of
> why file handles are not being freed to the OS.
>
> Mike
>
>
> On 03/23/2012 04:35 PM, Andrew Smart wrote:
>
> Hi,
> I'm running into this RuntimeError: Could not open facefile
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
> Cannot_Open_Resource when I'm trying to save out a series of *.png files in
> a loop. It crashes on this error after many passes through the loop and
> successful files get created, but then always on the same pass it does
> this. The full traceback is here:
>
> File
> "C:\Users\E440710\Desktop\PythonTransfer\fittslaw_ThroughputCalc_AS_break.py",
> line 744, in <module>
> fig.savefig(fname, transparent = True)
> File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 1174, in
> savefig
> self.canvas.print_figure(*args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\backend_bases.py", line
> 2027, in print_figure
> **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 451, in print_png
> FigureCanvasAgg.draw(self)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 400, in draw
> self.figure.draw(self.renderer)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
> draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 887, in
> draw
> func(*args)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
> draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\axes.py", line 1985, in
> draw
> a.draw(renderer)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
> draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 1043, in
> draw
> ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
> renderer)
> File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 994, in
> _get_tick_bboxes
> extent = tick.label1.get_window_extent(renderer)
> File "c:\Python32\lib\site-packages\matplotlib\text.py", line 743, in
> get_window_extent
> bbox, info = self._get_layout(self._renderer)
> File "c:\Python32\lib\site-packages\matplotlib\text.py", line 296, in
> _get_layout
> ismath=False)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 182, in get_text_width_height_descent
> font = self._get_agg_font(prop)
> File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
> line 223, in _get_agg_font
> font = FT2Font(str(fname))
> RuntimeError: Could not open facefile
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
> Cannot_Open_Resource
>
> I've tried the various fixes that have been suggested - removing the
> fontList.py3k.cache and even the removing the .matplotlib directory.
> However when I run my script that's producing the error the directory gets
> recreated along with the fontList.py3k.cache which must be pointing to the
> wrong path?
>
> When I check the path
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf where
> matplotlib is looking for the resource it cannot open - the Vera.ttf is
> there.
>
> This only happens after many iterations through the loop that is saving
> out the *.png files and I have no idea why.
>
> The relevant code from my script is here:
>
> for p in plotData[k]["data"]:
> #print("p in plotData[k]:",p)
> a = numpy.array((loc[0],loc[1]))
> b = numpy.array((p[0],p[1]))
> distValue = (numpy.sqrt(numpy.sum((a-b)**2) ))/86.0 #divide by
> 86 because that was the ppi on the display used to collect the data
> if p[2] == 1:
> hit_x.append(loc[0]-p[0])
>
> hit_y.append(loc[1]-p[1])
>
> frame_hit_x = loc[0]-p[0]
> frame_hit_y = loc[1]-p[1]
> print("frame_x:", frame_hit_x)
> files = []
> if size == (0.25,0.25) and makeMovie:
>
> fig = plt.figure()
> print("fig:", fig)
>
> plt.plot(frame_hit_x,frame_hit_y,color='green',marker='o',linestyle='')
>
> plt.axis('scaled')
> plt.axis([-100,100,-100,100])
>
> fname =
> "subj{:g}_size{:g}_hit_x{:g}.png".format(Subject,btnSize,frame_hit_x)
> print('saving frame', fname)
> fig.savefig(fname, transparent = True)
> files.append(fname)
>
> I'm on a Win7 64bit using python 3.2 and matplotlib version 1.2.x
>
> Any help would be greatly appreciated!
>
> Andy
>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here http://p.sf.net/sfu/sfd2d-msazure
>
>
>
> _______________________________________________
> Matplotlib-users mailing lis...@li...https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Michael D. <md...@st...> - 2012年03月23日 20:45:30
This is a known bug on Windows where it runs out of file handles after a 
while.
This commit was an attempt to fix it, but it doesn't seem to work:
https://github.com/matplotlib/matplotlib/commit/4cb2aaa87b0aa9efe7178d7510d3d091ef5206df
I think we need a Windows user/developer/expert to get to the bottom of 
why file handles are not being freed to the OS.
Mike
On 03/23/2012 04:35 PM, Andrew Smart wrote:
> Hi,
> I'm running into this RuntimeError: Could not open facefile 
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf; 
> Cannot_Open_Resource when I'm trying to save out a series of *.png 
> files in a loop. It crashes on this error after many passes through 
> the loop and successful files get created, but then always on the same 
> pass it does this. The full traceback is here:
>
> File 
> "C:\Users\E440710\Desktop\PythonTransfer\fittslaw_ThroughputCalc_AS_break.py", 
> line 744, in <module>
> fig.savefig(fname, transparent = True)
> File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 
> 1174, in savefig
> self.canvas.print_figure(*args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\backend_bases.py", 
> line 2027, in print_figure
> **kwargs)
> File 
> "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 451, in print_png
> FigureCanvasAgg.draw(self)
> File 
> "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 400, in draw
> self.figure.draw(self.renderer)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, 
> in draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 887, 
> in draw
> func(*args)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, 
> in draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\axes.py", line 1985, 
> in draw
> a.draw(renderer)
> File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, 
> in draw_wrapper
> draw(artist, renderer, *args, **kwargs)
> File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 1043, 
> in draw
> ticklabelBoxes, ticklabelBoxes2 = 
> self._get_tick_bboxes(ticks_to_draw, renderer)
> File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 994, 
> in _get_tick_bboxes
> extent = tick.label1.get_window_extent(renderer)
> File "c:\Python32\lib\site-packages\matplotlib\text.py", line 743, 
> in get_window_extent
> bbox, info = self._get_layout(self._renderer)
> File "c:\Python32\lib\site-packages\matplotlib\text.py", line 296, 
> in _get_layout
> ismath=False)
> File 
> "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 182, in get_text_width_height_descent
> font = self._get_agg_font(prop)
> File 
> "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py", 
> line 223, in _get_agg_font
> font = FT2Font(str(fname))
> RuntimeError: Could not open facefile 
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf; 
> Cannot_Open_Resource
>
> I've tried the various fixes that have been suggested - removing the 
> fontList.py3k.cache and even the removing the .matplotlib directory. 
> However when I run my script that's producing the error the directory 
> gets recreated along with the fontList.py3k.cache which must be 
> pointing to the wrong path?
>
> When I check the path 
> c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf 
> where matplotlib is looking for the resource it cannot open - the 
> Vera.ttf is there.
>
> This only happens after many iterations through the loop that is 
> saving out the *.png files and I have no idea why.
>
> The relevant code from my script is here:
>
> for p in plotData[k]["data"]:
> #print("p in plotData[k]:",p)
> a = numpy.array((loc[0],loc[1]))
> b = numpy.array((p[0],p[1]))
> distValue = (numpy.sqrt(numpy.sum((a-b)**2) ))/86.0 
> #divide by 86 because that was the ppi on the display used to collect 
> the data
> if p[2] == 1:
> hit_x.append(loc[0]-p[0])
>
> hit_y.append(loc[1]-p[1])
>
> frame_hit_x = loc[0]-p[0]
> frame_hit_y = loc[1]-p[1]
> print("frame_x:", frame_hit_x)
> files = []
> if size == (0.25,0.25) and makeMovie:
>
> fig = plt.figure()
> print("fig:", fig)
> 
> plt.plot(frame_hit_x,frame_hit_y,color='green',marker='o',linestyle='')
>
> plt.axis('scaled')
> plt.axis([-100,100,-100,100])
>
> fname = 
> "subj{:g}_size{:g}_hit_x{:g}.png".format(Subject,btnSize,frame_hit_x)
> print('saving frame', fname)
> fig.savefig(fname, transparent = True)
> files.append(fname)
>
> I'm on a Win7 64bit using python 3.2 and matplotlib version 1.2.x
>
> Any help would be greatly appreciated!
>
> Andy
>
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Andrew S. <and...@gm...> - 2012年03月23日 20:35:59
Hi,
I'm running into this RuntimeError: Could not open facefile
c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
Cannot_Open_Resource when I'm trying to save out a series of *.png files in
a loop. It crashes on this error after many passes through the loop and
successful files get created, but then always on the same pass it does
this. The full traceback is here:
 File
"C:\Users\E440710\Desktop\PythonTransfer\fittslaw_ThroughputCalc_AS_break.py",
line 744, in <module>
 fig.savefig(fname, transparent = True)
 File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 1174, in
savefig
 self.canvas.print_figure(*args, **kwargs)
 File "c:\Python32\lib\site-packages\matplotlib\backend_bases.py", line
2027, in print_figure
 **kwargs)
 File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 451, in print_png
 FigureCanvasAgg.draw(self)
 File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 400, in draw
 self.figure.draw(self.renderer)
 File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "c:\Python32\lib\site-packages\matplotlib\figure.py", line 887, in
draw
 func(*args)
 File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "c:\Python32\lib\site-packages\matplotlib\axes.py", line 1985, in
draw
 a.draw(renderer)
 File "c:\Python32\lib\site-packages\matplotlib\artist.py", line 56, in
draw_wrapper
 draw(artist, renderer, *args, **kwargs)
 File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 1043, in
draw
 ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
renderer)
 File "c:\Python32\lib\site-packages\matplotlib\axis.py", line 994, in
_get_tick_bboxes
 extent = tick.label1.get_window_extent(renderer)
 File "c:\Python32\lib\site-packages\matplotlib\text.py", line 743, in
get_window_extent
 bbox, info = self._get_layout(self._renderer)
 File "c:\Python32\lib\site-packages\matplotlib\text.py", line 296, in
_get_layout
 ismath=False)
 File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 182, in get_text_width_height_descent
 font = self._get_agg_font(prop)
 File "c:\Python32\lib\site-packages\matplotlib\backends\backend_agg.py",
line 223, in _get_agg_font
 font = FT2Font(str(fname))
RuntimeError: Could not open facefile
c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf;
Cannot_Open_Resource
I've tried the various fixes that have been suggested - removing the
fontList.py3k.cache and even the removing the .matplotlib directory.
However when I run my script that's producing the error the directory gets
recreated along with the fontList.py3k.cache which must be pointing to the
wrong path?
When I check the path
c:\Python32\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf where
matplotlib is looking for the resource it cannot open - the Vera.ttf is
there.
This only happens after many iterations through the loop that is saving out
the *.png files and I have no idea why.
The relevant code from my script is here:
for p in plotData[k]["data"]:
 #print("p in plotData[k]:",p)
 a = numpy.array((loc[0],loc[1]))
 b = numpy.array((p[0],p[1]))
 distValue = (numpy.sqrt(numpy.sum((a-b)**2) ))/86.0 #divide by
86 because that was the ppi on the display used to collect the data
 if p[2] == 1:
 hit_x.append(loc[0]-p[0])
 hit_y.append(loc[1]-p[1])
 frame_hit_x = loc[0]-p[0]
 frame_hit_y = loc[1]-p[1]
 print("frame_x:", frame_hit_x)
 files = []
 if size == (0.25,0.25) and makeMovie:
 fig = plt.figure()
 print("fig:", fig)
plt.plot(frame_hit_x,frame_hit_y,color='green',marker='o',linestyle='')
 plt.axis('scaled')
 plt.axis([-100,100,-100,100])
 fname =
"subj{:g}_size{:g}_hit_x{:g}.png".format(Subject,btnSize,frame_hit_x)
 print('saving frame', fname)
 fig.savefig(fname, transparent = True)
 files.append(fname)
I'm on a Win7 64bit using python 3.2 and matplotlib version 1.2.x
Any help would be greatly appreciated!
Andy
From: Eric F. <ef...@ha...> - 2012年03月23日 18:46:20
On 03/23/2012 08:05 AM, Albert Kottke wrote:
> I am having problems clearing figures from memory. After saving the
> figure, I use pyplot.close() on the figure handle and then del all of
> the data and figure, as shown here:
>
> fig.savefig('plots/%(record_id)05i' % recording)
> plt.close(fig)
>
> del accel, fourier_amp, fig, time, disp
> gc.collect()
>
> Despite this, the figures don't appear to be closing. I am trying to
> make 30k plots and I have to kill script every couple thousand and
> restart because I run out of memory.
>
> Any suggestions?
You are running a standalone script, correct? Make sure you are using 
only the agg backend. Before the first import of pyplot, do
import matplotlib
matplotlib.use("agg")
I don't know if that will help, but it can't hurt.
You might find matplotlib.cbook.report_memory() to be useful in tracking 
down the problem.
Eric
>
>
> Albert
>
> ------------------------------------------------------------------------------
> This SF email is sponsosred by:
> Try Windows Azure free for 90 days Click Here
> http://p.sf.net/sfu/sfd2d-msazure
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
From: Albert K. <alb...@gm...> - 2012年03月23日 18:05:39
I am having problems clearing figures from memory. After saving the
figure, I use pyplot.close() on the figure handle and then del all of
the data and figure, as shown here:
fig.savefig('plots/%(record_id)05i' % recording)
plt.close(fig)
del accel, fourier_amp, fig, time, disp
gc.collect()
Despite this, the figures don't appear to be closing. I am trying to
make 30k plots and I have to kill script every couple thousand and
restart because I run out of memory.
Any suggestions?
Albert
From: Benjamin R. <ben...@ou...> - 2012年03月23日 15:36:46
The shapes of X, Y, and Z must match. After the mesh grid, Z no longer
matches X and Y.
Ben Root
(I will be out of contact for at least a week, sorry I won't be able to
help any further till then.)
From: David C. <dcd...@gm...> - 2012年03月23日 13:02:04
Hi, I have three variables I would like to plot using plot_surface but I 
keep getting the error given at the bottom. Anyone know what I am doing 
wrong?? My code is as follows,
fig3 = plt.figure()
ax = Axes3D(fig3)
X = np.zeros((78,1))
Y = np.zeros((78,1))
Z = np.zeros((78,1))
for p in range(len(data)):
 X[p,0] = data[p][1] #distance
 Y[p,0] = data[p][3] #azimuth
 Z[p,0] = data[p][4] #snr
X, Y = np.meshgrid(X, Y)
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
ValueError Traceback (most recent call last)
/home/davcra/python_scripts/plot_snr_az.py in <module>()
 48 Z[p,0] = data[p][4] #snr
 49 X, Y = np.meshgrid(X, Y)
---> 50 surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet)
 51 #fig.colorbar(surf, shrink=0.5, aspect=5)
 52 #plt.show()
/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/axes3d.pyc in 
plot_surface(self, X, Y, Z, *args, **kwargs)
 616 normals.append(np.cross(v1, v2))
 617
--> 618 polyc = art3d.Poly3DCollection(polys, *args, **kwargs)
 619 if cmap is not None:
 620 polyc.set_array(np.array(avgz))
/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/art3d.pyc in 
__init__(self, verts, *args, **kwargs)
 282 '''
 283
--> 284 PolyCollection.__init__(self, verts, *args, **kwargs)
 285 self._zsort = 1
 286 self._sort_zpos = None
/usr/lib64/python2.6/site-packages/matplotlib/collections.pyc in 
__init__(self, verts, sizes, closed, **kwargs)
 666 Collection.__init__(self,**kwargs)
 667 self._sizes = sizes
--> 668 self.set_verts(verts, closed)
 669 __init__.__doc__ = cbook.dedent(__init__.__doc__) % 
artist.kwdocd
 670
/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/art3d.pyc in 
set_verts(self, verts, closed)
 304 def set_verts(self, verts, closed=True):
 305 '''Set 3D vertices.'''
--> 306 self.get_vector(verts)
 307 # 2D verts will be updated at draw time
 308 PolyCollection.set_verts(self, [], closed)
/usr/lib64/python2.6/site-packages/mpl_toolkits/mplot3d/art3d.pyc in 
get_vector(self, segments3d)
 297 segis.append((si, ei))
 298 si = ei
--> 299 xs, ys, zs = zip(*points)
 300 ones = np.ones(len(xs))
 301 self._vec = np.array([xs, ys, zs, ones])
ValueError: need more than 0 values to unpack
WARNING: Failure executing file: <plot_snr_az.py>
thanks,
David
From: David V. <dav...@gm...> - 2012年03月22日 13:51:17
Hi All,
I am plotting on two different y-axes: one on the left (ax1) and one on 
the right (ax2). Both share the same x-axes. The problem I am facing 
relates back to the zorder of the legend (at least, that is what I 
think): I want it to be on the foreground at all times. In order to do 
so, I change the zorder of the ax1.legend (left y axes) such that the 
ax2.plots (right y-axes) are under ax1.legend. However, that doesn't 
work: all the plots on the right axes (so using ax2) end up above the 
legend 1 on the left, despite having a lower zorder.
Note that I am also giving the grids on both ax1 and ax2 a lower zorder 
value compared to the legends, but the grid still ends up on top of 
legend 1 on the left.
# version info:
# Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2
# NumPy 1.6.1, Matplotlib 1.1.0
import pylab as plt
import numpy as np
# plotting on the left y-axes,
ax1 = plt.axes(zorder=10)
ax1.plot(range(0,5,1), 'r', label='ax1 ax1 ax1 ax1', zorder=11)
ax1.plot(np.arange(3,4.1,1), 'r--', label='ax1 ax1 ax1 ax1', zorder=12)
gr1 = ax1.grid(zorder=13)
# legend of the left y-axes, force high zorder
leg1 = ax1.legend(loc='upper left')
leg1.set_zorder(30)
# plotting on the right y-axes,
ax2 = plt.twinx()
ax2.set_zorder(20)
ax2.plot(range(4,-1,-1), 'b', label='ax2 ax2 ax2 ax2', zorder=21)
ax2.plot(np.arange(4,2.9,-1), np.arange(3,4.1,1), 'b--',
label='ax2 ax2 ax2 ax2', zorder=22)
gr2 = ax2.grid(zorder=23)
# legend of the right y-axes, force high zorder
leg2 = ax2.legend(loc='upper right')
leg2.set_zorder(40)
print '======= zorder:'
print ' ax1: %i' % ax1.get_zorder()
print ' ax2: %i' % ax2.get_zorder()
print 'leg1: %i' % leg1.get_zorder()
print 'leg2: %i' % leg2.get_zorder()
What am I missing here?
Thanks,
David
9 messages has been excluded from this view by a project administrator.

Showing results of 368

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