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 9 results of 9

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
>

Showing 9 results of 9

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