How to overlay two graphs that will have different scales for the y-axes?
book
Article ID: KB0080932
calendar_today
Updated On:
Products
Versions
Spotfire S+
All supported versions
Description
Customer wants to overlay two graphs that will have different scales for the y-axes. How can that be accomplished?
Environment
Product: TIBCO Spotfire S+
Version: All supported versions
OS: All supported operating systems
--------------------
Resolution
Here is some sample code that demonstrates how to handle two y-axis scales:
##########
#Overlay graphs with different y-axes
# Creating some data to plot x <- 1:10 y1 <- rnorm(10,10) y2 <- rnorm(10,100)
# Pass in margins par(mar=c(5,4,4,4)+0.1)
# Plot the first graph plot(x,y1,type="l")
# Allow for a second plot on the graphsheet par(new=T)
# Plot the second graph # suppressing axes (axes=F) # and no labels (xlab="" and ylab="") # also changing color (col=6) plot(x,y2,type="l",col=6,axes=F,xlab="",ylab="")
# Add an axis on the right side axis(4)
# Add the right side y-axis label mtext("y2",side=4,line=2.5,col=6)
##########
You can read more about any of the functions used above by typing a question mark followed by the function name at your S+ command prompt. For example:
> ?axis > ?par
Issue/Introduction
How to overlay two graphs that will have different scales for the y-axes?