首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >ggplot2如何单独设置拟合线条的图例?

ggplot2如何单独设置拟合线条的图例?

提问于 2020-07-24 16:00:29
回答 0关注 0查看 166
代码语言:r
复制
library(ggplot2)
f = read.csv(file = "C:/Users/Desktop/a1.csv")
plot = ggplot(f,aes(iteration,loss,colour = loss)) +
  geom_point(size = 0.01,show.legend = FALSE) +
  scale_colour_gradient(low = "green",high = "red",limits = c(0,4.5)) +
  scale_y_continuous(limits = c(0,4.5),expand = c(0,0)) +
  scale_x_continuous(limits = c(500,4200),expand = c(0,0)) +
  theme(panel.grid.major = element_blank(),panel.grid.minor = element_blank(),panel.background = element_rect(colour = "black",fill = "white",size = 0.2),axis.line = element_line(colour = "black",size = 0.2),axis.ticks = element_line(size = 0.2)) +
  theme(legend.position = "none") +
  geom_smooth(size = 0.5) +
  labs(x = "Train Steps") +
  labs(y = "Avg Loss") +
  ggtitle("Avg Loss Curve") +
  theme(plot.title = element_text(hjust = 0.5)) +
  print(plot)
  ggsave(filename = "C:/Users/Desktop/Average loss.tiff", dpi = 500 )

如图,我已设置了离散点颜色渐变,现在想单独显示蓝色拟合线条的图例,但是不知改如何修改,求教各位

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档