# Converting example from Gallery to suite X Y axis

Hello
Found the example below and looks ideal for what I want with 2 exceptions.
I want the x axis to have a time period of say 12 months and y axis no's of
USD values.
So, the data is like..
Jan 2011 100034
Feb2011 345321
Mar 2011 785434
Apr 2011 523753
May 2011 346723
etc etc

the code I found is and as a newbie tried and failed to convert .
Help appreciated

import numpy as npy
from pylab import figure, show
from matplotlib.widgets import SpanSelector

fig = figure(figsize=(8,6))

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

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

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

def onselect(xmin, xmax):
indmin, indmax = npy.searchsorted(x, (xmin, xmax))
indmax = min(len(x)-1, indmax)
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()

# set useblit True on gtkagg for enhanced performance
span = SpanSelector(ax, onselect, 'horizontal', useblit=True,
rectprops=dict(alpha=0.5, facecolor='red') )

show()

···

--
View this message in context: http://old.nabble.com/Converting-example-from-Gallery-to-suite-X-Y-axis-tp33431805p33431805.html
Sent from the matplotlib - users mailing list archive at Nabble.com.