[R] Plotting rgb proportions in R

Jim Lemon drjimlemon @ending from gm@il@com
Wed Dec 19 00:04:15 CET 2018


Hi Tasha,
I may be right off the track, but you could plot RGB proportions on a
3D plot. The easiest way I can think if would be to convert your 0-255
values to proportions:

rgb_prop<-read.table(text="Red Green Blue pct
249 158 37 56.311
249 158 68 4.319
249 158 98 0.058
249 128 7 13.965
249 128 37 12.87
188 128 37 0.029
249 128 68 0.161
188 128 68 0.015
188 98 7 0.029
219 128 7 2.773
219 128 37 2.583
188 98 68 0.058
219 128 68 0.525
249 188 37 0.876
249 188 68 1.08
219 98 7 0.482
249 188 98 0.015
249 158 7 3.852",header=TRUE)
rgb_prop$Red<-rgb_prop$Red/255
rgb_prop$Green<-rgb_prop$Green/255
rgb_prop$Blue<-rgb_prop$Blue/255
library(scatterplot3d)
scatterplot3d(rgb_prop[,1:3],cex.symbols=sqrt(rgb_prop[,4]),
 color=rgb(rgb_prop[,1],rgb_prop[,2],rgb_prop[,3]),pch=19)

then plot the RGB values on a 3D scatterplot. I have included
arguments to make the symbols the actual RGB colors that you specify
and their size proportional to the square root of the percentages.

Jim

On Wed, Dec 19, 2018 at 5:17 AM Tasha O'Hara <tasha.eileen using gmail.com> wrote:
>
> Hello,
>
> I am trying to plot specific rgb color proportions of a marine specimen in
> a stacked plot using R and I was looking for some help. I have several
> rgb proportions per specimen (an example of one is below).  I've run into
> different examples of people using vegan or grDevices. Can anyone help with
> this?
>
> Red    Green  Blue   %
> 249 158 37 56.311
> 249 158 68 4.319
> 249 158 98 0.058
> 249 128 7 13.965
> 249 128 37 12.87
> 188 128 37 0.029
> 249 128 68 0.161
> 188 128 68 0.015
> 188 98 7 0.029
> 219 128 7 2.773
> 219 128 37 2.583
> 188 98 68 0.058
> 219 128 68 0.525
> 249 188 37 0.876
> 249 188 68 1.08
> 219 98 7 0.482
> 249 188 98 0.015
> 249 158 7 3.852
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list