Re: [Matplotlib-users] Legends for multi-histograms

2008-12-11 Thread Manuel Metz
Zane Selvans wrote:
> It seems like there ought to be an easy way to associate labels with the 
> various groups of patches generated by a call to hist() that uses a list 
> of arrays, setting label=["a", "list", "of", "strings"] for instance, 
> instead of having to go in and label one patch from each returned list 
> of patches afterward.  Would make legend creation easier anyway.

Good point! Has to be added. Thanks.

mm

> Just a suggestion,
> Zane
> 
> -- 
> Zane Selvans
> Amateur Earthling
> [EMAIL PROTECTED]
> 303/815-6866
> http://zaneselvans.org
> PGP Key: 55E0815F
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] use of del() to delete a line

2008-12-11 Thread TP
Hi everybody,

I have a question about the behavior of "del()" Python built-in.
In the following example, when I use del() on the copy of a line, it does
not delete it, whereas with the original line, it works. Why? I do not
understand, because the id is the same for the copy and the original:

###
from pylab import *
import Tkinter as Tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
ion()
root = Tk.Tk()
f = Figure( figsize = (8,7) )
veryplot = FigureCanvasTkAgg( f
  , master = root )
veryplot.get_tk_widget().pack( side = Tk.LEFT
  , expand = Tk.YES
  , fill = Tk.BOTH )
b = f.add_subplot( 211 )
t = arange(0.01, 5.0, 0.01)
s1 = sin(2*pi*t)
b.plot( t, s1 )
b.plot( t, s1+1 )
print b.lines
raw_input('press a key to delete a line with a copy')
line_copy = b.lines[-1]
print "original id=", id( b.lines[-1] ), "copy id", id( line_copy )
del( line_copy ) # or b.lines.pop()
b.figure.canvas.draw()
print b.lines
raw_input('press a key to delete a line directly')
print "original id=", id( b.lines[-1] )
del( b.lines[-1] ) # or b.lines.pop()
b.figure.canvas.draw()
print b.lines
raw_input('press a key to quit')
###

Thanks in advance,

Julien


-- 
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1+,\'Z
(55l4('])"

"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)


--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] use of del() to delete a line

2008-12-11 Thread TP
TP wrote:

> I have a question about the behavior of "del()" Python built-in.

Ok, del only removes a name from the local namespace.
I have found an old answer of John, below. It seems that a better solution
is to use the remove method of a line instance:

http://osdir.com/ml/python.matplotlib.general/2005-05/msg00045.html

Until now, I used "del" which works well when the complete object hierarchy
is given...

Thanks

Julien

-- 
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1+,\'Z
(55l4('])"

"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)


--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] when the same Line2D is plot on two subplots, it disappears on the two subplots

2008-12-11 Thread TP
Hi,

I use matplotlib 0.91.2.
When I plot the same Line2D on two subplots, it disappears: execute the
following script:

###
from pylab import *
ion()
f = figure()
s = f.add_subplot("211")
curve = matplotlib.lines.Line2D([0,1],[0,1],color='m')
s.add_line( curve )
s2 = f.add_subplot("212")
draw()
raw_input('press a key to delete a line to second subplot')
s2.add_line( curve )
s2.lines[-1].figure.canvas.draw()
print s2.lines[-1].get_visible()
raw_input('press a key to quit')
###

What is the reason for this behavior?

Thanks

Julien

PS: thanks to Friedrich Hagedorn for his correction of my signature.

-- 
python -c "print ''.join([chr(154 - ord(c)) for c in '*9(9&(18%.9&1\
+,\'Z4(55l4('])"

"When a distinguished but elderly scientist states that something is
possible, he is almost certainly right. When he states that something is
impossible, he is very probably wrong." (first law of AC Clarke)


--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] use of del() to delete a line

2008-12-11 Thread John Hunter
On Thu, Dec 11, 2008 at 7:56 AM, TP <[EMAIL PROTECTED]> wrote:
> TP wrote:
>
>> I have a question about the behavior of "del()" Python built-in.
>
> Ok, del only removes a name from the local namespace.
> I have found an old answer of John, below. It seems that a better solution
> is to use the remove method of a line instance:
>
> http://osdir.com/ml/python.matplotlib.general/2005-05/msg00045.html
>
> Until now, I used "del" which works well when the complete object hierarchy
> is given...

The line is stored in axes.lines list, so simply deleting it will not
work because there is a reference to it in the list.  You need to
remove it from the list, as you inidicate.  See also

http://matplotlib.sourceforge.net/users/artists.html

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] when the same Line2D is plot on two subplots, it disappears on the two subplots

2008-12-11 Thread John Hunter
On Thu, Dec 11, 2008 at 10:19 AM, TP <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I use matplotlib 0.91.2.
> When I plot the same Line2D on two subplots, it disappears: execute the
> following script:
>
> ###
> from pylab import *
> ion()
> f = figure()
> s = f.add_subplot("211")
> curve = matplotlib.lines.Line2D([0,1],[0,1],color='m')
> s.add_line( curve )
> s2 = f.add_subplot("212")
> draw()
> raw_input('press a key to delete a line to second subplot')
> s2.add_line( curve )
> s2.lines[-1].figure.canvas.draw()
> print s2.lines[-1].get_visible()
> raw_input('press a key to quit')
> ###
>
> What is the reason for this behavior?

The lines get their transforms from the axes they reside in -- you
can't share a line on multiple axes

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Font problem

2008-12-11 Thread Jörgen Stenarson

Michael Droettboom skrev:

put the pfm/pfb files it somewhere else and have matplotlib use it?
I believe Nimbus Roman is just a clone of Times that is included with 
Ghostscript.


http://www.tug.dk/FontCatalogue/nimbus/

If you have Times or Times New Roman installed, that's probably a 
reasonable substitute.




I tried to use usetex to generate my pdf figures but I got a crash when 
saving the figure, log attached. I traced the crash to find_tex_file(), 
apparently ' can not be used to quote filenames in the windows shell it 
has to be ". In my patch I just changed it to always use " I don't know 
if that works on other systems.


/Jörgen
matplotlib data path 
C:\Python25\lib\site-packages\matplotlib-0.98.4-py2.5-win32.egg\matplotlib\mpl-data
loaded rc file C:\python\bugreports\matplotlib\matplotlibrc
matplotlib version 0.98.4
verbose.level debug
interactive is False
units is False
platform is win32
loaded modules: ['xml.sax.urlparse', 'distutils', 'matplotlib.errno', 
'matplotlib.matplotlib', 'subprocess', 'gc', 'matplotlib.tempfile', 
'distutils.sysconfig', 'ctypes._endian', 'encodings.encodings', 
'matplotlib.colors', 'msvcrt', 'numpy.testing.sys', 'numpy.core.info', 'xml', 
'numpy.fft.types', 'numpy.ma.operator', 'numpy.ma.cPickle', 'struct', 
'numpy.random.info', 'tempfile', 'xml.sax.urllib', 'numpy.linalg', 
'matplotlib.threading', 'numpy.testing.operator', 'imp', 'numpy.testing', 
'collections', 'numpy.core.umath', 'numpy.lib.pkgutil', 'distutils.types', 
'numpy.lib.numpy', 'numpy.core.scalarmath', 'zipimport', 'string', 
'matplotlib.subprocess', 'numpy.testing.os', 'matplotlib.locale', 
'numpy.lib.arraysetops', 'numpy.testing.unittest', 'numpy.lib.math', 
'matplotlib.__future__', 'numpy.testing.re', 'itertools', 'numpy.version', 
'numpy.lib.re', 'distutils.re', 'ctypes.os', 'numpy.core.os', 
'numpy.lib.type_check', 'signal', 'numpy.lib.types', 'numpy.lib._datasource', 
'random', 'threading', 'numpy.fft.fftpack_lite', 'matplotlib.cbook', 
'ctypes.ctypes', 'xml.sax.xmlreader', 'numpy.__builtin__', 'distutils.version', 
'cStringIO', 'numpy.ma.core', 'numpy.numpy', 'matplotlib.StringIO', 'locale', 
'numpy.add_newdocs', 'numpy.lib.getlimits', 'xml.sax.saxutils', 
'numpy.testing.types', 'numpy.lib.sys', 'encodings', 'numpy.ma.itertools', 
'numpy.lib.io', 'numpy.imp', 'numpy.ma.extras', 'numpy.testing.decorators', 
'matplotlib.warnings', 'matplotlib.string', '_subprocess', 'urllib', 
'matplotlib.sys', 're', 'numpy.lib._compiled_base', 'ntpath', 
'numpy.random.mtrand', 'math', 'numpy.fft.helper', 'numpy.ma.warnings', 
'matplotlib.numpy', 'UserDict', 'numpy.lib.function_base', 'distutils.os', 
'matplotlib', 'numpy.fft.numpy', 'numpy.lib.ufunclike', 'numpy.lib.info', 
'numpy.core.numerictypes', 'ctypes', 'numpy.lib.warnings', 'ctypes.struct', 
'codecs', 'numpy.core._sort', 'numpy.os', '_locale', 
'matplotlib.sre_constants', 'matplotlib.os', 'thread', 'StringIO', 
'numpy.core.memmap', 'traceback', '_struct', 'numpy.testing.warnings', 
'weakref', 'numpy.core._internal', 'numpy.fft.fftpack', 'numpy.testing.imp', 
'numpy.linalg.lapack_lite', 'distutils.sys', 'os', 'numpy.lib.itertools', 
'__future__', 'matplotlib.copy', 'xml.sax.types', 'matplotlib.traceback', 
'_sre', 'unittest', 'numpy.core.sys', 'numpy.random', 'numpy.linalg.numpy', 
'__builtin__', 'numpy.lib.twodim_base', 'matplotlib.re', 'numpy.core.cPickle', 
'operator', 'numpy.testing.parametric', 'numpy.core.arrayprint', 
'distutils.string', 'numpy.lib.arrayterator', 'ctypes._ctypes', 'ctypes.sys', 
'matplotlib.datetime', 'numpy.testing.nosetester', 'pkgutil', 
'numpy.lib.financial', 'numpy.core.multiarray', 'errno', '_socket', 'binascii', 
'sre_constants', 'datetime', 'numpy.ma', 'xml.sax.handler', 'types', 
'numpy.lib.stride_tricks', 'numpy.core.numpy', 'numpy', 'matplotlib.types', 
'numpy.core.defmatrix', 'xml.sax.os', 'cPickle', 'matplotlib.xml', '_codecs', 
'numpy.lib.operator', 'encodings.cp1252', 'matplotlib.pyparsing', 'nturl2path', 
'numpy.ma.numpy', 'copy', 'numpy.core.re', 'socket', '_types', 
'numpy.core.fromnumeric', 'numpy.ctypeslib', 'numpy.lib.scimath', 'numpy.fft', 
'numpy.lib', 'numpy.random.numpy', 'encodings.aliases', 'matplotlib.distutils', 
'exceptions', 'sre_parse', 'numpy.core.cStringIO', 'numpy.core.ctypes', 
'distutils.distutils', 'copy_reg', 'sre_compile', 'xml.sax', '_random', 
'numpy.lib.__future__', 'site', 'numpy.lib.polynomial', 'numpy._import_tools', 
'numpy.core.copy_reg', '__main__', 'numpy.fft.info', 'numpy.core.records', 
'shutil', 'numpy.lib.cPickle', 'numpy.sys', 'matplotlib.weakref', 
'numpy.core._dotblas', 'numpy.testing.traceback', 'strop', 
'numpy.testing.numpytest', 'numpy.core.numeric', 'numpy.linalg.info', 
'encodings.codecs', 'numpy.core.__svn_version__', 'numpy.ctypes', 'numpy.core', 
'matplotlib.rcsetup', 'matplotlib.time', 'nt', 'xml.sax._exceptions', 
'xml.sax.codecs', 'stat', '_ssl', 'numpy.lib.utils', 'numpy.lib.index_tricks', 
'warnings', 'encodings.types', 'numpy.core.defchararray', '_ctypes', 
'

Re: [Matplotlib-users] Font problem

2008-12-11 Thread Michael Droettboom
Jörgen Stenarson wrote:
> Michael Droettboom skrev:
>>> put the pfm/pfb files it somewhere else and have matplotlib use it?
>> I believe Nimbus Roman is just a clone of Times that is included with 
>> Ghostscript.
>>
>> http://www.tug.dk/FontCatalogue/nimbus/
>>
>> If you have Times or Times New Roman installed, that's probably a 
>> reasonable substitute.
>>
>
> I tried to use usetex to generate my pdf figures but I got a crash 
> when saving the figure, log attached. I traced the crash to 
> find_tex_file(), apparently ' can not be used to quote filenames in 
> the windows shell it has to be ". In my patch I just changed it to 
> always use " I don't know if that works on other systems.
Someone who knows about usetex should review and apply this patch.

But just for clarification -- the font lookup issues we were talking 
about yesterday only apply when usetex is False.  When usetex is True, 
all the font lookup happens with LaTeX, so you can't directly specify a 
font by name.  Any particular reason why you're using usetex over the 
default?

Cheers,
Mike

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] The Blue Marble is upside down!

2008-12-11 Thread Mauro Cavalcanti
Dear Jeff & ALL,

Attached is the latest version of my Basemap embedded in wxPython
sample application. I have added a check menu option that allows one
to toggle the overlay of the Blue Marble image on and off the Basemap
figure. Everything works well -- except that the Blue Marble image is
plotted upside down! I could not figure out the cause of this, say,
rather bizarre behaviour. Any hints?

Thanks in advance for any assistance you can provide.

Best regards,

PS This version has another known bug, to be eventually fixed -- if
the user has plotted a point coordinate file, the points are erased if
the Blue Marble overlay is requested because the PlotMap() routine
calls ax.cla() at the start.

-- 
Dr. Mauro J. Cavalcanti
Ecoinformatics Studio
P.O. Box 46521, CEP 20551-970
Rio de Janeiro, RJ, BRASIL
E-mail: [email protected]
Web: http://studio.infobio.net
Linux Registered User #473524 * Ubuntu User #22717
"Life is complex. It consists of real and imaginary parts."
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# generated by wxGlade 0.6.3 on Thu Nov 20 17:06:15 2008

# This sample program shows how to read
# geographic coordinates stored in comma-delimited files
# and plot them in a Matplotlib Basemap class object.
# Data files should be formatted as below:

# cities,latitude,longitude
# "Boulder, CO",40.02,-105.16
# "San Diego, CA",32.73,-117.16
# "Washington, DC",38.55,-77.00
# "Whitefish, MT",48.25,-114.21
# "Belize City, Belize",17.29,-88.10

import os
import csv
import wx

from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
from mpl_toolkits.basemap import Basemap

fields = {'cities':0,
		'latitude':1,
		'longitude':2}

# begin wxGlade: extracode
# end wxGlade

class TMainForm(wx.Frame):
	def __init__(self, *args, **kwds):
		# begin wxGlade: TMainForm.__init__
		kwds["style"] = wx.ICONIZE|wx.CAPTION|wx.MINIMIZE|wx.CLOSE_BOX
		wx.Frame.__init__(self, *args, **kwds)
		self.Splitter = wx.SplitterWindow(self, -1, style=wx.SP_3D|wx.SP_BORDER)
		self.PlotPanel = wx.Panel(self.Splitter, -1)
		self.FilePanel = wx.Panel(self.Splitter, -1)
		self.Notebook = wx.Notebook(self.FilePanel, -1, style=0)
		self.ReportPage = wx.Panel(self.Notebook, -1)
		self.FilePage = wx.Panel(self.Notebook, -1)
		
		# Menu Bar
		self.MainMenu = wx.MenuBar()
		self.FileMenu = wx.Menu()
		self.FileOpenItem = wx.MenuItem(self.FileMenu, 102, "&Open...\tCtrl+O", "Open an existing file", wx.ITEM_NORMAL)
		self.FileMenu.AppendItem(self.FileOpenItem)
		self.FileMenu.AppendSeparator()
		self.FileQuitItem = wx.MenuItem(self.FileMenu, wx.ID_EXIT, "&Quit\tCtrl+Q", "Quit the program", wx.ITEM_NORMAL)
		self.FileMenu.AppendItem(self.FileQuitItem)
		self.MainMenu.Append(self.FileMenu, "&File")
		self.OptionsMenu = wx.Menu()
		self.OptionsBlueMarbleItem = wx.MenuItem(self.OptionsMenu, 201, "&Blue Marble", "Overlay Blue Marble image", wx.ITEM_CHECK)
		self.OptionsMenu.AppendItem(self.OptionsBlueMarbleItem)
		self.MainMenu.Append(self.OptionsMenu, "&Options")
		self.HelpMenu = wx.Menu()
		self.HelpAboutItem = wx.MenuItem(self.HelpMenu, 301, "&About...", "Display general information about the program", wx.ITEM_NORMAL)
		self.HelpMenu.AppendItem(self.HelpAboutItem)
		self.MainMenu.Append(self.HelpMenu, "&Help")
		self.SetMenuBar(self.MainMenu)
		# Menu Bar end
		self.StatusBar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)
		self.FileList = wx.ListBox(self.FilePage, -1, choices=[])
		self.ReportText = wx.TextCtrl(self.ReportPage, -1, "", style=wx.TE_MULTILINE|wx.TE_READONLY)

		self.__set_properties()
		self.__do_layout()

		self.Bind(wx.EVT_MENU, self.OnFileOpen, self.FileOpenItem)
		self.Bind(wx.EVT_MENU, self.OnFileQuit, self.FileQuitItem)
		self.Bind(wx.EVT_MENU, self.OnOptionsOverlay, self.OptionsBlueMarbleItem)
		self.Bind(wx.EVT_MENU, self.OnHelpAbout, self.HelpAboutItem)
		self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.FileList)
		# end wxGlade
		self.Bind(wx.EVT_CHECKLISTBOX, self.EvtCheckListBox, self.FileList)
		self.Bind(wx.EVT_SIZE, self.OnSize)

	def __set_properties(self):
		# begin wxGlade: TMainForm.__set_properties
		self.SetTitle("Gaia")
		self.SetSize((800, 600))
		self.SetFocus()
		self.StatusBar.SetStatusWidths([-1, -1])
		# statusbar fields
		StatusBar_fields = ["Ready", ""]
		for i in range(len(StatusBar_fields)):
			self.StatusBar.SetStatusText(StatusBar_fields[i], i)
		self.FileList.SetMinSize((680, 545))
		self.ReportText.SetMinSize((680, 545))
		# end wxGlade
		
		self.plot_list = list()
		self.figure = Figure(figsize=(5,4), dpi=100)
		self.canvas = FigureCanvas(self.PlotPanel, -1, self.figure)
		self.ax = self.figure.add_axes([0,0,1,1])
		self.SetColor( (255,255,255) )
		
	def __do_layout(self):
		# begin wxGlade: TMainForm.__do_layout
		sizer_5 = wx.BoxSizer(wx.HORIZONTAL)
		sizer_7 = wx.BoxSizer(wx.VERTICAL)
		sizer_6 = wx.BoxSizer(wx.VERTICAL)
		sizer_8 = wx.BoxSizer(wx.HORIZONTAL)
		sizer_9 = wx.BoxSizer

Re: [Matplotlib-users] Font problem

2008-12-11 Thread Jouni K . Seppänen
Michael Droettboom  writes:

> Jörgen Stenarson wrote:
>> I tried to use usetex to generate my pdf figures but I got a crash 
>> when saving the figure, log attached. I traced the crash to 
>> find_tex_file(), apparently ' can not be used to quote filenames in 
>> the windows shell it has to be ". In my patch I just changed it to 
>> always use " I don't know if that works on other systems.
> Someone who knows about usetex should review and apply this patch.

In Unix shells ' is the better quoting character because all sorts of
things have special meaning within " characters... but I changed it to
use subprocess.Popen instead, so we shouldn't need to worry about shell
quoting at all.

Jörgen: Thanks for your report, which I think is the first one from a
Windows user using usetex with the pdf backend. Can you check that the
latest version on the trunk works (either by updating from svn or by
applying the attached patch)? Have you run into any other problems? What
TeX distribution are you using?

-- 
Jouni K. Seppänen
http://www.iki.fi/jks

Index: lib/matplotlib/dviread.py
===
--- lib/matplotlib/dviread.py	(revision 6564)
+++ lib/matplotlib/dviread.py	(revision 6565)
@@ -21,8 +21,8 @@
 import matplotlib
 import matplotlib.cbook as mpl_cbook
 import numpy as np
-import os
 import struct
+import subprocess
 
 _dvistate = mpl_cbook.Bunch(pre=0, outer=1, inpage=2, post_post=3, finale=4)
 
@@ -742,25 +742,15 @@
 doesn't use kpathsea, so what do we do? (TODO)
 """
 
-cmd = 'kpsewhich '
+cmd = ['kpsewhich']
 if format is not None:
-assert "'" not in format
-cmd += "--format='" + format + "' "
-assert "'" not in filename
-cmd += "'" + filename + "'"
-
+cmd += ['--format=' + format]
+cmd += [filename]
+
 matplotlib.verbose.report('find_tex_file(%s): %s' \
   % (filename,cmd), 'debug')
-pipe = os.popen(cmd, 'r')
-result = ""
-while True:
-data = _read_nointr(pipe)
-if data == "":
-break
-result += data
-pipe.close()
-result = result.rstrip()
-
+pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+result = pipe.communicate()[0].rstrip()
 matplotlib.verbose.report('find_tex_file result: %s' % result,
   'debug')
 return result
--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Font problem

2008-12-11 Thread Jörgen Stenarson
Jouni K. Seppänen skrev:
> 
> In Unix shells ' is the better quoting character because all sorts of
> things have special meaning within " characters... but I changed it to
> use subprocess.Popen instead, so we shouldn't need to worry about shell
> quoting at all.
> 
> Jörgen: Thanks for your report, which I think is the first one from a
> Windows user using usetex with the pdf backend. Can you check that the
> latest version on the trunk works (either by updating from svn or by
> applying the attached patch)? Have you run into any other problems? What
> TeX distribution are you using?
> 
>

Jouni,

I'll try it out tomorrow.

/Jörgen

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
___
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Updated Lasso Demo

2008-12-11 Thread Eric Bruning
+1 for including Brian's changes in the shipping example.

Brian, You might also be interested in an alternate, polygon-based
lasso I developed a while back. Though it meets my needs, beware of
backend-specific problems with idle events that I never resolved.

-Eric

http://www.nabble.com/Alternate-lasso:-click-to-form-polygon-td18724261.html

On Sun, Dec 7, 2008 at 10:24 AM, B Clowers  wrote:
> When running the initial lasso demo I found that only one lasso event was
> allowed and other canvas interaction events (e.g. zooming) would not work
> properly after the lasso event.  As such I came up with my own solution to
> the problem by modifying the example source.  The primary addition was a
> button release event call and a boolean to keep track whether the lasso was
> the last event to lock the widget from interaction.  Anyway, I hope it can
> help someone else out.
>
> Cheers,
>
> Brian
>
> 
> """
> Show how to use a lasso to select a set of points and get the indices
> of the selected points.  A callback is used to change the color of the
> selected points
>
> This is currently a proof-of-concept implementation (though it is
> usable as is).  There will be some refinement of the API and the
> inside polygon detection routine.
> """
> from matplotlib.widgets import Lasso
> import matplotlib.mlab
> from matplotlib.nxutils import points_inside_poly
> from matplotlib.colors import colorConverter
> from matplotlib.collections import RegularPolyCollection
>
> from matplotlib.pyplot import figure, show
> from numpy import nonzero
> from numpy.random import rand
>
> class Datum:
> colorin = colorConverter.to_rgba('red')
> colorout = colorConverter.to_rgba('green')
> def __init__(self, x, y, include=False):
> self.x = x
> self.y = y
> if include: self.color = self.colorin
> else: self.color = self.colorout
>
>
> class LassoManager:
> def __init__(self, ax, data):
> self.axes = ax
> self.canvas = ax.figure.canvas
> self.data = data
> #the lasso lock boolean is used to tell whether another
> #widget event has priority
> self.lassoLock = False
>
> self.Nxy = len(data)
>
> facecolors = [d.color for d in data]
> self.xys = [(d.x, d.y) for d in data]
> fig = ax.figure
> self.collection = RegularPolyCollection(
> fig.dpi, 6, sizes=(100,),
> facecolors=facecolors,
> offsets = self.xys,
> transOffset = ax.transData)
>
> ax.add_collection(self.collection)
>
> self.cid = self.canvas.mpl_connect('button_press_event',
> self.onpress)
> self.cidRelease = self.canvas.mpl_connect('button_release_event',
> self.onrelease)
>
> self.ind = None
>
> def callback(self, verts):
> facecolors = self.collection.get_facecolors()
> ind = nonzero(points_inside_poly(self.xys, verts))[0]
> for i in range(self.Nxy):
> if i in ind:
> facecolors[i] = Datum.colorin
> else:
> facecolors[i] = Datum.colorout
>
> self.canvas.draw_idle()
> self.canvas.widgetlock.release(self.lasso)
> #del self.lasso
> self.ind = ind
>
> def onpress(self, event):
> if self.canvas.widgetlock.locked(): return
> if event.inaxes is None: return
> self.lasso = Lasso(event.inaxes, (event.xdata, event.ydata),
> self.callback)
> # acquire a lock on the widget drawing
> self.canvas.widgetlock(self.lasso)
> # establish boolean that can be used to release the widgetlock
> self.lassoLock = True
>
> def onrelease(self, event):
> 'on release we reset the press data'
> # test whether the widgetlock was initiated by the lasso
> if self.lassoLock:
> self.canvas.widgetlock.release(self.lasso)
> self.lassoLock = False
> print self.ind
>
>
> if __name__ == '__main__':
>
> data = [Datum(*xy) for xy in rand(100, 2)]
>
> fig = figure()
> ax = fig.add_subplot(111, xlim=(0,1), ylim=(0,1), autoscale_on=False)
> lman = LassoManager(ax, data)
>
> show()
>
>
> --
> SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
> The future of the web can't happen without you.  Join us at MIX09 to help
> pave the way to the Next Web now. Learn more and register at
> http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
> ___
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>

--
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't ha