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






Showing 21 results of 21

From: Mark B. <mar...@gm...> - 2012年09月06日 22:48:36
On closer inspection the problem isn't calling it from another file,
it is calling it from wxpython. Not exactly sure how to copy code...
lasso_test.py
-----
from matplotlib.widgets import Lasso
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
from scipy import linspace, polyval, polyfit, sqrt, stats, randn
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
 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.ind = None
 def callback(self, verts):
 if hasattr(self, 'temp'):
 self.temp.pop(0).remove()
 facecolors = self.collection.get_facecolors()
 ind = nonzero(points_inside_poly(self.xys, verts))[0]
 selected = []
 for i in range(self.Nxy):
 if i in ind:
 facecolors[i] = Datum.colorin
 selected.append(self.xys[i])
 else:
 facecolors[i] = Datum.colorout
 xs = []
 ys = []
 for n in selected:
 xs.append(n[0])
 ys.append(n[1])
 (ar,br) = polyfit(xs,ys,1)
 t = linspace(min(xs),max(xs))
 print('ar=%s br=%s' % (ar,br))
 xr = polyval([ar,br],t)
 self.temp = self.axes.plot(t,xr,'-',c='b')
 self.canvas.draw_idle()
 self.canvas.widgetlock.release(self.lasso)
 del self.lasso
 self.ind = ind
 def onpress(self, event):
 print('clicked')
 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)
class start_lasso():
 def __init__(self):
 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()
--------------------------------
call_lasso.py
----
import wx
import lasso_test
class MyFrame(wx.Frame):
 """ We simply derive a new class of Frame. """
 def __init__(self, parent, title):
 wx.Frame.__init__(self, parent, title=title, size=(200,100))
 button = wx.Button(self, label='Open Lasso')
 self.Bind(wx.EVT_BUTTON, self.open_lasso, button)
 self.Show(True)
 def open_lasso(self, event):
 lasso_test.start_lasso()
app = wx.App(False)
frame = MyFrame(None, 'Small editor')
app.MainLoop()
-----------------------------
Thanks,
Mark
On Wed, Sep 5, 2012 at 5:15 PM, Tony Yu <ts...@gm...> wrote:
>
>
> On Wed, Sep 5, 2012 at 7:19 PM, Mark Budde <mar...@gm...> wrote:
>>
>> Hi,
>> I'm not an expert so please go easy on me. I am using the pyplot lasso
>> demo, and have got it to work how I would like. I am having a problem,
>> however, where I cannot get it to work if my python file is not the
>> main file (where __name__ is not __main__).
>>
>> I took the part at the bottom in the "if __name__ == '__main__':" and
>> put it into a class. Everything works fine if I call the class from
>> within the same file. However, if I call the class from another file,
>> the graph loads fine but the lasso tool does not work. Troubleshooting
>> revealed that LassoManager.onpress is not being called when I click
>> the mouse. Any suggestions are welcome because this is driving me
>> crazy!
>> Thanks,
>> Mark
>>
>
> Hi Mark,
>
> I can't seem to reproduce your issue, but it's a bit difficult without
> seeing how exactly you wrapped up the "main" part of the code. Just
> guessing: maybe the two cases aren't *exactly* the same.
>
> Is it possible that you have ``lman`` (the LassoManager instance) defined in
> the same block of code as ``show`` in one case but not the other? If, for
> example, ``lman`` is defined in a method of your class, but not saved
> anywhere then it'll get discarded after the method finishes. So ``show``
> would need to be called inside that method, or saved as a class attribute.
>
> Like I said, that's just a wild guess. You should paste the class def if
> you're still having problems.
>
> Best
> -Tony
>
> P.S. If you're running matplotlib from Github master, you might be
> interested in an alternative lasso tool (LassoSelector) that may be simpler
> to use.:
> https://github.com/matplotlib/matplotlib/blob/master/examples/widgets/lasso_selector_demo.py
>
From: jonasr <jon...@we...> - 2012年09月06日 21:50:22
Hello,
i spotted a bug in the Rectangle function when plotting with multiple
subplot, here is a source code example:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from matplotlib.pyplot import *
from numpy import *
import sys, os 
def main():
	f, axs = subplots(1,2)
	
	x=arange(0,10,0.001)
	y=sin(x)
	axs[0].plot(x,y,"blue")#,alpha=1)
	axs[1].plot(x,y,"blue",alpha=1)
			
	rect = Rectangle((0,0), 1, 1, facecolor="blue",alpha=1)
	axs[0].add_patch(rect)
	axs[1].add_patch(rect)		
	
	show()
	return 0
if __name__ == '__main__':
	main()
this script should plot two sin functions and a rectangle in both subplots
.
the rectangle doesn't seem to appear until i move the area from the left
subplot (where the rectangle should appear)
over to the second subplot.
here is an example how it looks like:
http://www.imagebanana.com/view/hzm8bjro/example.png
if i remove the command 
axs[1].add_patch(rect)
the problem doesn't seem to appear
my current matplotlib version is: '1.1.1rc'
os is ubuntu 12.04 
greetz jonas
--
View this message in context: http://matplotlib.1069221.n5.nabble.com/Rectangle-Bug-tp38825.html
Sent from the matplotlib - users mailing list archive at Nabble.com.
From: Jon Roadley-B. <jon...@gm...> - 2012年09月06日 21:06:35
Thats the plan.
The problem is clicking on a plot calls both onpick and onpress (hence
the additional fig.canvas.draw() to work around this).
ill put a flag in and do an if/else on that as well
From: Benjamin R. <ben...@ou...> - 2012年09月06日 20:48:18
On Thu, Sep 6, 2012 at 4:37 PM, Jon Roadley-Battin <
jon...@gm...> wrote:
> On 6 September 2012 14:55, Jon Roadley-Battin
> <jon...@gm...> wrote:
> > On 6 September 2012 14:20, Benjamin Root <ben...@ou...> wrote:
> >>
> >>
> >> On Thu, Sep 6, 2012 at 5:29 AM, Jon Roadley-Battin
> >> <jon...@gm...> wrote:
> >>>
> >>> Good morning,
> >>>
> >>> I have an odd problem with saving plot images via the navigation bar
> >>> (unsure if it is unique to the navigation bar) if I have added custom
> >>> text.
> >>>
> >>> BACKGROUND.
> >>> I have a python gui which is used to connect to some hardware as a
> >>> diagnosis tool. Its a pyGTK program and on one ui tab there is an
> >>> embeded matplotlib plot.
> >>> Now some of the signals I plot rather than being a waveform is more of
> >>> a collection of flags (16bit but thats a by and by)
> >>> eg:
> >>>
> >>>
> >>>
> >>>
> >>> fault
> >>> 0 = fault1
> >>> 0 = fault2
> >>> 1 = fault3
> >>> 0 = fault4
> >>>
> >>>
> >>>
> >>> so for this I can plot this and it will show 2 (possibly changing
> w.r.t.
> >>> time).
> >>> I then hook in via a onpick event such that if I click on a plot I
> >>> essentially do this:
> >>>
> >>> self.figtxt =
> >>> self.fig.text(0.79,0.92,'\n'.join(txt),va='top',
> >>> bbox=dict(boxstyle='round', facecolor='white',alpha=0.7))
> >>> self.plot_marker =
> >>>
> self.plot_area.plot(xdata,ydata,'x',color=event.artist.get_color(),ms=7)
> >>>
> >>> ie I put a cross where someone clicked (for indication) and I also
> >>> create a texxbox which lists human readable version of what bits are
> >>> set.
> >>> Great, really helpful in debugging.
> >>>
> >>> The issue is if you click on the save image icon on the navigation
> >>> toolbar it saves the waveform and legend BUT not the additional
> >>> content (the cross and the textbox).
> >>>
> >>>
> >>> any idea as to how todo this?
> >>>
> >>
> >> What you are describing should work as expected. Is it possible that
> you
> >> could make a simple, self-contained version (hopefully it doesn't need
> to be
> >> embedded to reproduce the problem)? Maybe a modification of one of the
> >> existing examples in the online docs might be able to reproduce your
> issue?
> >>
> >> Ben Root
> >>
> >
> > Good afternoon,
> > I agree it should work and the examples i have run allow this so this
> > is why I am looking over my specifics.
> > The only thing I can see is the examples call to add txt via an axes
> > entity, I have been doing it via a figure entity.
> >
> > I am going to re-write to draw on the axis (last time I did this it
> > didn't display hence going for a figure).
> >
> > If this doesn't work I shall strip the code down to a minimum example
> > demonstrating what I am describing
>
> Well I have narrowed down exactly what causes it and produced a
> stripped down piece of code that reproduces the effect.
>
> It is related to events. I use mpl_connect to connect two functions
> #1 onpick - when a plot is picked annotate plot (in practice IF it is
> a binary array then annotate)
> #2 onpress - click anywhere else and it clears said annotation.
>
> Works well (probably not the best way todo this, but it works). Thing
> is it seems my onpress method is called when I click on the save on
> the toolbar
>
> I guess I should add an if statement ( if event.inaxis ...) so that
> the remove method isn't called outside of the axes area
>
>
Yup, that would do it. Because of how you structured your try/except
statement in onpress(), the canvas is only re-drawn upon any unsuccessful
attempts of removing the text. So, after you save, you still see the text
objects there because the canvas hasn't been redrawn. Doing a test for
"event.inaxes" is the correct way to go there (and making sure you do the
draw at the right situation).
Cheers!
Ben Root
From: Jon Roadley-B. <jon...@gm...> - 2012年09月06日 20:37:34
On 6 September 2012 14:55, Jon Roadley-Battin
<jon...@gm...> wrote:
> On 6 September 2012 14:20, Benjamin Root <ben...@ou...> wrote:
>>
>>
>> On Thu, Sep 6, 2012 at 5:29 AM, Jon Roadley-Battin
>> <jon...@gm...> wrote:
>>>
>>> Good morning,
>>>
>>> I have an odd problem with saving plot images via the navigation bar
>>> (unsure if it is unique to the navigation bar) if I have added custom
>>> text.
>>>
>>> BACKGROUND.
>>> I have a python gui which is used to connect to some hardware as a
>>> diagnosis tool. Its a pyGTK program and on one ui tab there is an
>>> embeded matplotlib plot.
>>> Now some of the signals I plot rather than being a waveform is more of
>>> a collection of flags (16bit but thats a by and by)
>>> eg:
>>>
>>>
>>>
>>>
>>> fault
>>> 0 = fault1
>>> 0 = fault2
>>> 1 = fault3
>>> 0 = fault4
>>>
>>>
>>>
>>> so for this I can plot this and it will show 2 (possibly changing w.r.t.
>>> time).
>>> I then hook in via a onpick event such that if I click on a plot I
>>> essentially do this:
>>>
>>> self.figtxt =
>>> self.fig.text(0.79,0.92,'\n'.join(txt),va='top',
>>> bbox=dict(boxstyle='round', facecolor='white',alpha=0.7))
>>> self.plot_marker =
>>> self.plot_area.plot(xdata,ydata,'x',color=event.artist.get_color(),ms=7)
>>>
>>> ie I put a cross where someone clicked (for indication) and I also
>>> create a texxbox which lists human readable version of what bits are
>>> set.
>>> Great, really helpful in debugging.
>>>
>>> The issue is if you click on the save image icon on the navigation
>>> toolbar it saves the waveform and legend BUT not the additional
>>> content (the cross and the textbox).
>>>
>>>
>>> any idea as to how todo this?
>>>
>>
>> What you are describing should work as expected. Is it possible that you
>> could make a simple, self-contained version (hopefully it doesn't need to be
>> embedded to reproduce the problem)? Maybe a modification of one of the
>> existing examples in the online docs might be able to reproduce your issue?
>>
>> Ben Root
>>
>
> Good afternoon,
> I agree it should work and the examples i have run allow this so this
> is why I am looking over my specifics.
> The only thing I can see is the examples call to add txt via an axes
> entity, I have been doing it via a figure entity.
>
> I am going to re-write to draw on the axis (last time I did this it
> didn't display hence going for a figure).
>
> If this doesn't work I shall strip the code down to a minimum example
> demonstrating what I am describing
Well I have narrowed down exactly what causes it and produced a
stripped down piece of code that reproduces the effect.
It is related to events. I use mpl_connect to connect two functions
#1 onpick - when a plot is picked annotate plot (in practice IF it is
a binary array then annotate)
#2 onpress - click anywhere else and it clears said annotation.
Works well (probably not the best way todo this, but it works). Thing
is it seems my onpress method is called when I click on the save on
the toolbar
I guess I should add an if statement ( if event.inaxis ...) so that
the remove method isn't called outside of the axes area
#!/usr/bin/env python
from matplotlib.pyplot import figure, show
import numpy as np
fig = figure()
text = None
x = np.arange(0,10,0.2)
y = np.arange(10,20,0.2)
ax = fig.add_subplot(111)
ax.plot(x,y,picker=5)
def onpick(event):
 global text
 x = event.artist.get_xdata()[event.ind][0]
 y = event.artist.get_ydata()[event.ind][0]
 text = ax.annotate('foo',xy=(x,y),xytext=(0.8,
0.9),textcoords='axes fraction')
 fig.canvas.draw()
def onpress(event):
 global text
 try:
	text.remove()
 except:
 fig.canvas.draw()
fig.canvas.mpl_connect('button_press_event', onpress)
fig.canvas.mpl_connect('pick_event', onpick)
show()
From: Paul T. <pau...@gm...> - 2012年09月06日 18:27:57
I build from github.
On Thu, Sep 6, 2012 at 10:35 AM, James Morrison <jam...@gm...>wrote:
> Hi, I downloaded a zip from the master on the github matplotlib
> repository, when I run: python3 setup.py install
>
> I get several 'SyntaxError: invalid syntax' errors which appear to
> highlight quotes
> ...
>
> byte-compiling
> /usr/local/lib/python3.2/site-packages/matplotlib/sphinxext/plot_directive.py
> to plot_directive.cpython-32.pyc
> File
> "/usr/local/lib/python3.2/site-packages/matplotlib/sphinxext/plot_directive.py",
> line 510
> exec "import numpy as np\nfrom matplotlib import pyplot as plt\n" in ns
>
My install has:
 exec("import numpy as np\nfrom matplotlib import pyplot
as plt\n", ns)
^^ [no in]
>
> ^
> SyntaxError: invalid syntax
>
> byte-compiling
> /usr/local/lib/python3.2/site-packages/matplotlib/backends/backend_svg.py
> to backend_svg.cpython-32.pyc
> File
> "/usr/local/lib/python3.2/site-packages/matplotlib/backends/backend_svg.py",
> line 69
> s = s.replace(u"&", u"&amp;")
> ^
>
That matches my file, and seems like completely valid syntax. When I copy
and execute that text myself, it doesn't raise an error. However, I think
the problem may be that python3 no longer accepts unicode strings.
s = s.replace("&", "&amp;")
SyntaxError: invalid syntax
>
> ...
>
> Full output is here: https://gist.github.com/3656878
>
> I'm running Scientific Linux 5.4 and numpy appears to work ok installed
> via pip-3.2.
>
> Any ideas?
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: mogliii <mo...@gm...> - 2012年09月06日 14:59:02
<html>
 <head>
 <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
 </head>
 <body bgcolor="#FFFFFF" text="#000000">
 <div class="moz-cite-prefix">On 06/09/2012 14:49, Benjamin Root
 wrote:<br>
 </div>
 <blockquote
cite="mid:CAN...@ma..."
 type="cite"><br>
 <br>
 <div class="gmail_quote">On Thu, Sep 6, 2012 at 6:54 AM, Mogliii <span
 dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:mo...@gm..." target="_blank">mo...@gm...</a>&gt;</span>
 wrote:<br>
 <blockquote class="gmail_quote" style="margin:0 0 0
 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 <div text="#000000" bgcolor="#FFFFFF"> Hi,<br>
 <br>
 I am preparing figures with the following matplotlib
 preamble:<br>
 <br>
 plt.rc('font', **{'family':'serif', 'serif':['Computer
 Modern Roman'],<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'monospace':['Computer Modern
 Typewriter']})<br>
 params = {'backend': 'ps',<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'text.latex.preamble': [r"\usepackage{upgreek}",<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 r"\usepackage[nice]{units}"],<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'axes.labelsize': 12,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'text.fontsize': 12,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'legend.fontsize': 8,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'xtick.labelsize': 10,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'ytick.labelsize': 10,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'text.usetex': True,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'figure.figsize': fig_size,<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'axes.unicode_minus': True}<br>
 plt.rcParams.update(params)<br>
 <br>
 <br>
 But when using subscript and superscript in math mode the
 sizes end up different than in my LaTeX document (my .cls is
 using "book" as base class).<br>
 <br>
 Attached are two screenshots of it rendered from matplotlib
 and from Latex (sorry for the different sizes). The "mean"
 is clearly of different size in relation to the "d".<br>
 <br>
 <br>
 Is there an option to specify a .cls file in rcParams that
 should be used for rendering? <br>
 I tried: <br>
 text.latex.preamble': [r"\documentclass[twoside]{mycls}",<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r"\usepackage{upgreek}",<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
 r"\usepackage[nice]{units}"],<br>
 but then I get the error:<br>
 ! LaTeX Error: Two \documentclass or \documentstyle
 commands.<br>
 <br>
 How to overwrite default matplotlib one? my matplotlibrc has
 a commented preamble.<br>
 <br>
 <br>
 <br>
 See also my question on <a moz-do-not-send="true"
 href="http://tex.stackexchange.com" target="_blank">tex.stackexchange.com</a>:
 <a moz-do-not-send="true"
href="http://tex.stackexchange.com/questions/70400/subscript-size-different-in-latex-and-matplotlib"
 target="_blank">http://tex.stackexchange.com/questions/70400/subscript-size-different-in-latex-and-matplotlib</a><br>
 <br>
 <br>
 <br>
 Many thanks<br>
 </div>
 <br>
 </blockquote>
 <div><br>
 This might have been fixed at one point.&nbsp; Which version of
 matplotlib are you using?<br>
 <br>
 Ben Root<br>
 <br>
 </div>
 </div>
 </blockquote>
 <br>
 I found the solution. My LaTeX file uses the package amsmath, which
 also loads amstext. And that is invoked when using \text{} or
 \textnormal{} inside a formula.<br>
 <br>
 So the solution in matplotlib is to add the following to the
 preamble:<br>
 'text.latex.preamble': [r"\usepackage{upgreek}",<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; r"\usepackage[nice]{units}",<br>
 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="comment-copy"><code>r"\usepackage{amstext}"</code></span>],<br>
 <br>
 I was using matplotlib 1.1, now updated to 1.1.1, but that did not
 affect it. Also, I am not using the built-in LaTeX typesetting.<br>
 <br>
 <br>
 </body>
</html>
From: James M. <jam...@gm...> - 2012年09月06日 14:35:19
Hi, I downloaded a zip from the master on the github matplotlib repository,
when I run: python3 setup.py install
I get several 'SyntaxError: invalid syntax' errors which appear to
highlight quotes
...
byte-compiling
/usr/local/lib/python3.2/site-packages/matplotlib/sphinxext/plot_directive.py
to plot_directive.cpython-32.pyc
 File
"/usr/local/lib/python3.2/site-packages/matplotlib/sphinxext/plot_directive.py",
line 510
 exec "import numpy as np\nfrom matplotlib import pyplot as plt\n" in ns
 ^
SyntaxError: invalid syntax
byte-compiling
/usr/local/lib/python3.2/site-packages/matplotlib/backends/backend_svg.py
to backend_svg.cpython-32.pyc
 File
"/usr/local/lib/python3.2/site-packages/matplotlib/backends/backend_svg.py",
line 69
 s = s.replace(u"&", u"&amp;")
 ^
SyntaxError: invalid syntax
...
Full output is here: https://gist.github.com/3656878
I'm running Scientific Linux 5.4 and numpy appears to work ok installed via
pip-3.2.
Any ideas?
From: Erika M. <eri...@li...> - 2012年09月06日 14:06:40
Hello everyone, 
I have a problem with a colorbar:
I have a stackedbar and a colorbar that I want to create or delete by clicking 
on a button.. but when the colorbar is deleted I want to change the dimension 
of the axes, resizing it even in the place occupied by the colorbar..
I need to create the colorbar by using the function "make_axes_locatable" and 
not others function..
Someone can help me?
this is the code: 
from matplotlib.figure import Figure
from mpl_toolkits.axes_grid.axes_divider import make_axes_locatable
from matplotlib import mpl, colorbar
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as 
FigureCanvas
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
class Test(QWidget):
 def __init__(self):
 QWidget.__init__(self)
 self.resize(1000, 700)
 self.setGeometry(20,30,700,500) 
 self.fig = Figure(figsize=(100,100), dpi=75) 
 self.canvas = FigureCanvas(self.fig)
 self.axes = self.fig.add_subplot(111)
 b = self.axes.bar([0,1,2,3],[5,4,9,6])
 self.colorbar = True
 self.Colorbar()
 self.old_size = self.axes.get_position()
 self.btn = QPushButton()
 self.btn.resize(20,20)
 self.btn.clicked.connect(self.OnBtnClicked)
 self.Layout = QHBoxLayout()
 spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, 
 QSizePolicy.Minimum)
 self.Layout.addItem(spacerItem)
 self.Layout.addWidget(self.canvas)
 self.Layout.addWidget(self.btn)
 self.setLayout(self.Layout)
 def OnBtnClicked(self):
 self.colorbar = not self.colorbar
 self.Colorbar()
 def Colorbar(self):
 if self.colorbar :
 self.divider = make_axes_locatable(self.axes)
 self.cax = self.divider.append_axes("right", size="3%", pad=0.1)
 self.cmap = mpl.colors.ListedColormap(['b']) 
 self.cb = mpl.colorbar.ColorbarBase(self.cax, 
 cmap=self.cmap, 
 orientation='vertical') 
 else:
 if hasattr(self, "cb") :
 fig = self.axes.get_figure()
 fig.delaxes(self.cb.ax)
 del self.cb
 self.axes.set_position(self.old_size) 
 self.fig.canvas.draw()
app = QApplication(sys.argv)
win = Test()
win.show()
sys.exit(app.exec_())
thanks
Erika
From: Jon Roadley-B. <jon...@gm...> - 2012年09月06日 13:56:13
On 6 September 2012 14:20, Benjamin Root <ben...@ou...> wrote:
>
>
> On Thu, Sep 6, 2012 at 5:29 AM, Jon Roadley-Battin
> <jon...@gm...> wrote:
>>
>> Good morning,
>>
>> I have an odd problem with saving plot images via the navigation bar
>> (unsure if it is unique to the navigation bar) if I have added custom
>> text.
>>
>> BACKGROUND.
>> I have a python gui which is used to connect to some hardware as a
>> diagnosis tool. Its a pyGTK program and on one ui tab there is an
>> embeded matplotlib plot.
>> Now some of the signals I plot rather than being a waveform is more of
>> a collection of flags (16bit but thats a by and by)
>> eg:
>>
>>
>>
>>
>> fault
>> 0 = fault1
>> 0 = fault2
>> 1 = fault3
>> 0 = fault4
>>
>>
>>
>> so for this I can plot this and it will show 2 (possibly changing w.r.t.
>> time).
>> I then hook in via a onpick event such that if I click on a plot I
>> essentially do this:
>>
>> self.figtxt =
>> self.fig.text(0.79,0.92,'\n'.join(txt),va='top',
>> bbox=dict(boxstyle='round', facecolor='white',alpha=0.7))
>> self.plot_marker =
>> self.plot_area.plot(xdata,ydata,'x',color=event.artist.get_color(),ms=7)
>>
>> ie I put a cross where someone clicked (for indication) and I also
>> create a texxbox which lists human readable version of what bits are
>> set.
>> Great, really helpful in debugging.
>>
>> The issue is if you click on the save image icon on the navigation
>> toolbar it saves the waveform and legend BUT not the additional
>> content (the cross and the textbox).
>>
>>
>> any idea as to how todo this?
>>
>
> What you are describing should work as expected. Is it possible that you
> could make a simple, self-contained version (hopefully it doesn't need to be
> embedded to reproduce the problem)? Maybe a modification of one of the
> existing examples in the online docs might be able to reproduce your issue?
>
> Ben Root
>
Good afternoon,
I agree it should work and the examples i have run allow this so this
is why I am looking over my specifics.
The only thing I can see is the examples call to add txt via an axes
entity, I have been doing it via a figure entity.
I am going to re-write to draw on the axis (last time I did this it
didn't display hence going for a figure).
If this doesn't work I shall strip the code down to a minimum example
demonstrating what I am describing
From: Benjamin R. <ben...@ou...> - 2012年09月06日 13:50:19
On Thu, Sep 6, 2012 at 6:54 AM, Mogliii <mo...@gm...> wrote:
> Hi,
>
> I am preparing figures with the following matplotlib preamble:
>
> plt.rc('font', **{'family':'serif', 'serif':['Computer Modern Roman'],
> 'monospace':['Computer Modern Typewriter']})
> params = {'backend': 'ps',
> 'text.latex.preamble': [r"\usepackage{upgreek}",
> r"\usepackage[nice]{units}"],
> 'axes.labelsize': 12,
> 'text.fontsize': 12,
> 'legend.fontsize': 8,
> 'xtick.labelsize': 10,
> 'ytick.labelsize': 10,
> 'text.usetex': True,
> 'figure.figsize': fig_size,
> 'axes.unicode_minus': True}
> plt.rcParams.update(params)
>
>
> But when using subscript and superscript in math mode the sizes end up
> different than in my LaTeX document (my .cls is using "book" as base class).
>
> Attached are two screenshots of it rendered from matplotlib and from Latex
> (sorry for the different sizes). The "mean" is clearly of different size in
> relation to the "d".
>
>
> Is there an option to specify a .cls file in rcParams that should be used
> for rendering?
> I tried:
> text.latex.preamble': [r"\documentclass[twoside]{mycls}",
> r"\usepackage{upgreek}",
> r"\usepackage[nice]{units}"],
> but then I get the error:
> ! LaTeX Error: Two \documentclass or \documentstyle commands.
>
> How to overwrite default matplotlib one? my matplotlibrc has a commented
> preamble.
>
>
>
> See also my question on tex.stackexchange.com:
> http://tex.stackexchange.com/questions/70400/subscript-size-different-in-latex-and-matplotlib
>
>
>
> Many thanks
>
>
This might have been fixed at one point. Which version of matplotlib are
you using?
Ben Root
From: Benjamin R. <ben...@ou...> - 2012年09月06日 13:20:42
On Thu, Sep 6, 2012 at 5:29 AM, Jon Roadley-Battin <
jon...@gm...> wrote:
> Good morning,
>
> I have an odd problem with saving plot images via the navigation bar
> (unsure if it is unique to the navigation bar) if I have added custom
> text.
>
> BACKGROUND.
> I have a python gui which is used to connect to some hardware as a
> diagnosis tool. Its a pyGTK program and on one ui tab there is an
> embeded matplotlib plot.
> Now some of the signals I plot rather than being a waveform is more of
> a collection of flags (16bit but thats a by and by)
> eg:
>
>
>
>
> fault
> 0 = fault1
> 0 = fault2
> 1 = fault3
> 0 = fault4
>
>
>
> so for this I can plot this and it will show 2 (possibly changing w.r.t.
> time).
> I then hook in via a onpick event such that if I click on a plot I
> essentially do this:
>
> self.figtxt =
> self.fig.text(0.79,0.92,'\n'.join(txt),va='top',
> bbox=dict(boxstyle='round', facecolor='white',alpha=0.7))
> self.plot_marker =
> self.plot_area.plot(xdata,ydata,'x',color=event.artist.get_color(),ms=7)
>
> ie I put a cross where someone clicked (for indication) and I also
> create a texxbox which lists human readable version of what bits are
> set.
> Great, really helpful in debugging.
>
> The issue is if you click on the save image icon on the navigation
> toolbar it saves the waveform and legend BUT not the additional
> content (the cross and the textbox).
>
>
> any idea as to how todo this?
>
>
What you are describing should work as expected. Is it possible that you
could make a simple, self-contained version (hopefully it doesn't need to
be embedded to reproduce the problem)? Maybe a modification of one of the
existing examples in the online docs might be able to reproduce your issue?
Ben Root
From: Benjamin R. <ben...@ou...> - 2012年09月06日 13:03:28
On Thu, Sep 6, 2012 at 2:24 AM, Eric Firing <ef...@ha...> wrote:
> On 2012年09月05日 6:17 PM, Paul Tremblay wrote:
> > Hmm. I found that mpl handled my datetime objects just fine:
>
> Right, mpl has handled python datetime objects for a long time, but the
> numpy array with a datetime dtype is a new and different object, and it
> will take a bit of work to support it properly.
>
> Eric
>
>
Pedantic: numpy's datetime64 dtype, not datetime.
Ben Root
Hi,
I am preparing figures with the following matplotlib preamble:
plt.rc('font', **{'family':'serif', 'serif':['Computer Modern Roman'],
 'monospace':['Computer Modern Typewriter']})
params = {'backend': 'ps',
 'text.latex.preamble': [r"\usepackage{upgreek}",
 r"\usepackage[nice]{units}"],
 'axes.labelsize': 12,
 'text.fontsize': 12,
 'legend.fontsize': 8,
 'xtick.labelsize': 10,
 'ytick.labelsize': 10,
 'text.usetex': True,
 'figure.figsize': fig_size,
 'axes.unicode_minus': True}
plt.rcParams.update(params)
But when using subscript and superscript in math mode the sizes end up
different than in my LaTeX document (my .cls is using "book" as base class).
Attached are two screenshots of it rendered from matplotlib and from
Latex (sorry for the different sizes). The "mean" is clearly of
different size in relation to the "d".
Is there an option to specify a .cls file in rcParams that should be
used for rendering?
I tried:
text.latex.preamble': [r"\documentclass[twoside]{mycls}",
 r"\usepackage{upgreek}",
 r"\usepackage[nice]{units}"],
but then I get the error:
! LaTeX Error: Two \documentclass or \documentstyle commands.
How to overwrite default matplotlib one? my matplotlibrc has a commented
preamble.
See also my question on tex.stackexchange.com:
http://tex.stackexchange.com/questions/70400/subscript-size-different-in-latex-and-matplotlib
Many thanks
From: Jon Roadley-B. <jon...@gm...> - 2012年09月06日 09:30:50
Good morning,
I have an odd problem with saving plot images via the navigation bar
(unsure if it is unique to the navigation bar) if I have added custom
text.
BACKGROUND.
I have a python gui which is used to connect to some hardware as a
diagnosis tool. Its a pyGTK program and on one ui tab there is an
embeded matplotlib plot.
Now some of the signals I plot rather than being a waveform is more of
a collection of flags (16bit but thats a by and by)
eg:
fault
0 = fault1
0 = fault2
1 = fault3
0 = fault4
so for this I can plot this and it will show 2 (possibly changing w.r.t. time).
I then hook in via a onpick event such that if I click on a plot I
essentially do this:
 self.figtxt =
self.fig.text(0.79,0.92,'\n'.join(txt),va='top',
bbox=dict(boxstyle='round', facecolor='white',alpha=0.7))
 self.plot_marker =
self.plot_area.plot(xdata,ydata,'x',color=event.artist.get_color(),ms=7)
ie I put a cross where someone clicked (for indication) and I also
create a texxbox which lists human readable version of what bits are
set.
Great, really helpful in debugging.
The issue is if you click on the save image icon on the navigation
toolbar it saves the waveform and legend BUT not the additional
content (the cross and the textbox).
any idea as to how todo this?
On 2012年09月05日 6:17 PM, Paul Tremblay wrote:
> Hmm. I found that mpl handled my datetime objects just fine:
Right, mpl has handled python datetime objects for a long time, but the 
numpy array with a datetime dtype is a new and different object, and it 
will take a bit of work to support it properly.
Eric
>
> # put the weeks on the x axis
> # dates are datetime.datetime
> ax.plot(dates, defects)
> ax.xaxis.set_major_formatter(
> matplotlib.dates.DateFormatter('%W'))
>
> # create an invisible line in order to
> # create a secondary x axis below
> # the first axis, which just has the month(s)
> newax = fig.add_axes(ax.get_position())
> newax.spines['bottom'].set_position(('outward', 25))
> newax.patch.set_visible(False)
> newax.yaxis.set_visible(False)
> # months are also datetime. However, I filtered out
> # all dates except the first date for each month
> newax.plot_date(months, y, visible=False)
> newax.xaxis.set_major_locator(
> matplotlib.dates.MonthLocator()
> )
> newax.xaxis.set_major_formatter(
> matplotlib.dates.DateFormatter('%b')
> )
>
> On Thu, Sep 6, 2012 at 12:02 AM, Eric Firing <ef...@ha...
> <mailto:ef...@ha...>> wrote:
>
> On 2012年09月05日 4:04 PM, Paul Tremblay wrote:
> > I am using numpy 1.7, which I built myself (python3 setup.py
> build). I
> > had a chance to look a bit deeper into matplotlib, which in turn
> forced
> > me to learn a bit of numpy, and now I see that it probably makes more
> > sense to use numpy arrays for my data. Since the default for an
> array is
> > a float, most users won't encounter the problems I did, but a
> warning in
> > a FAQ might solve a few headaches, regardless of how the developers
> > decided to go.
>
> Paul,
>
> numpy 1.7 has a new datetime dtype which probably would be good for your
> use--except that mpl doesn't support it yet. That will be a project for
> mpl v1.3.
>
> Eric
>
> >
> > Thanks for your help.
> >
> > Paul
> >
> > On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <ben...@ou...
> <mailto:ben...@ou...>
> > <mailto:ben...@ou... <mailto:ben...@ou...>>> wrote:
> >
> >
> >
> > On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay
> > <pau...@gm... <mailto:pau...@gm...>
> <mailto:pau...@gm... <mailto:pau...@gm...>>>
> wrote:
> >
> >
> > The following Python code:
> >
> > >>ax.fill_between(dates, lower, upper, facecolor='gray',
> alpha=0.5)
> >
> > Produces this error with Python 3.2:
> >
> > Traceback (most recent call last):
> > File "scripts/audit_reports_weekly.py", line 150, in
> <module>
> > ax.fill_between(dates, lower, upper, facecolor='gray',
> > alpha=0.5)
> > File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> > line 6741, in fill_between
> > y1 = ma.masked_invalid(self.convert_yunits(y1))
> > File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> > line 2241, in masked_invalid
> > condition = ~(np.isfinite(a))
> > TypeError: ufunc 'isfinite' not supported for the input
> types,
> > and the inputs could not be safely coerced to any supported
> > types according to the casting rule ''safe''
> >
> >
> > [Decimal('3619.900530366609820157812617'), .....]
> >
> > If I change the list from type Decimal to type float, then I
> > don't get the error. Likewise, if I use Python 2.7, I
> also don't
> > get an error.
> >
> > After reading over the error message, I realize that this
> error
> > really results because of numpy, not matplotlib. But I'll go
> > ahead and post this message, in case you are unaware of the
> > problem.
> >
> >
> > Just a quick note, mpl v1.1.x is not officially supported for
> py3k.
> > The upcoming release of v1.2.0 will be the first official release
> > with such support.
> >
> > That being said, it probably would be a good idea to make
> sure where
> > the bug lies for this one (numpy or matplotlib). Which
> version of
> > numpy are you using?
> >
> > Ben Root
> >
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and
> > threat landscape has changed and how IT managers can respond.
> Discussions
> > will include endpoint security, mobile security and the latest in
> malware
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >
> >
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> <mailto:Mat...@li...>
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond.
> Discussions
> will include endpoint security, mobile security and the latest in
> malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> <mailto:Mat...@li...>
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
Hmm. I found that mpl handled my datetime objects just fine:
# put the weeks on the x axis
# dates are datetime.datetime
ax.plot(dates, defects)
ax.xaxis.set_major_formatter(
 matplotlib.dates.DateFormatter('%W'))
# create an invisible line in order to
# create a secondary x axis below
# the first axis, which just has the month(s)
newax = fig.add_axes(ax.get_position())
newax.spines['bottom'].set_position(('outward', 25))
newax.patch.set_visible(False)
newax.yaxis.set_visible(False)
# months are also datetime. However, I filtered out
# all dates except the first date for each month
newax.plot_date(months, y, visible=False)
newax.xaxis.set_major_locator(
 matplotlib.dates.MonthLocator()
)
newax.xaxis.set_major_formatter(
 matplotlib.dates.DateFormatter('%b')
)
On Thu, Sep 6, 2012 at 12:02 AM, Eric Firing <ef...@ha...> wrote:
> On 2012年09月05日 4:04 PM, Paul Tremblay wrote:
> > I am using numpy 1.7, which I built myself (python3 setup.py build). I
> > had a chance to look a bit deeper into matplotlib, which in turn forced
> > me to learn a bit of numpy, and now I see that it probably makes more
> > sense to use numpy arrays for my data. Since the default for an array is
> > a float, most users won't encounter the problems I did, but a warning in
> > a FAQ might solve a few headaches, regardless of how the developers
> > decided to go.
>
> Paul,
>
> numpy 1.7 has a new datetime dtype which probably would be good for your
> use--except that mpl doesn't support it yet. That will be a project for
> mpl v1.3.
>
> Eric
>
> >
> > Thanks for your help.
> >
> > Paul
> >
> > On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <ben...@ou...
> > <mailto:ben...@ou...>> wrote:
> >
> >
> >
> > On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay
> > <pau...@gm... <mailto:pau...@gm...>> wrote:
> >
> >
> > The following Python code:
> >
> > >>ax.fill_between(dates, lower, upper, facecolor='gray',
> alpha=0.5)
> >
> > Produces this error with Python 3.2:
> >
> > Traceback (most recent call last):
> > File "scripts/audit_reports_weekly.py", line 150, in <module>
> > ax.fill_between(dates, lower, upper, facecolor='gray',
> > alpha=0.5)
> > File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> > line 6741, in fill_between
> > y1 = ma.masked_invalid(self.convert_yunits(y1))
> > File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> > line 2241, in masked_invalid
> > condition = ~(np.isfinite(a))
> > TypeError: ufunc 'isfinite' not supported for the input types,
> > and the inputs could not be safely coerced to any supported
> > types according to the casting rule ''safe''
> >
> >
> > [Decimal('3619.900530366609820157812617'), .....]
> >
> > If I change the list from type Decimal to type float, then I
> > don't get the error. Likewise, if I use Python 2.7, I also don't
> > get an error.
> >
> > After reading over the error message, I realize that this error
> > really results because of numpy, not matplotlib. But I'll go
> > ahead and post this message, in case you are unaware of the
> > problem.
> >
> >
> > Just a quick note, mpl v1.1.x is not officially supported for py3k.
> > The upcoming release of v1.2.0 will be the first official release
> > with such support.
> >
> > That being said, it probably would be a good idea to make sure where
> > the bug lies for this one (numpy or matplotlib). Which version of
> > numpy are you using?
> >
> > Ben Root
> >
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Live Security Virtual Conference
> > Exclusive live event will cover all the ways today's security and
> > threat landscape has changed and how IT managers can respond. Discussions
> > will include endpoint security, mobile security and the latest in malware
> > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> >
> >
> >
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
On 2012年09月05日 4:04 PM, Paul Tremblay wrote:
> I am using numpy 1.7, which I built myself (python3 setup.py build). I
> had a chance to look a bit deeper into matplotlib, which in turn forced
> me to learn a bit of numpy, and now I see that it probably makes more
> sense to use numpy arrays for my data. Since the default for an array is
> a float, most users won't encounter the problems I did, but a warning in
> a FAQ might solve a few headaches, regardless of how the developers
> decided to go.
Paul,
numpy 1.7 has a new datetime dtype which probably would be good for your 
use--except that mpl doesn't support it yet. That will be a project for 
mpl v1.3.
Eric
>
> Thanks for your help.
>
> Paul
>
> On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <ben...@ou...
> <mailto:ben...@ou...>> wrote:
>
>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay
> <pau...@gm... <mailto:pau...@gm...>> wrote:
>
>
> The following Python code:
>
> >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>
> Produces this error with Python 3.2:
>
> Traceback (most recent call last):
> File "scripts/audit_reports_weekly.py", line 150, in <module>
> ax.fill_between(dates, lower, upper, facecolor='gray',
> alpha=0.5)
> File
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> line 6741, in fill_between
> y1 = ma.masked_invalid(self.convert_yunits(y1))
> File
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> line 2241, in masked_invalid
> condition = ~(np.isfinite(a))
> TypeError: ufunc 'isfinite' not supported for the input types,
> and the inputs could not be safely coerced to any supported
> types according to the casting rule ''safe''
>
>
> [Decimal('3619.900530366609820157812617'), .....]
>
> If I change the list from type Decimal to type float, then I
> don't get the error. Likewise, if I use Python 2.7, I also don't
> get an error.
>
> After reading over the error message, I realize that this error
> really results because of numpy, not matplotlib. But I'll go
> ahead and post this message, in case you are unaware of the
> problem.
>
>
> Just a quick note, mpl v1.1.x is not officially supported for py3k.
> The upcoming release of v1.2.0 will be the first official release
> with such support.
>
> That being said, it probably would be a good idea to make sure where
> the bug lies for this one (numpy or matplotlib). Which version of
> numpy are you using?
>
> Ben Root
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
I am using numpy 1.7, which I built myself (python3 setup.py build). I had
a chance to look a bit deeper into matplotlib, which in turn forced me to
learn a bit of numpy, and now I see that it probably makes more sense to
use numpy arrays for my data. Since the default for an array is a float,
most users won't encounter the problems I did, but a warning in a FAQ might
solve a few headaches, regardless of how the developers decided to go.
Thanks for your help.
Paul
On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <ben...@ou...> wrote:
>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <pau...@gm...>wrote:
>
>>
>> The following Python code:
>>
>> >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>>
>> Produces this error with Python 3.2:
>>
>> Traceback (most recent call last):
>> File "scripts/audit_reports_weekly.py", line 150, in <module>
>> ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
>> File
>> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
>> line 6741, in fill_between
>> y1 = ma.masked_invalid(self.convert_yunits(y1))
>> File
>> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
>> line 2241, in masked_invalid
>> condition = ~(np.isfinite(a))
>> TypeError: ufunc 'isfinite' not supported for the input types, and the
>> inputs could not be safely coerced to any supported types according to the
>> casting rule ''safe''
>>
>>
>> [Decimal('3619.900530366609820157812617'), .....]
>>
>> If I change the list from type Decimal to type float, then I don't get
>> the error. Likewise, if I use Python 2.7, I also don't get an error.
>>
>> After reading over the error message, I realize that this error really
>> results because of numpy, not matplotlib. But I'll go ahead and post this
>> message, in case you are unaware of the problem.
>>
>>
> Just a quick note, mpl v1.1.x is not officially supported for py3k. The
> upcoming release of v1.2.0 will be the first official release with such
> support.
>
> That being said, it probably would be a good idea to make sure where the
> bug lies for this one (numpy or matplotlib). Which version of numpy are
> you using?
>
> Ben Root
>
>
From: Tony Yu <ts...@gm...> - 2012年09月06日 00:16:34
On Wed, Sep 5, 2012 at 7:19 PM, Mark Budde <mar...@gm...> wrote:
> Hi,
> I'm not an expert so please go easy on me. I am using the pyplot lasso
> demo, and have got it to work how I would like. I am having a problem,
> however, where I cannot get it to work if my python file is not the
> main file (where __name__ is not __main__).
>
> I took the part at the bottom in the "if __name__ == '__main__':" and
> put it into a class. Everything works fine if I call the class from
> within the same file. However, if I call the class from another file,
> the graph loads fine but the lasso tool does not work. Troubleshooting
> revealed that LassoManager.onpress is not being called when I click
> the mouse. Any suggestions are welcome because this is driving me
> crazy!
> Thanks,
> Mark
>
>
Hi Mark,
I can't seem to reproduce your issue, but it's a bit difficult without
seeing how exactly you wrapped up the "main" part of the code. Just
guessing: maybe the two cases aren't *exactly* the same.
Is it possible that you have ``lman`` (the LassoManager instance) defined
in the same block of code as ``show`` in one case but not the other? If,
for example, ``lman`` is defined in a method of your class, but not saved
anywhere then it'll get discarded after the method finishes. So ``show``
would need to be called inside that method, or saved as a class attribute.
Like I said, that's just a wild guess. You should paste the class def if
you're still having problems.
Best
-Tony
P.S. If you're running matplotlib from Github master, you might be
interested in an alternative lasso tool (LassoSelector) that may be
simpler to use.:
https://github.com/matplotlib/matplotlib/blob/master/examples/widgets/lasso_selector_demo.py
From: Benjamin R. <ben...@ou...> - 2012年09月06日 00:15:47
On Wednesday, September 5, 2012, Mark Budde wrote:
> Hi,
> I'm not an expert so please go easy on me. I am using the pyplot lasso
> demo, and have got it to work how I would like. I am having a problem,
> however, where I cannot get it to work if my python file is not the
> main file (where __name__ is not __main__).
>
> I took the part at the bottom in the "if __name__ == '__main__':" and
> put it into a class. Everything works fine if I call the class from
> within the same file. However, if I call the class from another file,
> the graph loads fine but the lasso tool does not work. Troubleshooting
> revealed that LassoManager.onpress is not being called when I click
> the mouse. Any suggestions are welcome because this is driving me
> crazy!
> Thanks,
> Mark
I can assure you that it does work from a library because I have done that.
 Most likely it is some minor error in your code. Is it possible to post a
simple example to demonstrate your problem?
Ben Root

Showing 21 results of 21

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