气泡图(ggplot)中的一些变化 [英] Some changes in a bubbleplot (ggplot)

查看:159
本文介绍了气泡图(ggplot)中的一些变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要对此图进行一些更改:



$ p $ library(ggplot2)#load ggplot2绘图程序包

x_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)))

我在问:


  1. 如何更改图例的标题?

  2. 如何给点颜色比例




  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 package

x_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:

  1. How can I change the title of the legend?
  2. 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)中的一些变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆