I wanted to resurrect
this thread in light of some design considerations I'm going through.
Regarding multiple axes, Hadley wrote last year:
Laying the ground work for a secondary transformed axis is on my to do list for this summer.
I was wondering whether it's possible to have multiple sets of labels for the same breaks. In Andrie's code, he solves the problem of having both fahrenheit and celsius values by concatenating them. He passes farhenheit-celsius pairs as entries to the "labels" argument of scale_x_continuous:
## Andrie's Code
degC <- seq(0,100,10)
degCandF <- paste(degC,"C / ",degC * 9 / 5 + 32,"F",sep="")
d <- data.frame(tempcelcius=round(rnorm(25,15, 10), 1),attendence=rnorm(25,500, 100))
p <- qplot(x=tempcelcius,y=attendence,data=d)
p <- p + scale_x_continuous("Temperature (Celsius/Fahrenheit)",breaks=degC,labels=degCandF)
print(p)
In the code below, I create a situation—albeit a slightly nonsense one—where for international audiences it might be sensible to have converted values appear.
## My Code
set.seed(seed = 1001)
Dollars <- seq(20000, 40000, 2000)
DollarLabels <- paste("$", Dollars)
Pounds <- seq(6, 11, 1)
PoundLabels <- paste(Pounds, "lbs.")
d <- data.frame(AnnualIncome = rnorm(n = 25, mean = 30000, sd = 2500), BirthWeight = rnorm(n = 25, mean = 8, sd = 1))
p <- qplot(x = AnnualIncome, y = BirthWeight, data = d)
p <- p + scale_x_continuous("Annual Income", breaks = Dollars, labels = DollarLabels)
p <- p + scale_y_continuous("Birth Weight", breaks = Pounds, labels = PoundLabels)
print(p)
For example, the graph might be useful to international audiences if they could view it in terms of other currencies and international standard weights. In the image I've created (attached), I made up the currency and weight conversions for ease of mock-up. The key feature, though, is to assume that the major gridlines represent the same real unit of weight/money, and all I'm doing is supplying labels that respectively represent that weight/amount through a localised conversion. I don't want new breaks, just the ability to supply multiple sets of converted labels—in different positions—for the same underlying break numbers.
Does that make sense? If so, my colleague and I were wondering whether the solution might lie in either a crafty geom_text() call, or creating a modified geom based off of geom_text() to handle placing the labels. (We're not sure how we'd implement it exactly, yet.)
Alternatively, if you think there are better ways to display converted information for the same breaks, I'd love to hear your suggestions. It just seemed like having converted values on another axis was sensible. But I welcome your feedback and input!
- Brian