Hello to everybody,
since I looked serveral days in vain to find a solution to my problem, I would like to ask you for help!
Problem:
I want to plot at least three timeseries in one chart. Two timeseries are to be plotted as lines in a normal scale. The third timeseries (in my case these are precipitation-mesurements) are to be plotted as bars and - now the problem occurs... - this third timeseries should be scaled inversely from the top. In openoffice-Calc this function is called "reverse direction" at the scaling properties of the y-axis, even excel can handle that - so I am quite confident that matplotlib will do so, too. I just have no idea how...
Do you know how to scale an y-axis inversely (or 'reversly')?
Thank you for your help,
Simon
ps - here's my demo, perhaps it helps understanding...
···
#############################
import datetime, scipy
from pylab import *
# creating dates
date1 = datetime.date( 1982, 1, 1 )
date2 = datetime.date( 1982, 2, 1 )
date3 = datetime.date( 1982, 3, 1 )
date4 = datetime.date( 1982, 4, 1 )
dates = scipy.array([date1, date2, date3, date4])
# creating some dummy-data
f1 = [1,5,3,4] # could be a simulated discharge
f2 = [2,5,4,5] # could be an observed discharge
f3 = [45, 36, 53, 21] # could be precipitation
figure()
# creating two x-axes in one plot
ax_q = axes()
ax_p=twinx()
# plotting 'discharges'
ax_q.plot(dates, f2, 'g-', dates, f1, 'b--')
# plotting 'precipitation'
ax_p.bar(date2num(dates), f3, width=5, bottom=0)
# doing some scaling on the x-axis
months = MonthLocator(range(1,13), bymonthday=1)
monthfmt = DateFormatter("%b '%y")
ax_q.xaxis.set_major_locator(months)
ax_q.xaxis.set_major_formatter(monthfmt)
# scaling 'discharge' on the left and 'precipitation' on the right y-axis
ax_q.yaxis.tick_left()
ax_p.yaxis.tick_right()
# some other scaling ...
ax_q.yaxis.set_major_locator(MultipleLocator(5) )
show()
##########################################