r - Plot two xaxis in one plot? -


this can plotted easily.

xvals <- c(5.5, 15.5, 25.5, 35.5, 45.5, 55.5, 65.5, 75.5, 85.5, 95.5) yvals <- c(81, 63, 45, 27, 9, -9, -27, -45, -63, -81) xn <- rep(1000, 10) plot(xvals, yvals) 

both xvals , xn share same yvals want plot in 1 graph:

   yaxis:    xaxis lower:xvals    xaxis upper:xn 

enter image description here

i want add xn same plot xaxis (the upper) axis(3). idea on this!

leave code plot(xvals, yvals). add following:

#plot first plot plot(xvals, yvals) #start new overlaid plot par(new=true) #plot xn remove xaxis , x label plot(xn, yvals, xaxt='n', xlab='') #add @ top of graph (3) axis(3, xn) #bonus. add line add secondary xlabel on top mtext(side = 3, line = 2, "xn") 

result:

enter image description here


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -