I like to plot simple time series data and overplot precipitation data. The following code plots a line for the usual data and adds barplots (or histogram bars) for the precipitation data.
D # a simple (zoo) time series
P # a simple (zoo) time series of precipitation
plot(D, type="l")
lines(P, type="h", lwd=5)
But the bars are based on the y=0 axis and rise topwards. But usual in hydrology are precipitation bars that are based on the very top axis and "flow" downwards. D
has arbitrary y-ranges, so I would prefer a solution that does fix a value for the baseline of P
.
I googled a lot but did not manage to find how to do this in R without ggplot and without extra packages like hydrograph.