[英]ggplot2 with factor variable y axis and removed whitespace
我有一個類似下面的圖,在y軸上有一個因子變量。
library(reshape2)
library(ggplot2)
MA <- c("A", "B", "C")
dfr <- data.frame(
name = factor(MA, levels = MA),
start = 1:3,
end = 3:5,
prozent = c(1,0.5,0.75)
)
mdfr <- melt(dfr, measure.vars = c("start", "end"))
ggplot(mdfr, aes(value, name)) + geom_line(aes(size = prozent)) + scale_size_area()
我想刪除水平線之間的空白(或在默認的ggplot2中為“灰色空間”),以使它們彼此接觸。
您可以執行以下操作:
ggplot(mdfr, aes(value, name)) +
geom_line(aes(size = prozent)) +
scale_size_area() +
scale_y_discrete(expand = c(7, 0))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.