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 contains the hex values.
Sorry again for the noob question, any help is appreciated.
I imagine
intel2$HexLogClock
is stored as afactor
. Confirm this withclass(intel2$HexLogClock)
. In this case, each level of the factor is represented by an integer (which is assigned based on the order of factor level's first occurrences), so your firstHexLogClock
color will be black (1=black), then red, then green, blue, cyan, and so on.To correct this, you need to convert
intel2$HexLogClock
to a character vector, thusly:after which your command should work as you had expected.
Alternatively:
I think your trouble may lie in the hex values not being a character. Make sure they are first. See example below:
Notice the
stringsAsFactors=FALSE
code, which you can specify forread.csv
and other import methods to ensure your character data isn't converted to a factor.You can do this for your data using:
I think I'm misunderstanding, if so let me know but you can just supply the hexadecimal values to
col
as in: