按因子更改晶格图的默认颜色 [英] Changing default colours of a lattice plot by factor

查看:64
本文介绍了按因子更改晶格图的默认颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够使用点阵中的cloud函数创建3D图,但是我不知道如何将点的颜色更改为除红色和黑色的默认设置以外的一个因数. 如何更改点和添加回归到云图(使用R)?这个问题解决了类似的问题,但我仍然不知道如何更改默认颜色.我怎样才能做到这一点?我想做的是将因子级别1和2的点的颜色分别更改为灰色和黑色.另外,以下两种绘图格式之间是否有区别?

I have been able to create a 3D plot using the cloud function in lattice, however I do not know how to change the colour of points to a factor apart from the default setting of red and black. How to change points and add a regression to a cloudplot (using R)? this question addressed a similar point but I still do not know how to change the default colors. How can I achieve this? What I would like to do is change the colors of the points to grey and black for factor levels 1 and 2, respectively. Also, is there a difference between the two plot formats below?

df <- as.data.frame(matrix(sample(0:20, 3*10, replace=TRUE), ncol=3))
factor <- as.factor(rep(1:2,each = 5))
df <- cbind(df,factor)
library(lattice)
cloud(V3~V1+V2, data = df, pch= 19, #method 1 - red and black filled in points
  col.point = df$factor)
cloud(V3 ~ V1+V2, groups=factor, data=df )#method 2 - open blue and pink points

推荐答案

颜色由当前主题的superpose.symbol设置确定.您可以使用par.settings=参数更改呼叫设置.例如

The colors are determined by the superpose.symbol settings of the current theme. You can change the setting for a call with the par.settings= parmameter. For example

cloud(V3 ~ V1+V2, groups=factor, data=df, 
    par.settings=list(superpose.symbol=list(col=c("grey","black"))) , auto.key=TRUE)

这将返回

这篇关于按因子更改晶格图的默认颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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