R散点图与十六进制颜色 [英] R scatter plot with hexadecimal colors

查看:160
本文介绍了R散点图与十六进制颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个CSV文件,其中包含3列,X值,Y值及其对应的十六进制(#RRGGBB)值。我一直在试图创建一个散点/气泡图,气泡的内部根据十六进制值着色。

I've got a CSV file with 3 columns, the X values, Y values, and their corresponding hexadecimal (#RRGGBB) values. I've been trying to create a scatter/bubble plot with the insides of the bubbles colored according to the hex values.

symbols(year, logtrans, circles=size, inches=0.05, bg=intel2$HexLogClock)

intel2 $ HexLogClock包含十六进制值。

intel2$HexLogClock contains the hex values.

对于noob问题再次抱歉,任何帮助都是非常感激。

Sorry again for the noob question, any help is appreciated.

推荐答案

p>我认为你的麻烦可能在于十六进制值不是一个字符。确保他们是第一。请参阅以下示例:

I think your trouble may lie in the hex values not being a character. Make sure they are first. See example below:

year <- 1:5
logtrans <- log(year)
size <- rep(15,5)
intel2 <- data.frame(HexLogClock=c("#330000", "#FFFFCC", "#660000", "#FF0000", "#00FF00"),stringsAsFactors=FALSE)
symbols(year, logtrans, circles=size, inches=0.05, bg=intel2$HexLogClock)

请注意 stringsAsFactors = FALSE 代码,您可以为 read.csv

Notice the stringsAsFactors=FALSE code, which you can specify for read.csv and other import methods to ensure your character data isn't converted to a factor.

您可以使用以下方式为您的数据执行此操作:

You can do this for your data using:

intel2$HexLogClock <- as.character(intel2$HexLogClock)

这篇关于R散点图与十六进制颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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