Re: [Matplotlib-users] key_press_events on macosx

2013-06-05 Thread Scott Lasley
I have python 3.3.2 from python.org installed as a Framework.  I set up a 
virtualenv to test the script 
$ virtualenv-3.3 mpl121 --no-site-packages
$ .mpl121/bin/activate
$ pip-3.3 install numpy
$ pip-3.3 install matplotlib
With this setup, key events are passed to the window behind the active plot 
window and no event is printed by the test script.  Mouse clicks in the plot 
window do cause the script to print out the event.  I even tried installing 
1.4.x into the virtualenv with
$ pip-3.3 install 
git+https://github.com/matplotlib/matplotlib.git#egg=matplotlib
The key events were not printed out by the script.

I tried creating a different virtualenv using --system-site-packages and the 
script failed to detect key events.

If I deactivate the virtualenvs and run the script with 
matplotlib-1.4.x-py3.3-macosx-10.6-intel.egg in 
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/
the key events are printed by the script.

I'm not sure why using matplotlib from a virtualenv causes the key events to be 
ignored in my setup.  I should have stated in my first reply that I used a 
virtualenv to test 1.2.1 and 1.3.0rc2 but not 1.4.x.

Scott


On Jun 5, 2013, at 7:49 PM, Michiel de Hoon  wrote:

> The script works for me with matplotlib-1.2.1 both with Python2 and with 
> Python3 with the MacOSX backend.
> To rule out the usual culprit, is your Python3 installed as a framework?
> 
> Best,
> -MIchiel.
> 
> 
> - Original Message -
> From: Scott Lasley 
> To: "matplotlib-users@lists.sourceforge.net" 
> 
> Cc: 
> Sent: Thursday, June 6, 2013 4:50 AM
> Subject: Re: [Matplotlib-users] key_press_events on macosx
> 
> 
> On Jun 5, 2013, at 2:51 PM, Matt Terry  wrote:
> 
>> Hi,
>> I'm working on a TextBox widget and have run into problems registering 
>> key_press_events with the macosx backend.  button_press_events work, but 
>> key_press_events fail to trigger.  If I change backends to tkAgg, everything 
>> triggers as expected.
>> 
>> Can anyone reproduce this?
>> Run the following script; click the figure and bang on the keyboard.  Mouse 
>> clicks and keyboard clicks should echo on the screen.  I'm using mpl 1.2.1 
>> with Anaconda.
>> 
>> -matt
>> 
>> import pylab as plt
>> plt.switch_backend('macosx')
>> 
>> 
>> def print_event(event):
>>  print 'event', event
>> 
>> ax = plt.subplot(111)
>> fig = ax.figure
>> 
>> x = range(10)
>> ax.plot(x, x)
>> # mouse clicks work on tkAgg & macosx
>> fig.canvas.mpl_connect('button_press_event', print_event)
>> # key presses only work on tkAgg
>> fig.canvas.mpl_connect('key_press_event', print_event)
>> 
>> plt.show()
> 
> key_press_events in the script fail on my mac running OS X 10.8, python 3.3.2 
> from python.org and with both matplotlib 1.2.1 installed with pip and 
> matplotlib-1.3.0rc2 from the matplotlib.org download page
> 
> They do work with the latest matplotlib 1.4 from github
> 
> hth,
> Scott



--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] key_press_events on macosx

2013-06-05 Thread Matt Terry
I've only tested against the prepackaged python 2.7, mpl 1.2.1 in an
anaconda install. Anaconda is not a framework build.
On Jun 5, 2013 4:50 PM, "Michiel de Hoon"  wrote:

> The script works for me with matplotlib-1.2.1 both with Python2 and with
> Python3 with the MacOSX backend.
> To rule out the usual culprit, is your Python3 installed as a framework?
>
> Best,
> -MIchiel.
>
>
>
>
>
> - Original Message -
> From: Scott Lasley 
> To: "matplotlib-users@lists.sourceforge.net" <
> matplotlib-users@lists.sourceforge.net>
> Cc:
> Sent: Thursday, June 6, 2013 4:50 AM
> Subject: Re: [Matplotlib-users] key_press_events on macosx
>
>
> On Jun 5, 2013, at 2:51 PM, Matt Terry  wrote:
>
> > Hi,
> > I'm working on a TextBox widget and have run into problems registering
> key_press_events with the macosx backend.  button_press_events work, but
> key_press_events fail to trigger.  If I change backends to tkAgg,
> everything triggers as expected.
> >
> > Can anyone reproduce this?
> > Run the following script; click the figure and bang on the keyboard.
> Mouse clicks and keyboard clicks should echo on the screen.  I'm using mpl
> 1.2.1 with Anaconda.
> >
> > -matt
> >
> > import pylab as plt
> > plt.switch_backend('macosx')
> >
> >
> > def print_event(event):
> > print 'event', event
> >
> > ax = plt.subplot(111)
> > fig = ax.figure
> >
> > x = range(10)
> > ax.plot(x, x)
> > # mouse clicks work on tkAgg & macosx
> > fig.canvas.mpl_connect('button_press_event', print_event)
> > # key presses only work on tkAgg
> > fig.canvas.mpl_connect('key_press_event', print_event)
> >
> > plt.show()
>
> key_press_events in the script fail on my mac running OS X 10.8, python
> 3.3.2 from python.org and with both matplotlib 1.2.1 installed with pip
> and matplotlib-1.3.0rc2 from the matplotlib.org download page
>
> They do work with the latest matplotlib 1.4 from github
>
> hth,
> Scott
>
> --
> How ServiceNow helps IT people transform IT departments:
> 1. A cloud service to automate IT design, transition and operations
> 2. Dashboards that offer high-level views of enterprise services
> 3. A single system of record for all IT processes
> http://p.sf.net/sfu/servicenow-d2d-j
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
> --
> How ServiceNow helps IT people transform IT departments:
> 1. A cloud service to automate IT design, transition and operations
> 2. Dashboards that offer high-level views of enterprise services
> 3. A single system of record for all IT processes
> http://p.sf.net/sfu/servicenow-d2d-j
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] key_press_events on macosx

2013-06-05 Thread Michiel de Hoon
The script works for me with matplotlib-1.2.1 both with Python2 and with 
Python3 with the MacOSX backend.
To rule out the usual culprit, is your Python3 installed as a framework?

Best,
-MIchiel.





- Original Message -
From: Scott Lasley 
To: "matplotlib-users@lists.sourceforge.net" 

Cc: 
Sent: Thursday, June 6, 2013 4:50 AM
Subject: Re: [Matplotlib-users] key_press_events on macosx


On Jun 5, 2013, at 2:51 PM, Matt Terry  wrote:

> Hi,
> I'm working on a TextBox widget and have run into problems registering 
> key_press_events with the macosx backend.  button_press_events work, but 
> key_press_events fail to trigger.  If I change backends to tkAgg, everything 
> triggers as expected.
> 
> Can anyone reproduce this?
> Run the following script; click the figure and bang on the keyboard.  Mouse 
> clicks and keyboard clicks should echo on the screen.  I'm using mpl 1.2.1 
> with Anaconda.
> 
> -matt
> 
> import pylab as plt
> plt.switch_backend('macosx')
> 
> 
> def print_event(event):
>     print 'event', event
> 
> ax = plt.subplot(111)
> fig = ax.figure
> 
> x = range(10)
> ax.plot(x, x)
> # mouse clicks work on tkAgg & macosx
> fig.canvas.mpl_connect('button_press_event', print_event)
> # key presses only work on tkAgg
> fig.canvas.mpl_connect('key_press_event', print_event)
> 
> plt.show()

key_press_events in the script fail on my mac running OS X 10.8, python 3.3.2 
from python.org and with both matplotlib 1.2.1 installed with pip and 
matplotlib-1.3.0rc2 from the matplotlib.org download page

They do work with the latest matplotlib 1.4 from github

hth,
Scott
--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] key_press_events on macosx

2013-06-05 Thread Scott Lasley

On Jun 5, 2013, at 2:51 PM, Matt Terry  wrote:

> Hi,
> I'm working on a TextBox widget and have run into problems registering 
> key_press_events with the macosx backend.  button_press_events work, but 
> key_press_events fail to trigger.  If I change backends to tkAgg, everything 
> triggers as expected.
> 
> Can anyone reproduce this?
> Run the following script; click the figure and bang on the keyboard.  Mouse 
> clicks and keyboard clicks should echo on the screen.  I'm using mpl 1.2.1 
> with Anaconda.
> 
> -matt
> 
> import pylab as plt
> plt.switch_backend('macosx')
> 
> 
> def print_event(event):
> print 'event', event
> 
> ax = plt.subplot(111)
> fig = ax.figure
> 
> x = range(10)
> ax.plot(x, x)
> # mouse clicks work on tkAgg & macosx
> fig.canvas.mpl_connect('button_press_event', print_event)
> # key presses only work on tkAgg
> fig.canvas.mpl_connect('key_press_event', print_event)
> 
> plt.show()

key_press_events in the script fail on my mac running OS X 10.8, python 3.3.2 
from python.org and with both matplotlib 1.2.1 installed with pip and 
matplotlib-1.3.0rc2 from the matplotlib.org download page

They do work with the latest matplotlib 1.4 from github

hth,
Scott
--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Graphics issues when combining matplotlib widgets: Spanselector, cursor, fill_between:

2013-06-05 Thread Delosari
Hi, I have found minor graphical issues while using the spanselector, cursor
and fill_between widgets, which I would like to share with you.

All of them, can be experienced in this code (which I took from the
matplolib example)

"""
The SpanSelector is a mouse widget to select a xmin/xmax range and plot the
detail view of the selected region in the lower axes
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import SpanSelector
import matplotlib.widgets as widgets

Fig = plt.figure(figsize=(8,6))
Fig.set_facecolor('w')
Fig.set
Ax = Fig.add_subplot(211)


x = np.arange(0.0, 5.0, 0.01)
y = np.sin(2*np.pi*x) + 0.5*np.random.randn(len(x))

Ax.plot(x, y, '-')
Ax.set_ylim(-2,2)
Ax.set_title('Press left mouse button and drag to test')

RegionIndices = []

ax2 = Fig.add_subplot(212)
line2, = ax2.plot(x, y, '-')


def onselect(xmin, xmax):
if len(RegionIndices) == 2:
Ax.fill_between(x[:], 0.0, y[:],facecolor='White',alpha=1)
del RegionIndices[:]


indmin, indmax = np.searchsorted(x, (xmin, xmax))
indmax = min(len(x)-1, indmax)

Ax.fill_between(x[indmin:indmax], 0.0,
y[indmin:indmax],facecolor='Blue',alpha=0.30)

thisx = x[indmin:indmax]
thisy = y[indmin:indmax]
line2.set_data(thisx, thisy)
ax2.set_xlim(thisx[0], thisx[-1])
ax2.set_ylim(thisy.min(), thisy.max())
Fig.canvas.draw()

RegionIndices.append(xmin)
RegionIndices.append(xmax)

# set useblit True on gtkagg for enhanced performance
span = SpanSelector(Ax, onselect, 'horizontal', useblit =
True,rectprops=dict(alpha=0.5, facecolor='purple') )
cursor = widgets.Cursor(Ax, color="red", linewidth = 1, useblit = True)

plt.show()

I wonder if there is some way to avoid these two small issues:

1) You can see that when you select a region the spanselector box (purple)
glitches. In this code the effect is barely noticeable but on plots with
many lines is quite annoying (I have tried all the trueblit combinations to
not effect)

2) In this code when you select a region, the area in the upper plot between
the line and the horizontal axis is filled in blue. When you select a new
region the old area is filled in white (to clear it) and the new one is
filled with blue again. However, when I do that the line plotted, as well
as, the horizontal axis, become thicker... Is there a way to clear such a
region (generated with fill_between) without this happening... Or is it
necessary to replot the graph? Initially, I am  against doing this since I
have a well structured code and importing all the data again into the
spanselector method seems a bit messy... Which is the right way in python to
delete selected regions of a plot?

Any advice would be most welcome




--
View this message in context: 
http://matplotlib.1069221.n5.nabble.com/Graphics-issues-when-combining-matplotlib-widgets-Spanselector-cursor-fill-between-tp41212.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] key_press_events on macosx

2013-06-05 Thread Matt Terry
Hi,
I'm working on a TextBox widget and have run into problems registering
key_press_events with the macosx backend.  button_press_events work, but
key_press_events fail to trigger.  If I change backends to tkAgg,
everything triggers as expected.

Can anyone reproduce this?
Run the following script; click the figure and bang on the keyboard.  Mouse
clicks and keyboard clicks should echo on the screen.  I'm using mpl 1.2.1
with Anaconda.

-matt

import pylab as plt
plt.switch_backend('macosx')


def print_event(event):
print 'event', event

ax = plt.subplot(111)
fig = ax.figure

x = range(10)
ax.plot(x, x)
# mouse clicks work on tkAgg & macosx
fig.canvas.mpl_connect('button_press_event', print_event)
# key presses only work on tkAgg
fig.canvas.mpl_connect('key_press_event', print_event)

plt.show()
--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] time series

2013-06-05 Thread Sudheer Joseph
Thank you Verymuch for quick help,Paul.
with best regards,
Sudheer
From: Paul Hobson 
>To: Sudheer Joseph  
>Cc: "matplotlib-users@lists.sourceforge.net" 
> 
>Sent: Wednesday, 5 June 2013 9:57 PM
>Subject: Re: [Matplotlib-users] time series
> 
>
>
>On Wed, Jun 5, 2013 at 9:13 AM, Sudheer Joseph  
>wrote:
>
>Dear Users,
>>                 Is there any other method in matplotlib to get the plot 
>>similar to the one there in below link?
>>
>>
>>http://dsnra.jpl.nasa.gov/software/Python/scikits/lib.plotting.examples.html
>>I tried using this package but get below error.
>>
>>
>>sjo@sjo-ltp../hourly_rama~$ python ts.py 
>>Traceback (most recent call last):
>>  File "ts.py", line 12, in 
>>    fsp = fig.add_tsplot(111)
>>  File 
>>"/usr/local/lib/python2.7/dist-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg/scikits/timeseries/lib/plotlib.py",
>> line 1284, in add_tsplot
>>    return add_generic_subplot(self, *args, **kwargs)
>>  File 
>>"/usr/local/lib/python2.7/dist-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg/scikits/timeseries/lib/plotlib.py",
>> line 177, in add_generic_subplot
>>    if key in figure_instance._seen:
>>AttributeError: 'TimeSeriesFigure' object has no attribute '_seen'
>>
>>
>>
>>
>>
>>import numpy as np
>>import matplotlib.pyplot as plt
>>import scikits.timeseries as ts
>>import scikits.timeseries.lib.plotlib as tpl
>>from scikits.timeseries.lib.moving_funcs import mov_average_expw
>>
>>
>># generate some random data
>>data = np.cumprod(1 + np.random.normal(0, 1, 300)/100)
>>series = ts.time_series(data,
>>                       start_date=ts.Date(freq='M', year=1982, month=1))
>>fig = tpl.tsfigure()
>>fsp = fig.add_tsplot(111)
>>fsp.tsplot(series, '-', mov_average_expw(series, 40), 'r--')
>>plt.show()
>>
>>
>
>
>Pandas has excellent time series handling and plotting capabilities. 
>http://pandas.pydata.org/pandas-docs/stable/timeseries.html
>
>http://pandas.pydata.org/pandas-docs/stable/visualization.html
>
>
>--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] time series

2013-06-05 Thread Paul Hobson
On Wed, Jun 5, 2013 at 9:13 AM, Sudheer Joseph wrote:

> Dear Users,
>  Is there any other method in matplotlib to get the plot
> similar to the one there in below link?
>
>
> http://dsnra.jpl.nasa.gov/software/Python/scikits/lib.plotting.examples.html
> I tried using this package but get below error.
>
> sjo@sjo-ltp../hourly_rama~$ python ts.py
> Traceback (most recent call last):
>   File "ts.py", line 12, in 
> fsp = fig.add_tsplot(111)
>   File
> "/usr/local/lib/python2.7/dist-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg/scikits/timeseries/lib/plotlib.py",
> line 1284, in add_tsplot
> return add_generic_subplot(self, *args, **kwargs)
>   File
> "/usr/local/lib/python2.7/dist-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg/scikits/timeseries/lib/plotlib.py",
> line 177, in add_generic_subplot
> if key in figure_instance._seen:
> AttributeError: 'TimeSeriesFigure' object has no attribute '_seen'
>
> 
>
> import numpy as np
> import matplotlib.pyplot as plt
> import scikits.timeseries as ts
> import scikits.timeseries.lib.plotlib as tpl
> from scikits.timeseries.lib.moving_funcs import mov_average_expw
>
> # generate some random data
> data = np.cumprod(1 + np.random.normal(0, 1, 300)/100)
> series = ts.time_series(data,
>start_date=ts.Date(freq='M', year=1982, month=1))
> fig = tpl.tsfigure()
> fsp = fig.add_tsplot(111)
> fsp.tsplot(series, '-', mov_average_expw(series, 40), 'r--')
> plt.show()
>
>
Pandas has excellent time series handling and plotting capabilities.
http://pandas.pydata.org/pandas-docs/stable/timeseries.html
http://pandas.pydata.org/pandas-docs/stable/visualization.html
--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] time series

2013-06-05 Thread Sudheer Joseph
Dear Users,
                 Is there any other method in matplotlib to get the plot 
similar to the one there in below link?

http://dsnra.jpl.nasa.gov/software/Python/scikits/lib.plotting.examples.html

I tried using this package but get below error.


sjo@sjo-ltp../hourly_rama~$ python ts.py 
Traceback (most recent call last):
  File "ts.py", line 12, in 
    fsp = fig.add_tsplot(111)
  File 
"/usr/local/lib/python2.7/dist-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg/scikits/timeseries/lib/plotlib.py",
 line 1284, in add_tsplot
    return add_generic_subplot(self, *args, **kwargs)
  File 
"/usr/local/lib/python2.7/dist-packages/scikits.timeseries-0.91.3-py2.7-linux-x86_64.egg/scikits/timeseries/lib/plotlib.py",
 line 177, in add_generic_subplot
    if key in figure_instance._seen:
AttributeError: 'TimeSeriesFigure' object has no attribute '_seen'



import numpy as np
import matplotlib.pyplot as plt
import scikits.timeseries as ts
import scikits.timeseries.lib.plotlib as tpl
from scikits.timeseries.lib.moving_funcs import mov_average_expw

# generate some random data
data = np.cumprod(1 + np.random.normal(0, 1, 300)/100)
series = ts.time_series(data,
                       start_date=ts.Date(freq='M', year=1982, month=1))
fig = tpl.tsfigure()
fsp = fig.add_tsplot(111)
fsp.tsplot(series, '-', mov_average_expw(series, 40), 'r--')
plt.show()


 
***
Sudheer Joseph 
Indian National Centre for Ocean Information Services
Ministry of Earth Sciences, Govt. of India
POST BOX NO: 21, IDA Jeedeemetla P.O.
Via Pragathi Nagar,Kukatpally, Hyderabad; Pin:5000 55
Tel:+91-40-23886047(O),Fax:+91-40-23895011(O),
Tel:+91-40-23044600(R),Tel:+91-40-9440832534(Mobile)
E-mail:sjo.in...@gmail.com;sudheer.jos...@yahoo.com
Web- http://oppamthadathil.tripod.com
***--
How ServiceNow helps IT people transform IT departments:
1. A cloud service to automate IT design, transition and operations
2. Dashboards that offer high-level views of enterprise services
3. A single system of record for all IT processes
http://p.sf.net/sfu/servicenow-d2d-j___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users