yaxis range display using absolute values rather than offset values
set useOffset to False: ax = plt.gca() ax.ticklabel_format(useOffset=False)
set useOffset to False: ax = plt.gca() ax.ticklabel_format(useOffset=False)
Get current axis via plt.gca(), and then set its limits: ax = plt.gca() ax.set_xlim([xmin, xmax]) ax.set_ylim([ymin, ymax])
First, scale Rate by Rate*max(df$Response) and modify the 0.9 scale of Response text. Second, include a second axis via scale_y_continuous(sec.axis=…): ggplot(df) + geom_bar(aes(x=Year, y=Response),stat=”identity”, fill=”tan1″, colour=”sienna3″)+ geom_line(aes(x=Year, y=Rate*max(df$Response)),stat=”identity”)+ geom_text(aes(label=Rate, x=Year, y=Rate*max(df$Response)), colour=”black”)+ geom_text(aes(label=Response, x=Year, y=0.95*Response), colour=”black”)+ scale_y_continuous(sec.axis = sec_axis(~./max(df$Response))) Which yields:
update: Copied material that was on the R wiki at http://rwiki.sciviews.org/doku.php?id=tips:graphics-base:2yaxes, link now broken: also available from the wayback machine Two different y axes on the same plot (some material originally by Daniel Rajdl 2006/03/31 15:26) Please note that there are very few situations where it is appropriate to use two different scales on the … Read more