Plotting rgb proportions in R

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Plotting rgb proportions in R

surchin84
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting rgb proportions in R

Jeff Newmiller
I can't figure out what message you are hoping to convey in your plot from your posting... what are you comparing to what? Comments like "I've run into different examples of people using vegan (an analysis package with some diagnostic display functionality) or grDevices (a package supporting different device and graphic file formats)" fail to inform us as to where we can catch up with your reading or whether you liked what they did or not. Is there some missing analysis step or do you just want to present the raw data? Even a hand drawn sketch in PNG format would be some improvement in clarity.

Note that this is the wrong place to ask for help on theory... if you want to know what type of analysis you should attempt then you came here too soon... this is where we try to help you apply R to the problem once you know what your analysis strategy will be.

On December 18, 2018 9:17:24 AM PST, Tasha O'Hara <[hidden email]> 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]]
>
>______________________________________________
>[hidden email] 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.

--
Sent from my phone. Please excuse my brevity.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting rgb proportions in R

Jim Lemon-4
In reply to this post by surchin84
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 <[hidden email]> 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]]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting rgb proportions in R

Bert Gunter-2
3-d Proportions must sum to 1and are thus actually 2-d and should preferaby
be plotted as a ternary plot. Several r packages will do this for you, e.g.
package Ternary. Search "ternary plots" on rseek.org for others.

-- Bert


Bert Gunter

"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )


On Tue, Dec 18, 2018 at 3:10 PM Jim Lemon <[hidden email]> wrote:

> 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 <[hidden email]>
> 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]]
> >
> > ______________________________________________
> > [hidden email] 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.
>
> ______________________________________________
> [hidden email] 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.
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting rgb proportions in R

Jim Lemon-4
I was probably a bit obscure and should have written "convert your
0-255 values to 0-1". As Bert notes, you can't get a sensible ternary
plot if your values do not sum to 1. scatterplot3d does a pretty good
job, if you run the example.


Jim

On Wed, Dec 19, 2018 at 3:26 PM Bert Gunter <[hidden email]> wrote:

>
> 3-d Proportions must sum to 1and are thus actually 2-d and should preferaby be plotted as a ternary plot. Several r packages will do this for you, e.g. package Ternary. Search "ternary plots" on rseek.org for others.
>
> -- Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, Dec 18, 2018 at 3:10 PM Jim Lemon <[hidden email]> wrote:
>>
>> 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 <[hidden email]> 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]]
>> >
>> > ______________________________________________
>> > [hidden email] 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.
>>
>> ______________________________________________
>> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting rgb proportions in R

PIKAL Petr
In reply to this post by Bert Gunter-2
Hi

> -----Original Message-----
> From: R-help <[hidden email]> On Behalf Of Bert Gunter
> Sent: Wednesday, December 19, 2018 5:26 AM
> To: Jim Lemon <[hidden email]>
> Cc: R-help <[hidden email]>
> Subject: Re: [R] Plotting rgb proportions in R
>
> 3-d Proportions must sum to 1and are thus actually 2-d and should preferaby
> be plotted as a ternary plot. Several r packages will do this for you, e.g.
> package Ternary. Search "ternary plots" on rseek.org for others.

From which I would recommend ggtern. Sometimes a bit tricky but quite handy, especially when you consider some grouping.

Cheers
Petr

>
> -- Bert
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and
> sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Tue, Dec 18, 2018 at 3:10 PM Jim Lemon <[hidden email]> wrote:
>
> > 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 <[hidden email]>
> > 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]]
> > >
> > > ______________________________________________
> > > [hidden email] 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.
> >
> > ______________________________________________
> > [hidden email] 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.
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] 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.
Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních partnerů PRECHEZA a.s. jsou zveřejněny na: https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information about processing and protection of business partner’s personal data are available on website: https://www.precheza.cz/en/personal-data-protection-principles/
Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any documents attached to it may be confidential and are subject to the legally binding disclaimer: https://www.precheza.cz/en/01-disclaimer/

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting rgb proportions in R

Jim Lemon-4
Hi Tasha,
Using the original sample you sent:

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
# the matrix format forces the stacked bar display
barplot(matrix(rgb_prop$pct,ncol=1),
 col=rgb(rgb_prop[,c("Red","Green","Blue")]),beside=FALSE)

Of course you can add more stacks by increasing the number of columns in
the "x" matrix.

Jim

On Thu, Jan 3, 2019 at 3:33 AM Tasha O'Hara <[hidden email]> wrote:

> I apologize for the late reply after the holidays. I really appreciate all
> the data visualization suggestions. The scatterplot works very well, but I
> do have >400 specimen with at least 5-20 colors each, so a stacked
> barchart of each specific color proportion would be most useful to show
> uniformity within each specimen. Below is an example of what I would like
> to do, but instead of generic colors, I am hoping to plot the actual RGB
> proportions for each.
> [image: image.png]
>
> On Wed, Dec 19, 2018 at 5:28 AM PIKAL Petr <[hidden email]> wrote:
>
>> Hi
>>
>> > -----Original Message-----
>> > From: R-help <[hidden email]> On Behalf Of Bert Gunter
>> > Sent: Wednesday, December 19, 2018 5:26 AM
>> > To: Jim Lemon <[hidden email]>
>> > Cc: R-help <[hidden email]>
>> > Subject: Re: [R] Plotting rgb proportions in R
>> >
>> > 3-d Proportions must sum to 1and are thus actually 2-d and should
>> preferaby
>> > be plotted as a ternary plot. Several r packages will do this for you,
>> e.g.
>> > package Ternary. Search "ternary plots" on rseek.org for others.
>>
>> From which I would recommend ggtern. Sometimes a bit tricky but quite
>> handy, especially when you consider some grouping.
>>
>> Cheers
>> Petr
>>
>> >
>> > -- Bert
>> >
>> >
>> > Bert Gunter
>> >
>> > "The trouble with having an open mind is that people keep coming along
>> and
>> > sticking things into it."
>> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>> >
>> >
>> > On Tue, Dec 18, 2018 at 3:10 PM Jim Lemon <[hidden email]> wrote:
>> >
>> > > 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 <[hidden email]>
>> > > 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]]
>> > > >
>> > > > ______________________________________________
>> > > > [hidden email] 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.
>> > >
>> > > ______________________________________________
>> > > [hidden email] 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.
>> > >
>> >
>> > [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > [hidden email] 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.
>> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
>> partnerů PRECHEZA a.s. jsou zveřejněny na:
>> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information
>> about processing and protection of business partner’s personal data are
>> available on website:
>> https://www.precheza.cz/en/personal-data-protection-principles/
>> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
>> důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
>> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
>> documents attached to it may be confidential and are subject to the legally
>> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
>>
>>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Plotting rgb proportions in R

surchin84
That works! Thank you so much for for help!

On Wed, Jan 2, 2019, 19:56 Jim Lemon <[hidden email] wrote:

> Hi Tasha,
> Using the original sample you sent:
>
> 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
> # the matrix format forces the stacked bar display
> barplot(matrix(rgb_prop$pct,ncol=1),
>  col=rgb(rgb_prop[,c("Red","Green","Blue")]),beside=FALSE)
>
> Of course you can add more stacks by increasing the number of columns in
> the "x" matrix.
>
> Jim
>
> On Thu, Jan 3, 2019 at 3:33 AM Tasha O'Hara <[hidden email]>
> wrote:
>
>> I apologize for the late reply after the holidays. I really appreciate
>> all the data visualization suggestions. The scatterplot works very well,
>> but I do have >400 specimen with at least 5-20 colors each, so a stacked
>> barchart of each specific color proportion would be most useful to show
>> uniformity within each specimen. Below is an example of what I would like
>> to do, but instead of generic colors, I am hoping to plot the actual RGB
>> proportions for each.
>> [image: image.png]
>>
>> On Wed, Dec 19, 2018 at 5:28 AM PIKAL Petr <[hidden email]>
>> wrote:
>>
>>> Hi
>>>
>>> > -----Original Message-----
>>> > From: R-help <[hidden email]> On Behalf Of Bert Gunter
>>> > Sent: Wednesday, December 19, 2018 5:26 AM
>>> > To: Jim Lemon <[hidden email]>
>>> > Cc: R-help <[hidden email]>
>>> > Subject: Re: [R] Plotting rgb proportions in R
>>> >
>>> > 3-d Proportions must sum to 1and are thus actually 2-d and should
>>> preferaby
>>> > be plotted as a ternary plot. Several r packages will do this for you,
>>> e.g.
>>> > package Ternary. Search "ternary plots" on rseek.org for others.
>>>
>>> From which I would recommend ggtern. Sometimes a bit tricky but quite
>>> handy, especially when you consider some grouping.
>>>
>>> Cheers
>>> Petr
>>>
>>> >
>>> > -- Bert
>>> >
>>> >
>>> > Bert Gunter
>>> >
>>> > "The trouble with having an open mind is that people keep coming along
>>> and
>>> > sticking things into it."
>>> > -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>>> >
>>> >
>>> > On Tue, Dec 18, 2018 at 3:10 PM Jim Lemon <[hidden email]>
>>> wrote:
>>> >
>>> > > 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 <[hidden email]
>>> >
>>> > > 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]]
>>> > > >
>>> > > > ______________________________________________
>>> > > > [hidden email] 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.
>>> > >
>>> > > ______________________________________________
>>> > > [hidden email] 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.
>>> > >
>>> >
>>> > [[alternative HTML version deleted]]
>>> >
>>> > ______________________________________________
>>> > [hidden email] 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.
>>> Osobní údaje: Informace o zpracování a ochraně osobních údajů obchodních
>>> partnerů PRECHEZA a.s. jsou zveřejněny na:
>>> https://www.precheza.cz/zasady-ochrany-osobnich-udaju/ | Information
>>> about processing and protection of business partner’s personal data are
>>> available on website:
>>> https://www.precheza.cz/en/personal-data-protection-principles/
>>> Důvěrnost: Tento e-mail a jakékoliv k němu připojené dokumenty jsou
>>> důvěrné a podléhají tomuto právně závaznému prohláąení o vyloučení
>>> odpovědnosti: https://www.precheza.cz/01-dovetek/ | This email and any
>>> documents attached to it may be confidential and are subject to the legally
>>> binding disclaimer: https://www.precheza.cz/en/01-disclaimer/
>>>
>>>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] 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.