我试图隐藏使用ggplot2绘制的三重传奇文本。当我在ggplot中渲染图形时,图例消失了(正如我对我的代码所期望的那样)。当我以图形方式渲染图形时,图例仍然存在。我真的不希望整个传说消失,只是重复的传奇文本。有什么想法吗?我的代码在下面有一个简短的示例数据集。谢谢!
# Make data
flow = c(5000, 8000, 11000, 5500, 8500, 12000,
6500, 9500, 12500, 6000, 7000, 11000)
final = c(0.25, 0.55, 0.75, 0.25, 0.55, 0.75,
0.25, 0.55, 0.75, 0.25, 0.55, 0.75)
rank50c = c("Rank1", "Rank1", "Rank1", "Rank2", "Rank2", "Rank2",
"Rank3", "Rank3", "Rank3", "Obs", "Obs", "Obs")
plotly.data <- data.frame(flow, final, rank50c)
# Plot it
p <- ggplot(data = plotly.data, aes(x = final, y = flow, colour = rank50c,
size = rank50c, linetype = rank50c)) +
geom_line() +
xlab("Probability") + ylab("Annual Flow (ML)") + # Set axis labels
ggtitle("Flow") + #Set title
theme_bw() +
theme(plot.margin = unit(c(1, 2, 1, 1.5), "cm")) +
scale_size_manual(values = c(2, rep(0.5, 3)),
guide = "none") + #name = "Legend size",
scale_colour_manual(values=c("#000000", "#3333FF","#1414ff", "#2727ff"),
guide = "none") + #name = "Legend col"
scale_linetype_manual(values = c("solid", rep("dotted", 3)),
guide = "none") #name = "Legend line",
ggplotly(p)
#p #plotting in ggplot works fine