本文介绍了气泡图(ggplot)中的一些变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我需要对此图进行一些更改: $ p $ library(ggplot2)#load ggplot2绘图程序包 x_var y_var size_var df.test_data< - data.frame(x_var,y_var,size_var)' ggplot(data = df.test_data,aes(x = x_var,y = y_var))+ geom_point(aes(size =(size_var))) 我在问: 如何更改图例的标题? 如何给点颜色比例 ggplot(data = dfx.test_data,aes(aes(>))解决方案 x = x_var,y = y_var))+ geom_point(aes(si ze =(size_var),color = size_var))+ scale_color_gradient(low =yellow,high =red)+ labs(color =NEW TITLE) I need some changes to this plot:library(ggplot2) # load ggplot2 plotting packagex_var <- rnorm( n = 15, mean = 5, sd = 2)y_var <- x_var + rnorm(n = 15, mean = 5, sd =4)size_var <- runif(15, 1,10)df.test_data <- data.frame(x_var, y_var, size_var)'ggplot(data=df.test_data, aes(x=x_var, y=y_var)) + geom_point(aes(size=(size_var))) I'm asking:How can I change the title of the legend?How can I give to the points a color scale that changes with the value of the point (from yellow to red, yellow for values near to 2, red for values near to 7) 解决方案 Is that what you want?ggplot(data=dfx.test_data, aes(x=x_var, y=y_var)) +geom_point(aes(size=(size_var),color=size_var))+scale_color_gradient(low="yellow", high="red")+labs(colour="NEW TITLE") 这篇关于气泡图(ggplot)中的一些变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 15:46