更改ggplot2中用于scale_shape()的形状 [英] Changing shapes used for scale_shape() in ggplot2

查看:3608
本文介绍了更改ggplot2中用于scale_shape()的形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有以下几个元素:

  y < -  rnorm(10)
b < - as.factor (样本(1:4,10,replace = T))
qplot(1:10,y,shape = b)

如何使用 ggplot2

更改形状解决方案使用ggplot的方法是使用 scale_shape_manual 并在值中提供所需的形状参数:

  qplot(1:10,y,shape = b)+ scale_shape_manual(values = c(0 ,5,6,15))



形状与通常的0-25索引相同: http://yusung.blogspot.com/2008/11/plot-symbols-in-r.html a>


Suppose I have the following

y <- rnorm(10)
b <- as.factor(sample(1:4,10,replace=T))
qplot(1:10, y, shape=b)

How do I change the shapes that are used using ggplot2?

解决方案

The ggplot way to do it would be to use scale_shape_manual and provide the desired shapes in the values argument:

qplot(1:10, y, shape=b) + scale_shape_manual(values = c(0, 5, 6, 15))

The shapes are the same as the usual 0-25 indexes: http://yusung.blogspot.com/2008/11/plot-symbols-in-r.html

这篇关于更改ggplot2中用于scale_shape()的形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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