Re: [R] Thinking about using two y-scales on your plot?

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Thu, 03 Apr 2008 20:55:13 +1000

Allen S. Rout wrote:
> ...
> I've got a series of graphs I generate in R to illustrate backup
> activity. These are scaled, primarily, in bytes. But different
> activities have different costs per byte, and I augment the bytes
> scale with dollars.
>
> http://docs.osg.ufl.edu/tsm/current/ext/UFEXCH-MBX01.AD.UFL.EDU-all.html
>
> So the blue series corresponds to tbe blue dollars scale (and bytes)
> and the green and red points correspond to the green scale (and
> bytes).
>
> Am I being naughty?
>
Hi Allen,
If misleading someone is naughty, I guess we've all done that... The difficulty you have is the visual impression that the storage charges are higher than the transfer charges. You are trying to squeeze three dimensions (daily amount of information, daily cost of transfer and daily cost of storage) into two. Because the values are actually plotted against the first dimension and the cost scales are tacked on to that, only in the case where both of the latter dimensions coincide would the visual metric correspond to the numbers. Then you wouldn't have a problem, of course. I would tend to make the visual comparison on the money dimension and add supplementary axes showing the amount of information for each aspect of the cost. Here's a rough example:

# estimate the first two weeks of data
ufexch<-data.frame(transGb=
  c(450,700,200,550,550,545,550,550,195,180,555,555,550,550), storGb=c(900,1000,1020,1025,1030,1035,1045,1045,   1050,1050,1050,1055,1060,1065))
# roughly calculate dollars per day
ufexch$transdd<-ufexch$transGb/2
ufexch$stordd<-ufexch$storGb/1111
par(mar=c(5,4,4,4))
plot(c(ufexch$transdd,NA,0.2),xlim=c(1,14),ylim=c(0.2,400),col="green",   pch=2,log="y",main="Cost of backups",ylab="Dollars/day",xlab="Date",   axes=FALSE,type="b")
points(ufexch$stordd,col="blue",pch=1,type="b") box()

axis(2)
axis(1,at=1:14,labels=paste(1:14,"Feb",sep="/"))
axis(4,at=c(100,300,500),labels=c(500,800,1000),col="green")
axis(4,at=c(0.5,0.9,1.4),labels=c(500,900,1400),col="blue")
mtext("Gigabytes",4,2)
legend(6,20,c("Storage","Transfer"),pch=1:2,col=c(4,3))

Jim



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 03 Apr 2008 - 09:51:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 03 Apr 2008 - 10:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive