0

I have the following code:

require(ggplot2) 
require(extrafont)

loadfonts(device="pdf")

#set the x-axis now 
xaxis <- seq(0,1, by=0.01)

#set the functions here 
aij <- sqrt(1 - (1-xaxis)**1.02)
bij <- 1 - (1 - xaxis)**1.50
cij <- aij - bij 

ggplot(transform(stack(data.frame(aij, bij, cij)), x = xaxis), 
       aes(x = x, y = values, linetype = ind)) +
  geom_line() + 
  theme_bw() + 
  xlab("x ratio") + 
  ylab("Function values") + 
  theme(text=element_text(family="Times New Roman", face="bold", size=12), 
        legend.title = element_blank()) + 
  scale_linetype_manual(values = c("solid", "dashed", "dotted"))

I wish to have cij plotted in the second axis. How would that be possible?

Indian
  • 977
  • 3
  • 12
  • 24
  • 1
    If you want to use a second y axis for cij, that will not be possible with ggplo2. See https://stackoverflow.com/questions/3099219/how-to-use-ggplot2-make-plot-with-2-y-axes-one-y-axis-on-the-left-and-another – talat Dec 31 '14 at 08:54
  • You probably need to use the `ggvis` package to do that. – LyzandeR Dec 31 '14 at 10:32

0 Answers0