[Matplotlib-users] Using a picture as a legend label

2013-06-12 Thread Michael Cracraft
A typical plot for me includes some simple line curves and a legend
attempting to describe what apparatus that curve belongs to.  Often the
labels I give seem clear to me at the time, but even returning a month
later to the plot, I'll be as lost as the next guy.

A few of my colleagues have been plotting curves, and then including a
picture or diagram in place of a typical legend label.  The picture or
diagram is bordered by the color of the trace on the plot.  I am fairly
certain the plots are done in Matlab.  The diagrams are simply dropped into
a powerpoint deck and given a border that is matched as close as possible
to the trace.  I did some things like that back in graduate school.

Seems like it would be neat to have a way to do a legend in matplotlib that
does something like this.  I'm envisioning a regular axes with lines,
scatter plots, etc. to the left and a column of graphics to the right.  I
would think this would be fairly doable using GridSpec or some of the
similar layout.  The place I could see getting hung up would be adding a
color border to a picture that matches the trace and also doing the scaling
to make it work all dynamically for different numbers of traces.
--
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Looking for a good color map that works both for color and bw

2012-01-16 Thread Michael Cracraft
I prepared some plots for a conference paper using pcolormesh.  The plots
need to work both for color and for a bw print copy.  Does anyone have a
goto color map for that sort of occassion?  I was using YlGrBu, but I'm
just not happy with it.

Thanks,
Michael
--
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Issue with Redrawing a Line (numpy.ndarray, set_ydata, and draw)

2010-10-06 Thread Michael Cracraft
I have a code that continuously modifies a numpy.ndarray variable.  Then, I
use set_ydata on the matplotlib.lines.Line2D object to the same ndarray
variable.  Then, I call fig.canvas.draw() to redraw the figure, where fig is
Figure object.

However, the line on the graph never changes.  I print a few entries to the
console to make sure that the variable is changing.

It seems like the only way I can get the line to update is to create a
completely new ndarray, update that variable with the new values and use
set_ydata on my line object.  Then, the redraw works.  Other things that I
tried that didn't seem to work were:

L1.set_ydata(x[:])
L1.set_ydata(x.tolist())
L1.set_ydata(list(x))


where L1 is my line object, and x is my ndarray.  To make it redraw I have
to do something like this.

xnew = numpy.zeros(numpy.size(x,0))
for k in range(numpy.size(x,0)):
 xnew[k] = x[k]
L1.set_ydata(xnew)
fig.canvas.draw()

Is there some switch I can set to force a redraw of the elements?  I feel
like I am missing something fundamental.

Thanks,
Michael

-- 
_
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Issue with Redrawing a Line (numpy.ndarray, set_ydata, and draw)

2010-10-06 Thread Michael Cracraft
I am running python 2.6.4 and matplotlib 0.99.1.1.  I was using the TkAgg
backend with my original problem, but I tried GTKAgg with the same result.
Here are two sample codes.  One works and the other does not.

This one works ...

plt.ion()

x = np.arange(0,2*np.pi,0.01)
y = np.sin(x)
line, = plt.plot(x,y)
for i in np.arange(1,200):
y = np.sin(x + i/10.0)
line.set_ydata(y)
plt.draw()

This one does not ...

plt.ion()

x = np.arange(0,2*np.pi,0.01)
y = np.sin(x)
line, = plt.plot(x,y)
for i in np.arange(1,200):
for k in range(len(x)):
y[k] = np.sin(x[k] + i/10.0)
line.set_ydata(y)
plt.draw()

The only real difference is that I do not get a new ndarray instance in the
second one.  My guess was that there was something to do with the object
being the same instance as before causing some issue when I updated the
ydata.



On Wed, Oct 6, 2010 at 7:56 PM, Benjamin Root ben.r...@ou.edu wrote:

 On Wed, Oct 6, 2010 at 1:06 PM, Michael Cracraft 
 michael.cracr...@gmail.com wrote:

 I have a code that continuously modifies a numpy.ndarray variable.  Then,
 I use set_ydata on the matplotlib.lines.Line2D object to the same ndarray
 variable.  Then, I call fig.canvas.draw() to redraw the figure, where fig is
 Figure object.

 However, the line on the graph never changes.  I print a few entries to
 the console to make sure that the variable is changing.

 It seems like the only way I can get the line to update is to create a
 completely new ndarray, update that variable with the new values and use
 set_ydata on my line object.  Then, the redraw works.  Other things that I
 tried that didn't seem to work were:

 L1.set_ydata(x[:])
 L1.set_ydata(x.tolist())
 L1.set_ydata(list(x))


 where L1 is my line object, and x is my ndarray.  To make it redraw I have
 to do something like this.

 xnew = numpy.zeros(numpy.size(x,0))
 for k in range(numpy.size(x,0)):
  xnew[k] = x[k]
 L1.set_ydata(xnew)
 fig.canvas.draw()

 Is there some switch I can set to force a redraw of the elements?  I feel
 like I am missing something fundamental.

 Thanks,
 Michael


 Michael,

 Which version of matplotlib are you using?  Which backend are you using?
 Also, could you include a small script or two that demonstrate the problem?
 This way, we can poke around with it and see what is up.

 Ben Root




-- 
_
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Issue with Redrawing a Line (numpy.ndarray, set_ydata, and draw)

2010-10-06 Thread Michael Cracraft
You are correct about the version.  I was just working with the version
installed on Fedora 13, and the recache works.  Looks like a working
solution for now.

Thanks,
Michael


On Wed, Oct 6, 2010 at 8:18 PM, Jae-Joon Lee lee.j.j...@gmail.com wrote:

 I believe that you're using older version of mpl (1.0) and this is a
 known issues, which has been fixed.


 http://sourceforge.net/tracker/?func=detailaid=2917758group_id=80706atid=560720

 Try to add

 L1.recache()

 after set_ydata.

 Regards,

 -JJ



 On Thu, Oct 7, 2010 at 3:06 AM, Michael Cracraft
 michael.cracr...@gmail.com wrote:
  I have a code that continuously modifies a numpy.ndarray variable.  Then,
 I
  use set_ydata on the matplotlib.lines.Line2D object to the same ndarray
  variable.  Then, I call fig.canvas.draw() to redraw the figure, where fig
 is
  Figure object.
 
  However, the line on the graph never changes.  I print a few entries to
 the
  console to make sure that the variable is changing.
 
  It seems like the only way I can get the line to update is to create a
  completely new ndarray, update that variable with the new values and use
  set_ydata on my line object.  Then, the redraw works.  Other things that
 I
  tried that didn't seem to work were:
 
  L1.set_ydata(x[:])
  L1.set_ydata(x.tolist())
  L1.set_ydata(list(x))
 
 
  where L1 is my line object, and x is my ndarray.  To make it redraw I
 have
  to do something like this.
 
  xnew = numpy.zeros(numpy.size(x,0))
  for k in range(numpy.size(x,0)):
   xnew[k] = x[k]
  L1.set_ydata(xnew)
  fig.canvas.draw()
 
  Is there some switch I can set to force a redraw of the elements?  I feel
  like I am missing something fundamental.
 
  Thanks,
  Michael
 
  --
  _
 
 
 --
  Beautiful is writing same markup. Internet Explorer 9 supports
  standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
  Spend less time writing and  rewriting code and more time creating great
  experiences on the web. Be a part of the beta today.
  http://p.sf.net/sfu/beautyoftheweb
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 




-- 
_
--
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2  L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users