[英]ggplot2 Reversing secondary y axis
我正在創建一個圖形,在分數的主要y軸(縮放比例為0-5)和次要y軸PCR結果(縮放比例為0-45)上顯示兩個線圖。 但是,我需要反轉第二個y軸,以使45位於y軸的底部(45 =陰性PCR結果)。 我可以繪制次要y軸,但不知道如何反轉它。
鏈接到一些虛擬數據
https://www.filehosting.org/file/details/813109/redditexample.csv
library(data.table)
library(ggplot2)
library(lubridate)
#Read the file you want to use for a graph
data <- fread("redditexample.csv", na.strings = c("", NA))
data$V1 <- lubridate::dmy(data$V1)
plot <- ggplot(data) +
geom_line(aes(x = V1, y = AveScore, col = type)) +
geom_point(aes(x = V1, y = PCR)) +
scale_y_continuous('PCR', sec.axis = sec_axis(trans = "reverse")
也嘗試過:
scale_y_continuous('PCR', sec.axis = sec_axis(~ . *-1 + 50))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.