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

Showing 12 results of 12

From: Erik W. <er...@er...> - 2007年06月05日 21:36:30
Attachments: chart.png
Hi,
I'm trying to plot a barchart for use in a django site. It's creating
a blank chart image though.(attached).
What am I doing wrong?
from pylab import *
def chart(request):
 from PIL import Image as PILImage
 from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
 from matplotlib.figure import Figure
 from StringIO import StringIO
 fig = Figure(figsize=(6,4))
 canvas = FigureCanvas(fig)
 ax = fig.add_subplot(111)
 #from pylab import *
 N = 7
 menMeans = (20, 35, 30, 35, 27, 21, 60)
 ind = arange(N) # the x locations for the groups
 #print ind
 width = 0.35 # the width of the bars
 ax = bar(ind, menMeans, width, color='b')
 #ylabel('Time')
 title('Time In Minutes - Last 7 Days')
 xticks(ind+width, ('Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', '*') )
 fig.set_facecolor('w')
 canvas.draw()
 size = canvas.get_renderer().get_canvas_width_height()
 buf=canvas.tostring_rgb()
 im=PILImage.fromstring('RGB', size, buf, 'raw', 'RGB', 0, 1)
 imdata=StringIO()
 im.save(imdata, format='PNG')
 response = HttpResponse(imdata.getvalue(), mimetype='image/png')
 return response
Thanks!
Erik
From: Werner F. B. <wer...@fr...> - 2007年06月05日 17:30:16
Hi Andrew,
Andrew Straw wrote:
> Dear Werner,
>
> This seems to be an unintended side-effect of reorganizing the mpl 
> data file location that I did prior to this release. (I.e. it's not 
> your code that broke, I think it's mpl.) Unfortunately, since I didn't 
> (and still don't) use py2exe, it will be hard for me to fix this. Can 
> you send a patch that gets py2exe working again?
The work around I did is using glob.glob instead as follows:
# matplotlib data
##mpdir, mpfiles = matplotlib.get_py2exe_datafiles()
mpfiles = glob.glob('C:\Python25\lib\site-packages\matplotlib\mpl-data\*.*')
But I can't confirm yet that this works as I am also trying out 
something else in my InnoSetup script. Will confirm ASAP and will try 
and look into matplotlib.get_py2exe_datafiles() and see how it could be 
fixed.
Best regards
Werner
From: Mark B. <ma...@gm...> - 2007年06月05日 17:16:42
I just saw in the code:
if event.key is None: # simulate backspace
So it works properly,
Mark
On 6/5/07, Mark Bakker <ma...@gm...> wrote:
>
> I notice the alignment problem.
> But it looks like you are close.
> On my machine (win32), the 'enter' key didn't work either. It works like a
> backspace. That sounds like what Matthias reported.
> Mark
>
> On 6/5/07, John Hunter <jd...@gm...> wrote:
> >
> > On 6/5/07, John Hunter <jd...@gm...> wrote:
> >
> > > I worked on this some time ago, I never got to the point where I
> > > thought it was ready for production but it is close. There is a
> > > problem if usetex is enabled, because partial tex strings will cause
> > > errors. But you can use it with regular text or plain text.
> >
> > Typo: "plain text" was meant to be "math text"
> >
> > Now I remember what really bothered me about this widget, and it
> > wasn't just the usetex problem. The problem is that mpl has three
> > different vertical alignment methods for text: top, bottom and center.
> > None of them are right for a text box: you want baseline. Try typing
> > "thinking" into the text box and watch what happens when you add and
> > remove the "g". We do need to support baseline alignment for text, so
> > if someone has an interest in adding this it would be a very useful
> > feature, not just for a text box for for text alignment (eg tick
> > labels) in general.
> >
> > See the image of the "g" at
> > http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-3.html
> > for a visual representation -- hwat I am calling the "baseline" they
> > refer to as the "origin" in that graph. Our default alignment should
> > be "origin" or "baseline" but we don't have support for that.
> >
> > JDH
> >
>
>
From: Mark B. <ma...@gm...> - 2007年06月05日 17:15:29
I notice the alignment problem.
But it looks like you are close.
On my machine (win32), the 'enter' key didn't work either. It works like a
backspace. That sounds like what Matthias reported.
Mark
On 6/5/07, John Hunter <jd...@gm...> wrote:
>
> On 6/5/07, John Hunter <jd...@gm...> wrote:
>
> > I worked on this some time ago, I never got to the point where I
> > thought it was ready for production but it is close. There is a
> > problem if usetex is enabled, because partial tex strings will cause
> > errors. But you can use it with regular text or plain text.
>
> Typo: "plain text" was meant to be "math text"
>
> Now I remember what really bothered me about this widget, and it
> wasn't just the usetex problem. The problem is that mpl has three
> different vertical alignment methods for text: top, bottom and center.
> None of them are right for a text box: you want baseline. Try typing
> "thinking" into the text box and watch what happens when you add and
> remove the "g". We do need to support baseline alignment for text, so
> if someone has an interest in adding this it would be a very useful
> feature, not just for a text box for for text alignment (eg tick
> labels) in general.
>
> See the image of the "g" at
> http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-3.html
> for a visual representation -- hwat I am calling the "baseline" they
> refer to as the "origin" in that graph. Our default alignment should
> be "origin" or "baseline" but we don't have support for that.
>
> JDH
>
From: John H. <jd...@gm...> - 2007年06月05日 16:43:50
On 6/5/07, John Hunter <jd...@gm...> wrote:
> I worked on this some time ago, I never got to the point where I
> thought it was ready for production but it is close. There is a
> problem if usetex is enabled, because partial tex strings will cause
> errors. But you can use it with regular text or plain text.
Typo: "plain text" was meant to be "math text"
Now I remember what really bothered me about this widget, and it
wasn't just the usetex problem. The problem is that mpl has three
different vertical alignment methods for text: top, bottom and center.
 None of them are right for a text box: you want baseline. Try typing
"thinking" into the text box and watch what happens when you add and
remove the "g". We do need to support baseline alignment for text, so
if someone has an interest in adding this it would be a very useful
feature, not just for a text box for for text alignment (eg tick
labels) in general.
See the image of the "g" at
http://freetype.sourceforge.net/freetype2/docs/glyphs/glyphs-3.html
for a visual representation -- hwat I am calling the "baseline" they
refer to as the "origin" in that graph. Our default alignment should
be "origin" or "baseline" but we don't have support for that.
JDH
From: Andrew S. <str...@as...> - 2007年06月05日 16:27:48
Dear Werner,
This seems to be an unintended side-effect of reorganizing the mpl data 
file location that I did prior to this release. (I.e. it's not your code 
that broke, I think it's mpl.) Unfortunately, since I didn't (and still 
don't) use py2exe, it will be hard for me to fix this. Can you send a 
patch that gets py2exe working again?
Thanks,
Andrew
Werner F. Bruhin wrote:
> Werner F. Bruhin wrote:
> 
>> John Hunter wrote:
>> 
>> 
>>> matplotlib 0.90.1 is out and available for download from the sourceforge site.
>>> 
>>> 
>>> 
>> When trying to package my application with py2exe I get the following error:
>>
>> Traceback (most recent call last):
>> File "setup.py", line 141, in <module>
>> mpdir, mpfiles = matplotlib.get_py2exe_datafiles()
>> File "C:\Python25\Lib\site-packages\matplotlib\__init__.py", line 369, 
>> in get_py2exe_datafiles
>> mplfiles.remove(os.sep.join([get_data_path(), 'Matplotlib.nib']))
>> ValueError: list.remove(x): x not in list
>> 
>> 
> To work around this I just put a try/except in:
> try:
> # Need to explicitly remove cocoa_agg files or py2exe complains
> mplfiles.remove(os.sep.join([get_data_path(), 'Matplotlib.nib']))
> except:
> pass
>
> But I then get this error:
> error: can't copy 
> 'C:\Python25\lib\site-packages\matplotlib\mpl-data\fonts': doesn't exist 
> or not a regular file
>
> I guess I will have to review how I am using the get_py2exe_datafiles stuff.
>
> Werner
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: John H. <jd...@gm...> - 2007年06月05日 16:13:08
Attachments: textbox2.py
On 6/5/07, Mark Bakker <ma...@gm...> wrote:
>
> I think a prompt could be very useful in MPL, just to build small little
> GUI's that only need 1 or 2 boxes.
> I also realize it is not easy, and for bigger jobs you want a full GUI
> environment like wx or Tk anyway, so I understand it when developers set
> other priorities.
> Then again, I would really use it,
> Mark
>
> > From: Matthias Michler < Mat...@gm...>
> >
> > Hello everybody,
> >
> > Now my question is: Could a prompt be a useful part of matplotlib?
I worked on this some time ago, I never got to the point where I
thought it was ready for production but it is close. There is a
problem if usetex is enabled, because partial tex strings will cause
errors. But you can use it with regular text or plain text.
Give it a whirl -- I don't mind including tit in matplotlib.widgets
if people think it would be usefult. I do think there is a niche for
these kinds of things where people want brain dead simple widgets w/o
having to deal with GUI toolkits.
I'm pasting the example below, and also attaching it in case the lines
get wrapped
# usetex not supported
import matplotlib
matplotlib.rcParams['text.usetex'] = False
import matplotlib.transforms as transforms
import matplotlib.widgets as widgets		
from pylab import figure, show, nx
class TextBox(widgets.Widget):
 def __init__(self, ax, s=''):
 self.canvas = ax.figure.canvas
 self.text = ax.text(0.025, 0.2, s,
 fontsize=14,
 #verticalalignment='baseline',
 horizontalalignment='left',
 transform=ax.transAxes)
 self.ax = ax
 ax.set_yticks([])
 ax.set_xticks([])
 ax.set_navigate(False)
 self.canvas.draw()
 self.canvas.mpl_connect('key_press_event', self.keypress)
 self.region = self.canvas.copy_from_bbox(ax.bbox)
 r = self._get_text_right()
 self.cursor, = ax.plot([r,r], [0.2, 0.8], transform=ax.transAxes)
 self.redraw()
 def redraw(self):
 self.ax.redraw_in_frame()
 self.canvas.blit(self.ax.bbox)
 def keypress(self, event):
 if event.key is not None and len(event.key)>1: return
 t = self.text.get_text()
 if event.key is None: # simulate backspace
 if len(t): newt = t[:-1]
 else: newt = ''
 else:
 newt = t + event.key
 self.text.set_text(newt)
 r = self._get_text_right()
 self.cursor.set_xdata([r,r])
 self.redraw()
 def _get_text_right(self):
 l,b,w,h = self.text.get_window_extent().get_bounds()
 r = l+w+2
 t = b+h
 s = self.text.get_text()
 # adjust cursor position for trailing space
 numtrail = len(s) - len(s.rstrip())
 en = self.ax.get_renderer_cache().points_to_pixels(self.text.get_fontsize())/2.
 r += numtrail*en
 l,b = self.ax.transAxes.inverse_xy_tup((l,b))
 r,t = self.ax.transAxes.inverse_xy_tup((r,t))
 return r
fig = figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.7])
ax.plot([1,2,3])
#rc('text', usetex=1)
fig.text(0.39, 0.875, 'My label: ',
 horizontalalignment='right', verticalalignment='center')
axtext = fig.add_axes([0.4, 0.85, 0.5, 0.05])
box = TextBox(axtext)
show()
From: Mark B. <ma...@gm...> - 2007年06月05日 14:52:24
I think a prompt could be very useful in MPL, just to build small little
GUI's that only need 1 or 2 boxes.
I also realize it is not easy, and for bigger jobs you want a full GUI
environment like wx or Tk anyway, so I understand it when developers set
other priorities.
Then again, I would really use it,
Mark
From: Matthias Michler <Mat...@gm...>
>
> Hello everybody,
>
> Now my question is: Could a prompt be a useful part of matplotlib?
>
From: Werner F. B. <wer...@fr...> - 2007年06月05日 14:19:39
Werner F. Bruhin wrote:
> John Hunter wrote:
> 
>> matplotlib 0.90.1 is out and available for download from the sourceforge site.
>> 
>> 
> When trying to package my application with py2exe I get the following error:
>
> Traceback (most recent call last):
> File "setup.py", line 141, in <module>
> mpdir, mpfiles = matplotlib.get_py2exe_datafiles()
> File "C:\Python25\Lib\site-packages\matplotlib\__init__.py", line 369, 
> in get_py2exe_datafiles
> mplfiles.remove(os.sep.join([get_data_path(), 'Matplotlib.nib']))
> ValueError: list.remove(x): x not in list
> 
To work around this I just put a try/except in:
 try:
 # Need to explicitly remove cocoa_agg files or py2exe complains
 mplfiles.remove(os.sep.join([get_data_path(), 'Matplotlib.nib']))
 except:
 pass
But I then get this error:
error: can't copy 
'C:\Python25\lib\site-packages\matplotlib\mpl-data\fonts': doesn't exist 
or not a regular file
I guess I will have to review how I am using the get_py2exe_datafiles stuff.
Werner
From: Werner F. B. <wer...@fr...> - 2007年06月05日 14:14:10
John Hunter wrote:
> matplotlib 0.90.1 is out and available for download from the sourceforge site.
> 
When trying to package my application with py2exe I get the following error:
Traceback (most recent call last):
 File "setup.py", line 141, in <module>
 mpdir, mpfiles = matplotlib.get_py2exe_datafiles()
 File "C:\Python25\Lib\site-packages\matplotlib\__init__.py", line 369, 
in get_py2exe_datafiles
 mplfiles.remove(os.sep.join([get_data_path(), 'Matplotlib.nib']))
ValueError: list.remove(x): x not in list
Werner
From: Werner F. B. <wer...@fr...> - 2007年06月05日 08:10:23
Attachments: ttffont.cache
John,
John Hunter wrote:
> On 6/4/07, Werner F. Bruhin <wer...@fr...> wrote:
>> John Hunter wrote:
>> > matplotlib 0.90.1 is out and available for download from the 
>> sourceforge site.
>> >
>> Just installed it. Works very nicely with the exception of some font
>> issue.
>>
>> I am getting this:
>> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
>> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
>> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
>> C:\Python25\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf
>
> make sure you are picking up the most recent matplotlibrc. We changed
> the font ordering some time ago. Then run with --verbose-helpful and
> post the output, maybe --verbose-debug, and we will see if we can
> figure out what is going on. I haven't run under windows for some
> time.
>
Works the first time after I removed the cache file. Looking at the 
file it might have something to do with Unicode, i.e. one of the two "/" 
is encoded as 'u0005C', see attached file.
Werner
From: Werner F. B. <wer...@fr...> - 2007年06月05日 08:01:09
Attachments: stdoutlog.txt
John,
John Hunter wrote:
> On 6/4/07, Werner F. Bruhin <wer...@fr...> wrote:
>> John Hunter wrote:
>> > matplotlib 0.90.1 is out and available for download from the 
>> sourceforge site.
>> >
>> Just installed it. Works very nicely with the exception of some font
>> issue.
>>
>> I am getting this:
>> Could not match Bitstream Vera Serif, New Century Schoolbook, Century
>> Schoolbook L, Utopia, ITC Bookman, Bookman, Nimbus Roman No9 L, Times
>> New Roman, Times, Palatino, Charter, serif, normal, normal. Returning
>> C:\Python25\lib\site-packages\matplotlib\mpl-data\fonts\ttf\Vera.ttf
>
> make sure you are picking up the most recent matplotlibrc.
I don't have a custom rc file, i.e. this is with the 0.90.1 installed 
matplotlibrc.
> We changed
> the font ordering some time ago. Then run with --verbose-helpful and
> post the output, maybe --verbose-debug, and we will see if we can
> figure out what is going on. I haven't run under windows for some
> time.
I attached the verbose-debug output.
Maybe to do with the fontcache? Will try this in a moment and let you 
know if it corrected the issue.
Werner
>
>

Showing 12 results of 12

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