[Matplotlib-users] Using Proxy Artist to make legend

2012-01-26 Thread Sabine van der Linden
Hello, 

I have made a plot with a fill_between part, which does not show up in the
legend. I have read that I have to use a proxy artist for this, but I have no
clue where to place this, and how.. The fill between works fine, it's just the
legend that is not really cooperating ;) 

import matplotlib.pyplot as plt

plt.plot(dbx, gemlist)
plt.title('Reekslengte '+str(i))
plt.xlabel('signaal-ruisverhouding ingangssignaal (dB)')
plt.ylabel('signaal-ruisverhouding uitgangssignaal (dB)')
plt.xlim(-36, 22)

plt.fill_between(dbx, boven, onder, color='b', alpha=0.1)
plt.legend(loc=4)
plt.show()

Tnx in advance :) 

Sabine 


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Using Proxy Artist to make legend

2012-01-26 Thread Tony Yu
On Thu, Jan 26, 2012 at 8:20 AM, Sabine van der Linden wrote:

> Hello,
>
> I have made a plot with a fill_between part, which does not show up in the
> legend. I have read that I have to use a proxy artist for this, but I have
> no
> clue where to place this, and how.. The fill between works fine, it's just
> the
> legend that is not really cooperating ;)
>
> import matplotlib.pyplot as plt
>
> plt.plot(dbx, gemlist)
> plt.title('Reekslengte '+str(i))
> plt.xlabel('signaal-ruisverhouding ingangssignaal (dB)')
> plt.ylabel('signaal-ruisverhouding uitgangssignaal (dB)')
> plt.xlim(-36, 22)
>
> plt.fill_between(dbx, boven, onder, color='b', alpha=0.1)
> plt.legend(loc=4)
> plt.show()
>
> Tnx in advance :)
>
> Sabine
>
>
I have a convenience function (copied below) in my python path that I like
to use for this purpose.

Hope that helps,
-Tony

#

def fill_between(x, y1, y2=0, ax=None, **kwargs):
"""Plot filled region between `y1` and `y2`.

This function works exactly the same as matplotlib's fill_between,
except
that it also plots a proxy artist (specifically, a rectangle of 0 size)
so that it can be added it appears on a legend.
"""
ax = ax if ax is not None else plt.gca()
ax.fill_between(x, y1, y2, **kwargs)
p = plt.Rectangle((0, 0), 0, 0, **kwargs)
ax.add_patch(p)
return p
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Hardware rendering with tricontourf

2012-01-26 Thread Howard

Hi all

I'm rendering some images with about 3.5 million triangles into a 
512x512 png file using tricontourf. I'm running this in a virtual 
machine, and I'm pretty sure that there is no graphics rendering 
hardware being used. Is it possible, assuming the hardware was 
available, to make tricontourf use the rendering hardware?  Will that 
happen by default?


Here's the relevant portion of the code.

   figure1 = plt.figure(figsize=(imageWidth,imageHeight))
   theTriangulation.set_mask(mask)
   plt.axis("off")

   # This makes sure the figure fills the canvas
   ax = figure1.add_axes([0,0,1,1])

   # This turns off the tick marks of the axis we added.
   ax.axis("off")
   plt.tricontourf(theTriangulation,
 modelData,
 theLookupTable.N,
 norm=theNorm,
 antialiased=False,
 cmap=theLookupTable)
  canvas = FigureCanvasAgg(figure1)
  canvas.print_figure(fileName, dpi=DPI)

Thanks
Howard
--
Howard Lander 
Senior Research Software Developer
Renaissance Computing Institute (RENCI) 
The University of North Carolina at Chapel Hill
Duke University
North Carolina State University
100 Europa Drive
Suite 540
Chapel Hill, NC 27517
919-445-9651
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Events

2012-01-26 Thread Jerzy Karczmarczuk
Does anybody know how to generate and process my "private" events? I can 
subclass the Event() class, say, MyEvent,
with a name "my_event", and I can -
canvas.mpl_connect('my_event', aCallback)

but then, how to fire one? (I don't want to call the callback directly).


Suppose that the interface, when show() is active launches a 
simulation/visualisation program which animates many things in its 
figure. From time to time something "special" appears, and its behaviour 
should be steered by those private events.

(Yes, I know that I can do it in several other ways, or write my own 
event-processing loop, or use directly wxPython or PyGTK instead of 
Matplotlib. So, I don't need the replacement solution, but just a way to 
fire events within Matplotlib...)

Thank you.

Jerzy Karczmarczuk
Caen, France

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Events

2012-01-26 Thread Benjamin Root
On Thu, Jan 26, 2012 at 3:24 PM, Jerzy Karczmarczuk <
jerzy.karczmarc...@unicaen.fr> wrote:

> Does anybody know how to generate and process my "private" events? I can
> subclass the Event() class, say, MyEvent,
> with a name "my_event", and I can -
>canvas.mpl_connect('my_event', aCallback)
>
> but then, how to fire one? (I don't want to call the callback directly).
>
>
> Suppose that the interface, when show() is active launches a
> simulation/visualisation program which animates many things in its
> figure. From time to time something "special" appears, and its behaviour
> should be steered by those private events.
>
> (Yes, I know that I can do it in several other ways, or write my own
> event-processing loop, or use directly wxPython or PyGTK instead of
> Matplotlib. So, I don't need the replacement solution, but just a way to
> fire events within Matplotlib...)
>
> Thank you.
>
> Jerzy Karczmarczuk
> Caen, France
>
>
It is smart to simply re-use mpl's event callback system.  Luckily, in the
latest release, we allowed for arbitary events to be added.  To answer your
question, take a look at how pick_event() is declared in backend_bases.py:

def pick_event(self, mouseevent, artist, **kwargs):
"""
This method will be called by artists who are picked and will
fire off :class:`PickEvent` callbacks registered listeners
"""
s = 'pick_event'
event = PickEvent(s, self, mouseevent, artist, **kwargs)
self.callbacks.process(s, event)

The function that "fires" the event is "self.callbacks.process(s, event)",
where "self" is the figure canvas.

I hope this helps!
Ben Root
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Spline in Path

2012-01-26 Thread fabio.lima
 

Dear users Matplotlib 
I am new to Matplotlib and would like to know
how the code below I can set the command to plot the spline instead of
straight lines. 

# -- Plot the reaction path
import pylab as p
fig =
p.figure(1)
sp = p.subplot(1,1,1)

p.plot(range(len(Epath)), Epath,
's-')

for idx, (E,label) in enumerate(zip(Epath,PathLabels)):

p.text(idx, E, label,
 horizontalalignment='center',

verticalalignment='top')

p.title('H2O disassociation')
p.ylabel('Energy
[eV]')
p.xlabel('Reaction path')
p.xlim([-0.5, 2.5])
p.ylim([-0.5,
1.5])
sp.get_xaxis().set_ticks([]) # Turn off ticks on
xaxis

p.show()

Best Regards 

Fábio de Lima
Chemistry Department -
UFMS- Campo Grande Brazil
Phone: 55 (67) 3345-3596
Cellular: 55 (67)
9639-1338
 --
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plot_date() runtime error

2012-01-26 Thread Shankararaman Ramakrishnan
Hi,

 

I have been trying to leverage plot_date() to generate time trends. I
seem to run into the following runtime error and don't have much
insight as to why this is happening. Specifically, I don't quite see why
the function is attempting to set the lower bound to 0001-01-01 UTC when
my x-axis starts only from day number 729390. 

I am using Python 2.4 and Matplotlib 1.0.1

 

In [131]: date_num = date2num(dates)

 

In [132]: date_num

Out[132]: 

array([ 729390.,  729391.,  729392.,  729393.,  729394.,  729395.,

729396.,  729397.,  729398.,  729399.])

 

In [133]: plot_date(date_num,range(10))

 

RuntimeError: RRuleLocator estimated to generate 2012 ticks from
0001-01-01 00:00:00+00:00 to 2012-02-04 17:46:21.028099+00:00: exceeds
Locator.MAXTICKS * 2 (2000)

 

 

Any help will be much appreciated.

 

Thanks,
Shankar

 

 

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plot_date() runtime error

2012-01-26 Thread Paul Ivanov
Hi Shankar,

Shankararaman Ramakrishnan, on 2012-01-26 18:24,  wrote:
> I have been trying to leverage plot_date() to generate time trends. I
> seem to run into the following runtime error and don't have much
> insight as to why this is happening. Specifically, I don't quite see why
> the function is attempting to set the lower bound to 0001-01-01 UTC when
> my x-axis starts only from day number 729390. 

I suspect this may be the case because you've already plotted
something on this axis that resolves to this early date. For
example, I can reproduce an error similar to yours by first doing
plot(1,0) before the plot_date call.

Can you try to create a new figure just before the call to plot_date?

best,
-- 
Paul Ivanov
314 address only used for lists,  off-list direct email at:
http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 

--
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users