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


Showing 7 results of 7

From: Curtis C. <cu...@hi...> - 2005年03月19日 21:10:28
Hi,
I have two questions about the basemap toolkit:
1) I use the orthographic projection often in my research. Can support
for this be easily added to basemap?
2) In the basemap.interp function, which just forwards the arguments on to
numarray.nd_image.map_coordinates, why is it necessary to enforce regular
grid spacing? It seems to me the interpolation will work either way.
Cheers,
Curtis
 * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 * Curtis S. Cooper, Graduate Research Assistant *
 * Lunar and Planetary Laboratory, University of Arizona *
 * http://www.lpl.arizona.edu/~curtis/		 *
 * Kuiper Space Sciences, Rm. 318 *
 * 1629 E. University Blvd., *
 * Tucson, AZ 85721 * * * * * * * * * * * * * * *
 * Wk: (520) 621-1471 *
 * * * * * * * * * * * *
From: Peter G. <pgr...@ge...> - 2005年03月19日 21:06:28
I do it all the time, but instead of writing to a stream directly, I 
write to file, and embed the image in the html. This works for me, 
because (1) I need that html around to let users setup options, and (2) 
the images are available at a later date - something that has been 
plotted once can be viewed multiple times.
You basically save your plot to a file and then include something like:
<img src="/tmp/image.2005年03月19日_10-50-20.38431390.png">
in your html.
Unless you serve thousands of requests, the few ms waisted 
writing/reading to/from a file should be negligible.
Finally, you might want to look into the error log file for apache, and 
see what goes on behind the scenes. I still run 0.65 (modified) and 
remember had to setup proper permissions on a cache file before thigs 
worked.
Another thing, maybe not the case here, but worth remembering that it is 
crucial to have the 'Content-type' line be the first data written. I've 
had issues in the past where importing some libraries would write 
something else to the stream, and often would be get some criptic errror.
Cheers,
 
-- 
Peter Groszkowski Gemini Observatory
Tel: +1 808 9742509 670 N. A'ohoku Place
Fax: +1 808 9359235 Hilo, Hawai'i 96720, USA
Simon Hook wrote:
> Hi,
>
> The code below when run from a file in the cgi-bin directory should 
> generate a plot but it does not work:
>
> #!d:/apps/Python23/python
>
> import sys
> import matplotlib
> matplotlib.use('Agg')
> from pylab import *
>
> plot([1,2,3,4])
>
> #print "Content-type: text/html\n\n"
> #print "<html>Hello world!</html>"
>
> print "Content-type: image/png\n\n"
> print savefig(sys.stdout)
>
> However, it does not work and I am really struggling to get matplotlib 
> to generate a plot dynamically in a cgi-script. If anyone has done 
> this successfully I would really appreciate some help or a simple 
> example. I am using Windows XP and Apache 2.0.53.
>
> Many thanks,
>
> Simon
>
>
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
John,
I have reduced the python script to 4 lines which no longer includes 
matplotlib but it still does not work (see below). I have tried many 
permutations - none work. If you can get this to work, under 
Apache-windows. I would really appreciate knowing how. This capability 
would be useful for displaying images from matplotlib.
#!d:/apps/Python23/python.exe
fp = open('tmp.png','rb')
print "Content-type: image/png\n"
print fp.read()
fp.close()
Tthe script generates is:
The image "http://shook-m2/cgi-bin/plot.py" cannot be displayed, because 
it contains errors.
plot.py is the name of the script, tmp.png is a png in the cgi-bin 
directory.
I am using:
Python 2.3 (Enthought version)
Apache 2.0.53
Windows XP Sp2
The script is in cgi-bin. Other python scripts work fine e.g. hello world.
Cheers, Simon
John Hunter wrote:
>>>>>>"Simon" == Simon Hook <sim...@jp...> writes:
>>>>>> 
>>>>>>
>
> Simon> Hi, The code below when run from a file in the cgi-bin
> Simon> directory should generate a plot but it does not work:
>
>It would help to have more information. What do you mean "does not
>work"? Are there any errors displayed to the terminal or apache
>logs. I know people have used mpl with apache, but it can be a little
>tricky to get all the data paths set up properly. 
>
>matplotlib uses a couple of environment variables to find it's data
>and store cache information. For example, if your fonts and
>.matplotlibrc are in a nonstandard place, you need to set the env var
>MATPLOTLIBDATA to point to them. Also, mpl tries to create a cache
>file .ttffont.cache in your HOME dir by default, and in an apache
>config HOME may not exist or may not be writable. If there is no
>HOME, matplotlib will fall back on the MATPLOTLIBDATA dir, so make
>sure env var is set, that it points to the directory that contains
>Vera.ttf and the other mpl fonts, and that it is writable by the user
>under which apache runs.
>
>If you get this to work, please write a HOWTO and submit it to the list.
>
>
> Simon> #!d:/apps/Python23/python
>
> Simon> import sys import matplotlib matplotlib.use('Agg') from
> Simon> pylab import *
>
> Simon> plot([1,2,3,4])
>
> Simon> #print "Content-type: text/html\n\n" #print "<html>Hello
> Simon> world!</html>"
>
> Simon> print "Content-type: image/png\n\n" 
> Simon> print savefig(sys.stdout)
>
>This looks wrong. Doing
>
>print savefig(sys.stdout)
>
>will also print the return value of savefig, which is None I believe.
>I think you just want
>
>savefig(sys.stdout)
>
>But I can't vouch for the overall approach (setting the content type
>and then dumping in a binary stream of the png). It may be correct,
>but I haven't used it. Somehow I would expect the stream to be mime
>or base64 encoded in an ascii file.
>
> Simon> However, it does not work and I am really struggling to get
> Simon> matplotlib to generate a plot dynamically in a
> Simon> cgi-script. If anyone has done this successfully I would
> Simon> really appreciate some help or a simple example. I am using
> Simon> Windows XP and Apache 2.0.53.
>
>Hope this helps a little -- let us know if you have any more details
>on the problem you are experiencing or if you make any progress.
>
>JDH
> 
>
From: John H. <jdh...@ac...> - 2005年03月19日 12:56:20
>>>>> "Simon" == Simon Hook <sim...@jp...> writes:
 Simon> Hi, The code below when run from a file in the cgi-bin
 Simon> directory should generate a plot but it does not work:
It would help to have more information. What do you mean "does not
work"? Are there any errors displayed to the terminal or apache
logs. I know people have used mpl with apache, but it can be a little
tricky to get all the data paths set up properly. 
matplotlib uses a couple of environment variables to find it's data
and store cache information. For example, if your fonts and
.matplotlibrc are in a nonstandard place, you need to set the env var
MATPLOTLIBDATA to point to them. Also, mpl tries to create a cache
file .ttffont.cache in your HOME dir by default, and in an apache
config HOME may not exist or may not be writable. If there is no
HOME, matplotlib will fall back on the MATPLOTLIBDATA dir, so make
sure env var is set, that it points to the directory that contains
Vera.ttf and the other mpl fonts, and that it is writable by the user
under which apache runs.
If you get this to work, please write a HOWTO and submit it to the list.
 Simon> #!d:/apps/Python23/python
 Simon> import sys import matplotlib matplotlib.use('Agg') from
 Simon> pylab import *
 Simon> plot([1,2,3,4])
 Simon> #print "Content-type: text/html\n\n" #print "<html>Hello
 Simon> world!</html>"
 Simon> print "Content-type: image/png\n\n" 
 Simon> print savefig(sys.stdout)
This looks wrong. Doing
print savefig(sys.stdout)
will also print the return value of savefig, which is None I believe.
I think you just want
savefig(sys.stdout)
But I can't vouch for the overall approach (setting the content type
and then dumping in a binary stream of the png). It may be correct,
but I haven't used it. Somehow I would expect the stream to be mime
or base64 encoded in an ascii file.
 Simon> However, it does not work and I am really struggling to get
 Simon> matplotlib to generate a plot dynamically in a
 Simon> cgi-script. If anyone has done this successfully I would
 Simon> really appreciate some help or a simple example. I am using
 Simon> Windows XP and Apache 2.0.53.
Hope this helps a little -- let us know if you have any more details
on the problem you are experiencing or if you make any progress.
JDH
From: John H. <jdh...@ac...> - 2005年03月19日 02:32:30
>>>>> "Russell" == Russell E Owen <ro...@ce...> writes:
 Russell> I have some kind of error in some test code and get this
 Russell> interesting display:
Sorry, this was an undocumented change. After some discussion on
matplotlib-devel we resolved that it only confused matters to have
matplotlib trying to do custom error handling and logging, because
python has standard ways of dealing with both of these. This should
have made it into the CHANGELOG *and* the release notes, so it was an
oversight in that it made it into neither.
 * errors now raise exceptions, as they should.
 * warnings are handled by the python standard library module
 "warnings".
I think everyone on matplotlib-devel agreed after months of
intermittent discussion that this was the proper solution.
I advise you to grab the latest .matplotlibrc file from the src
distribution and copy it over to your home directory and re-customize
it. The latest version can also always be found at
http://matplotlib.sf.net/.matplotlibrc .
JDH
From: Natsu <nat...@ya...> - 2005年03月19日 02:06:14
John Hunter wrote:
> OK, I can replicate the bug on windows and linux -- thanks for the
> test file. Even though I've found where the bug is occurring -- the
> call to 
> 
> setattr("family_name", Py::String(face->family_name);
> 
> in ft2font.cpp, the fix is not immediately obvious, so we'll continue
> to work on it and I'll keep you posted. In the interim, hopefully you
> can remove the troublesome files from your font path and still use
> matplotlib.
John,
Thank you for your immidiate response.
As I had to modify Yasushi's script to find the troublesome fonts,
for the sake of possible followers, I post the modified script here as
'font_test.py'.
With this script, I did not remove the font from the system,
just added to the list 'exlude' defined in the bottom part of
the script.
The same idea worked for function createFontDict in font_manager.py,
though its a very clumsy work-around for the problem, I know.
Maybe, you can list the dangerous font in somewhere in the .rcfile, 
until the problem in ft2font.cpp is solved.
Anyway, thanks a lot. I'll start to do the plotting.
Natsu
---
def createFontDict(fontfiles, fontext='ttf'):
 """A function to create a dictionary of font file paths. The
default is to create a dictionary for TrueType fonts. An AFM font
dictionary can optionally be created.
"""
 fontdict = {}
 exclude = ['JRLM00M.TTF', ] ## modified
 # Add fonts from list of known font files.
 seen = {}
 for fpath in fontfiles:
 fname = os.path.split(fpath)[-1] ## modified
 if seen.has_key(fname): continue
 else: seen[fname] = 1
 if fontext == 'ttf':
 if fname in exclude: continue ## modified
 try:
 font = ft2font.FT2Font(str(fpath))
 except RuntimeError:
 verbose.report_error("Could not open font file %s"%fpath)
 continue
 prop = ttfFontProperty(font)
--- snip ---
----- font_test.py -----
import os
import glob
import sys
from matplotlib import rcParams
from matplotlib.ft2font import FT2Font
## from matplotlib.font_manager import findSystemFonts
## Original script failed here.
MSFolders = \
 r'Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders'
MSFontDirectories = [
 r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts',
 r'SOFTWARE\Microsoft\Windows\CurrentVersion\Fonts']
def win32FontDirectory():
 """Return the user-specified font directory for Win32."""
 try:
 import _winreg
 except ImportError:
 return os.path.join(os.environ['WINDIR'], 'Fonts')
 else:
 user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders)
 try:
 return _winreg.QueryValueEx(user, 'Fonts')[0]
 finally:
 _winreg.CloseKey(user)
 return None
def findSystemFonts(fontpaths=None, fontext='ttf'):
 """Search for fonts in the specified font paths, or use the system
paths if none given. A list of TrueType fonts are returned by default
with AFM fonts as an option.
"""
 fontfiles = {}
 if fontpaths is None:
 if sys.platform == 'win32':
 fontdir = win32FontDirectory()
 fontpaths = [fontdir]
 # now get all installed fonts directly...
 for f in win32InstalledFonts(fontdir):
 base, ext = os.path.splitext(f)
 if len(ext)>1 and ext[1:].lower()==fontext:
 fontfiles[f] = 1
 else:
 fontpaths = x11FontDirectory()
 elif isinstance(fontpaths, (str, unicode)):
 fontpaths = [fontpaths]
 for path in fontpaths:
 for fname in glob.glob(os.path.join(path, '*.'+fontext)):
 fontfiles[os.path.abspath(fname)] = 1
 return [fname for fname in fontfiles.keys() if os.path.exists(fname)]
def win32InstalledFonts(directory=None, fontext='ttf'):
 """Search for fonts in the specified font directory, or use the
system directories if none given. A list of TrueType fonts are
returned by default with AFM fonts as an option.
"""
 import _winreg
 if directory is None:
 directory = win32FontDirectory()
 key, items = None, {}
 for fontdir in MSFontDirectories:
 try:
 local = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, fontdir)
 except OSError:
 continue
 local = None
 if not local:
 return glob.glob(os.path.join(directory, '*.'+fontext))
 try:
 for j in range(_winreg.QueryInfoKey(local)[1]):
 try:
 key, direc, any = _winreg.EnumValue( local, j)
 if not os.path.dirname(direc):
 direc = os.path.join(directory, direc)
 direc = os.path.abspath(direc).lower()
 if direc[-4:] == '.'+fontext:
 items[direc] = 1
 except EnvironmentError:
 pass
 return items.keys()
 finally:
 _winreg.CloseKey(local)
 return None
paths = [rcParams['datapath']]
if os.environ.has_key('TTFPATH'):
 ttfpath = os.environ['TTFPATH']
 if ttfpath.find(';') >= 0: #win32 style
 paths.extend(ttfpath.split(';'))
 else:
 paths.append(ttfpath)
ttffiles = findSystemFonts(paths) + findSystemFonts()
exclude = ['JRLM00M.TTF', ]
for fpath in ttffiles:
 fname = os.path.split(fpath)[-1]
 if fname in exclude:
 pass
 else:
 print "probing %s" %(str(fpath))
 font = FT2Font(str(fpath))
print "all fine."
From: Russell E. O. <ro...@ce...> - 2005年03月19日 00:31:50
I have some kind of error in some test code and get this interesting 
display:
/usr/local/lib/python2.4/site-packages/matplotlib/__init__.py:641: 
UserWarning: Bad val "error" on line #199
 "verbose.level : error # one of silent, error, helpful, 
debug, debug-annoying"
 in file "/Users/rowen/.matplotlibrc"
 Illegal verbose string "error". Legal values are ('silent', 
'helpful', 'debug', 'debug-annoying')
 warnings.warn('Bad val "%s" on line #%d\n\t"%s"\n\tin file "%s"\n\t%s' 
% (val, cnt, line, fname, msg))
My .matplotlibrc worked fine with matplotlib 0.72.1 and 0.71 and "error" 
was certainly an accepted value.
-- Russell

Showing 7 results of 7

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