Product: TIBCO Spotfire®
Creating an axis "break" to span more data.
When data is clustered in a plot with a large space between clusters, it is advantageous to "break" the axis to save space in the plot.
There is no real way to create a true axis break in the S+ program. What you will need to do is create a "compressed" plot and then label it accordingly. An example follows.
##########
#Create sample data
x1 <- 1:10
x2 <- 1:10
y1 <- runif(10,80,90)
y2 <- runif(10,130,150)
my.data <- data.frame(x=c(x1,x2), y=c(y1,y2))
#Split data
temp1 <- my.data[my.data$y<=90,]
temp2 <- my.data[my.data$y>90 & my.data$y<=150,]
# compressing axis
plot(c(temp1$x,temp2$x), c(temp1$y,temp2$y-30), type="n", axes=F, ylim=c(80,120), xlab="x", ylab="y")
lines(temp1$x,temp1$y,lty=2,lwd=4,col="red")
lines(temp2$x,temp2$y-30,lty=3,lwd=3,col="blue")
axis(1)
axis.render(2, ticks=list(at=c(80,90,100,110,120)),
labels=list(at=c(80,90,100,110,120),text=c(80,90,130,140,150)), breaks=list(at=95, style="d",
width=.03, length=0.06))
box()
##########
If you were to add points to this graph you would need to adjust the y-value down to meet the adjusted scale.
Comments
0 comments
Article is closed for comments.