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 )
如图,我已设置了离散点颜色渐变,现在想单独显示蓝色拟合线条的图例,但是不知改如何修改,求教各位
相似问题