Re: [Matplotlib-users] Emulating keypress and mouse clicks

2013-11-22 Thread Eric Larson
Just wanted to let people know that I chased down the problem I was having.
The command I was using was working, but I wrongly assumed the coordinate
system was normalized for some reason. Doing things like:

fig.canvas.button_press_event(110, 240, 1, False, None)


works great!


Cheers,

Eric




On Thu, Nov 21, 2013 at 9:52 AM, Eric89GXL  wrote:

> Hello,
>
> I have some some matplotlib code that we use for interactive plotting, and
> I
> want to do non-interactive unit testing. This means I need to emulate
> keypresses and mouse clicks.
>
> It is simple enough to do keypress unit testing by using:
>
> fig.canvas.key_press_event('down')
>
> This for example allows us to test that pressing "down" in a figure window
> elicits the appropriate behavior.
>
> However, I am having difficulty testing mouse clicks. We have behaviors
> where users can click within an axis (e.g., fix.axes[1]) to elicit some
> behavior. I have tried the following:
>
> fig.canvas.button_press_event(0.5, 0.5, 1)
>
> But within the event handler (which generally has structure
> _mouse_click(event, params)), the "event" object does not have the
> "event.inaxes" field populated correctly (it is always "None") despite my
> emulated click @ (0.5, 0.5) sitting within one of the axes in the figure.
>
> Does anyone know how to emulate either of these types of clicks?
>
>
>
> --
> View this message in context:
> http://matplotlib.1069221.n5.nabble.com/Emulating-keypress-and-mouse-clicks-tp42534.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> --
> Shape the Mobile Experience: Free Subscription
> Software experts and developers: Be at the forefront of tech innovation.
> Intel(R) Software Adrenaline delivers strategic insight and game-changing
> conversations that shape the rapidly evolving mobile landscape. Sign up
> now.
> http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Installation issue: python setup.py install --home=... fails

2013-11-22 Thread Russell E. Owen
In article <528e8aac.1090...@stsci.edu>,
 Michael Droettboom  
 wrote:

> When you use |--home|, distutils assumes you are referring to a home 
> directory in which you have a tree of libraries in |lib|lib64| living 
> there, so it appends |lib64/python| to the given path:
> 
> |> python setup.py install --home=/foo
> running install
> Checking .pth file supportin  /foo/lib64/python/
> error: can't create or remove files in install directory|
> 
> So the issue is not that your PYTHONPATH doesn't contain 
> |/lsst/home/rowen/code/sandbox/Linux64/external/matplotlib/1.3.1+1| 
> (which it does) but that it doesn't contain 
> |/lsst/home/rowen/code/sandbox/Linux64/external/matplotlib/1.3.1+1/lib/python|
> |.
> 
> With matplotlib 1.2.1, we used raw distutils and not setuptools, which 
> does the same thing without the strict check.  And that does allow users 
> to shoot themselves in the foot, since the check is in fact right when 
> it says things won't work:
> 
> |> git checkout v1.2.1
> > mkdir ~/foo
> > python setup.py install --home=~/foo
> ...
> > PYTHONPATH=~/foo python
> Python2.7.5  (default, Oct8  2013,12:19:40)
> [GCC4.8.1  20130603  (Red Hat4.8.1-1)] on linux2
> Type"help","copyright","credits"  or  "license"  for  more information.
> >>>import  matplotlib
> Traceback (most recent call last):
>File"", line1,in  
> ImportError: No module named matplotlib|
> 
> I think what you really want to use is |--install-lib|, which will 
> install the matplotlib library directly inside of the given path, which 
> (if it's also on the `PYTHONPATH`) it will work.

Thank you. That did it!

For the record, we do actually want the files in /lib/python. So I 
fixed it by manually adding /lib/python to PYTHONPATH before 
running the installer.

It would help if the error message showed which path was expected to be 
on the PYTHONPATH, but now that I know I'm happy.

-- Russell


--
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] figure.colorbar sometimes raises an exception

2013-11-22 Thread Russell E. Owen
We have code that ran fine in 1.1.1 that raises an exception in colorbar 
in 1.2.1 and 1.3.1. I have appended an example; I'm afraid it is rather 
extreme, but we have seen this for arrays that have more than one 
non-masked values as well, even with the values not all being equal.

Should I report this as a bug? Should we guard all our calls to colormap 
with try/except, or perhaps there's a flag we can set that says "do your 
best"? (But I don't see anything like that in the docs).

-- Russell

cmap = getattr(cm, cmap)
cmap.set_bad('k', 0.2)
if cmapOver is not None:
cmap.set_over(cmapOver, 1.0)
if cmapUnder is not None:
cmap.set_under(cmapUnder, 1.0)
p = PatchCollection(patches, norm=norm, cmap=cmap)
value_array = numpy.array(values)
masked_value_array = 
numpyMa.masked_where(numpy.isnan(value_array), value_array)
p.set_array(masked_value_array)
cb = self.fig.colorbar(p)

  File 
"/nfs/lsst/home/rowen/code/testing_pipeQA/python/lsst/testing/pipeQA/figu
res/FpaQaFigure.py", line 317, in makeFigure
cb = self.fig.colorbar(p)
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/figure.py
", line 1451, in colorbar
cb = cbar.colorbar_factory(cax, mappable, **kw)
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 1274, in colorbar_factory
cb = Colorbar(cax, mappable, **kwargs)
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 877, in __init__
ColorbarBase.__init__(self, ax, **kw)
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 317, in __init__
self.draw_all()
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 342, in draw_all
self._config_axes(X, Y)
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 433, in _config_axes
self.update_ticks()
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 367, in update_ticks
ticks, ticklabels, offset_string = self._ticker()
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 580, in _ticker
ticks = self._locate(b)
  File 
"/lsst/DC3/stacks/gcc445-RH6/28nov2011/Linux64/external/matplotlib/1.3.1+
1/lib/python/matplotlib-1.3.1-py2.7-linux-x86_64.egg/matplotlib/colorbar.
py", line 829, in _locate
z = np.take(y, i0) + (xn - np.take(b, i0)) * dy / db
FloatingPointError: invalid value encountered in divide

Where masked_value_array=[-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
-- -- -- -- -- -- -- -- -- --
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
--
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
--
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 0.7598040968345164 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
--
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
--
 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
--]


--
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing 
conversations that shape the rapidly evolving mobile landscape. Sign up now. 
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users