I am trying to plot the data using two y axis.
p <- ggplot(mydf, aes(x = pos)) +
geom_line(aes(y = data1, colour="data1")) +
geom_line(aes(y = data2, colour="data2")) +
scale_y_continuous(limits = c(0.40, 0.90), breaks=c(0.40, 0.050, 0.60, 0.70, 0.80, 0.90), sec.axis = sec_axis(~., name = "data1")) +
labs(y = "freq",
x = "position",
colour = "") +
scale_colour_hue(labels = c("data1",
"data2"),
l = 40) +
ggtitle("title of the plot") +
theme_bw() +
theme(text=element_text(size=8)) +
theme(plot.title = element_text(hjust = 0.5, size =8)) +
theme(legend.direction = "horizontal", legend.position = "bottom", legend.box = "vertical")
plot(p)
The first y axis values range from 0.40-0.90
, che second y axis values range rom 0.50-0.60
.
How to adjust the plot?
pos data1 data2
1 0.9 0.6
2 0.8 0.6
3 0.8 0.6
4 0.7 0.6
5 0.6 0.5
6 0.5 0.5
7 0.4 0.5
mydf <- structure(list(win_mid = 88:97, emboss = c(0.8189, 0.81395, 0.818533333333333,
0.820825, 0.81846, 0.816883333333333, 0.815757142857143, 0.8149125,
0.814255555555556, 0.81373), clc = c(0.5985568621, 0.5985568621,
0.598507734833333, 0.59852001665, 0.59852738574, 0.5986134848,
0.598590549371429, 0.598623096925, 0.598573214244444, 0.59846694016
)), row.names = 76:85, class = "data.frame")