[R] how to qplot two x-axis x1:Farenheit x2:Celsius

Rui Barradas ruipbarradas at sapo.pt
Wed Sep 12 11:25:47 CEST 2012


Hello,

Two corrections:

1. To convert from Celsius to Farenheit it's degC*1.8 + 32, not degC*1.4 
+ 32
2. The axis tick marks should be in the same _places_, but with 
different _labels_.

degC<-seq(-40,120,by=20)
plot(degC,1:9)
axis(3, at=degC, labels=degC*1.8+32)  # here
mtext("degF",3,line=2)

To the op:
according to Hadley Wickham, "It's not possible in ggplot2 because plots 
with multiple y scales are fundamentally flawed." See
http://stackoverflow.com/questions/3099219/how-to-use-ggplot2-make-plot-with-2-y-axes-one-y-axis-on-the-left-and-another

Hope this helps,

Rui Barradas

Em 12-09-2012 10:11, Jim Lemon escreveu:
> On 09/12/2012 09:29 AM, Jonas Stein wrote:
>> Hi,
>>
>> how can i plot two different x axis in a ggplot2 qplot?
>> I want to plot Farenheit and Celsius in one diagram.
>> x1:Farenheit x2:Celsius
>>
> Hi Jason,
> Here's a basic example of how to do this sort of thing.
>
> degC<-seq(-40,120,by=20)
> plot(degC,1:9)
> axis(3,at=degC*1.4+32)
> mtext("degF",3,line=2)
>
> 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.




More information about the R-help mailing list