Hi Phil,

phils, on 2012-02-04 07:41,  wrote:
> Newbie to using matplotlib

welcome to the party :)
 
> Is it possible to use wx and have a window with say 2 buttons on where when
> clicking on either button a different graph will appear using a different
> data set. Any examples?

Yes, it's possible. Here's a modified version of
examples/event_handling/keypress_demo.py which toggles between
two different axes when you press the 'w' key on your keyboard:
one has green points connected by dashed lines, the other with
multi-colored multi-sized scatter data.
--------
import numpy as np
import matplotlib.pyplot as plt

plt.close('all')
def press(event):
    print('press', event.key)
    if event.key=='w':
        visible = ax.get_visible()
        ax.set_visible(not visible)
        ax2.set_visible(visible)
        fig.canvas.draw()

fig = plt.figure()
ax = fig.add_axes([.1,.1,.8,.8], label='one')
ax2 = fig.add_axes([.1,.1,.8,.8], label='two')
ax2.set_visible(False)

fig.canvas.mpl_connect('key_press_event', press)

ax.plot(np.random.rand(12), np.random.rand(12), 'go--')
ax2.scatter(100*np.random.rand(12), 100*np.random.rand(12),
        c=np.random.rand(12), s=np.random.rand(12)*100)

plt.show()
--------

I don't want to take away all of your fun, so have a look at
adding (mouse clickable) buttons to this using either
examples/widgets/buttons.py or examples/widgets/radio_buttons.py
- depending on your preference.

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

------------------------------------------------------------------------------
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

Reply via email to