r - 如何使用 ggplot 更改组图例顺序
问题描述
我画了一个折线图。该图有 3 个组。我想更改 Legend 组的顺序。这是我的脚本
dummy_plot = ggplot(data = dataplot , aes(x = factor(indexsampling),group = method)) +
geom_line(aes( y = value,linetype = method,color=method),size=1)+
geom_point(aes( y = value,shape=method,color=method))+
theme(plot.title = element_text(hjust = 0.5),
text = element_text(size=20),
axis.text=element_text(size=18),
legend.text=element_text(size=18),
legend.title=element_blank(),
legend.position = c(1, 0.5),
legend.justification = c(1, 0),
legend.background = element_rect(fill=alpha('white', 0.0))
)+
labs(title = title_name ,x = xlabel,y=ylabel,fill="")+
scale_linetype_manual(values=c("dotted", "twodash","solid"))+
scale_x_discrete( labels = c('0.625',"0.500","0.333","0.288"))+
scale_y_continuous(limits = c(0.2,0.62))
我想将标签更改为“LC: Exp”、“LC: Cubic”和“Max”。请建议我。
解决方案
推荐阅读
- sql - 更新表并添加新的主索引列
- arrays - 当公式似乎在 excel 中按预期执行时,为什么数组括号不可见?
- sql - 如何检查唯一列是否尚未包含正在插入的数据,以防止错误
- python - 重新编译是否会重置模型的权重?
- python-3.x - 使用 CustomJS 更新 Bokeh 源
- mysql - MySQL:如何并排显示列名和行字段值
- google-cloud-platform - 如何在 Google Cloud AI Platform 中的 Jupyter notebook 上使用 GPU
- android - 动态recyclerView Android kotlin
- c# - 如何根据首次激活的地区将应用程序设置为默认语言
- javascript - Express GET 路由无法识别