Re: [matplotlib-devel] legend.py "ValueError: numpoints must be >= 0; it was 0"

2011-07-20 Thread Jae-Joon Lee
Sorry for this very very reply.
The error message is now fixed in the git master branch.

Regards,

-JJ


On Fri, May 20, 2011 at 12:31 PM, Steve Ward  wrote:
> In legend.__init__ the exception message doesn't match the condition
> that raises it.  I think it should say "numpoints must be > 0".  I'm
> using matplotlib version 0.99.3.
>
> Example:
> #
> import matplotlib.pyplot as plt
> ax = plt.subplot(1,1,1)
> ax.plot(1.1, 2.2, label='foo')
> ax.legend(numpoints=0)
> #
> # ValueError: numpoints must be >= 0; it was 0
>
>
> Steve
>
> --
> What Every C/C++ and Fortran developer Should Know!
> Read this article and learn how Intel has extended the reach of its
> next-generation tools to help Windows* and Linux* C/C++ and Fortran
> developers boost performance applications - including clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> ___
> Matplotlib-devel mailing list
> Matplotlib-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-devel
>

--
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


Re: [matplotlib-devel] Plan for cutting v1.1.0?

2011-07-20 Thread Benjamin Root
On Friday, July 15, 2011, Fernando Perez  wrote:
> On Wed, Jul 13, 2011 at 1:58 PM, Benjamin Root  wrote:
>> I would love to find out if there is some way to embed a video using sphinx
>
> have a look at the sources for:
>
> http://fperez.org/talks
>
> Cheers,
>
> f
>

That is pretty straight-forward and easy to use.  My main concern
though will be that YouTube demo videos have to be considered as
static resources and not created on the fly.  This has to be the case
because we would need the YouTube URL for the link.  Might not be
terrible.

On a related note, I was reading through the docs for la (labeled
arrays) when I noticed that the docs had functions organized.  I
haven't looked at the source code yet, but I wonder if it was done
with some sort of sphinx magic that we could use?

Ben

--
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel


[matplotlib-devel] Figures don't keep a reference to widgets.

2011-07-20 Thread Charles R Harris
This turned up when I generated blowups of portions of a thumbnail image by
clicking on various locations. The blowups contained a button, but the
button was inoperative. My guess is that when the click handler that created
the blowup exited it took the button object with it. My workaround was to
create the various button handlers in the Button __init__ method so that
they hung onto a reference to self. This may not be the best approach so
I've attached a file for discussion.

Chuck
"""
GUI Neutral widgets

All of these widgets require you to predefine an Axes instance and
pass that as the first arg.  matplotlib doesn't try to be too smart in
layout -- you have to figure out how wide and tall you want your Axes
to be to accommodate your widget.
"""

import numpy as np

class Widget:
"""
OK, I couldn't resist; abstract base class for mpl GUI neutral
widgets
"""
drawon = True
eventson = True




class Button(Widget):
"""
A GUI neutral button

The following attributes are accesible

  ax- the Axes the button renders into
  label - a text.Text instance
  color - the color of the button when not hovering
  hovercolor - the color of the button when hovering

Call "on_clicked" to connect to the button
"""

def __init__(self, ax, label, image=None,
 color='0.85', hovercolor='0.95'):
"""
ax is the Axes instance the button will be placed into

label is a string which is the button text

image if not None, is an image to place in the button -- can
  be any legal arg to imshow (numpy array, matplotlib Image
  instance, or PIL image)

color is the color of the button when not activated

hovercolor is the color of the button when the mouse is over
  it

"""
def click(event):
if event.inaxes != self.ax:
return
if not self.eventson:
return
for cid, func in self.observers.items():
func(event)

def motion(event):
if event.inaxes==self.ax:
c = self.hovercolor
else:
c = self.color
if c != self.lastcolor:
self.ax.set_axis_bgcolor(c)
self.lastcolor = c
if self.drawon: self.ax.figure.canvas.draw()

if image is not None:
ax.imshow(image)
self.label = ax.text(0.5, 0.5, label,
 verticalalignment='center',
 horizontalalignment='center',
 transform=ax.transAxes)

self.cnt = 0
self.ax = ax
self.color = color
self.hovercolor = hovercolor
self.lastcolor = color
self.observers = {}

ax.figure.canvas.mpl_connect('button_press_event', click)
ax.figure.canvas.mpl_connect('motion_notify_event', motion)
ax.set_navigate(False)
ax.set_axis_bgcolor(color)
ax.set_xticks([])
ax.set_yticks([])


def on_clicked(self, func):
"""
When the button is clicked, call this func with event

A connection id is returned which can be used to disconnect
"""
cid = self.cnt
self.observers[cid] = func
self.cnt += 1
return cid

def disconnect(self, cid):
'remove the observer with connection id cid'
try:
del self.observers[cid]
except KeyError:
pass

--
5 Ways to Improve & Secure Unified Communications
Unified Communications promises greater efficiencies for business. UC can 
improve internal communications as well as offer faster, more efficient ways
to interact with customers and streamline customer service. Learn more!
http://www.accelacomm.com/jaw/sfnl/114/51426253/___
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel