How to plot curves with more than 8 colors

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

How to plot curves with more than 8 colors

Vincent Deng
Hi,

I'm a new hand in R language. I have about 20 groups of data[x,y] and
want to plot them on a graph. To do this, I write a for-loop as
following: (some codes are omitted for simplicity)

for (i in c(1:20))
{
  points(...,...,col=i)
  lines(...,col=i)
}

The problem is "R only plot them with 8 colors repeatly". Could anyone
help me solve this problem? Or is there any package providing plot
function without color limit?

Best Regards...

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to plot curves with more than 8 colors

Uwe Ligges
Vincent Deng wrote:

> Hi,
>
> I'm a new hand in R language. I have about 20 groups of data[x,y] and
> want to plot them on a graph. To do this, I write a for-loop as
> following: (some codes are omitted for simplicity)
>
> for (i in c(1:20))
> {
>   points(...,...,col=i)
>   lines(...,col=i)
> }
>
> The problem is "R only plot them with 8 colors repeatly". Could anyone
> help me solve this problem? Or is there any package providing plot
> function without color limit?


After typing

  ?colors

I get a nice help page that points me to a lot of other functions that
generate more than 8 colors. Maybe your installation of R is broken and
you cannot see this help page? You certainly tried to get help on colors
as well.

There is no limit of the color number in the functions above, simply
specify the color you want to get. The only color limit applies for the
device and for most devices and rgb colors this is 256^3.

Uwe Ligges




> Best Regards...
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to plot curves with more than 8 colors

Vincent Deng
Dear Uwe,

Sorry, I did not describe my question clearly. I created a matrix to
store color code using rgb function.

abc = rgb(6:36,0,0,maxColorValue = 255)

And after running codes like this

for (i in c(1:20))
{
   points(...,...,col=abc[i])
   lines(...,col=abc[i])
}

R still used 8 colors of abc color codes repeatedly to draw the diagram

Any helps?

Best Regards...

On 12/27/05, Uwe Ligges <[hidden email]> wrote:

> Vincent Deng wrote:
> > Hi,
> >
> > I'm a new hand in R language. I have about 20 groups of data[x,y] and
> > want to plot them on a graph. To do this, I write a for-loop as
> > following: (some codes are omitted for simplicity)
> >
> > for (i in c(1:20))
> > {
> >   points(...,...,col=i)
> >   lines(...,col=i)
> > }
> >
> > The problem is "R only plot them with 8 colors repeatly". Could anyone
> > help me solve this problem? Or is there any package providing plot
> > function without color limit?
>
>
> After typing
>
>   ?colors
>
> I get a nice help page that points me to a lot of other functions that
> generate more than 8 colors. Maybe your installation of R is broken and
> you cannot see this help page? You certainly tried to get help on colors
> as well.
>
> There is no limit of the color number in the functions above, simply
> specify the color you want to get. The only color limit applies for the
> device and for most devices and rgb colors this is 256^3.
>
> Uwe Ligges
>
>
>
>
> > Best Regards...
> >
> > ______________________________________________
> > [hidden email] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to plot curves with more than 8 colors

Uwe Ligges
Vincent Deng wrote:

> Dear Uwe,
>
> Sorry, I did not describe my question clearly. I created a matrix to
> store color code using rgb function.
>
> abc = rgb(6:36,0,0,maxColorValue = 255)
>
> And after running codes like this
>
> for (i in c(1:20))
> {
>    points(...,...,col=abc[i])
>    lines(...,col=abc[i])
> }
>
> R still used 8 colors of abc color codes repeatedly to draw the diagram
>
> Any helps?


No, it does not (in fact, all appears to be more or less black on my
screen ;-)). Another example:

plot(1:255, col=rgb(1:255,0,0,maxColorValue = 255))

Uwe Ligges



> Best Regards...
>
> On 12/27/05, Uwe Ligges <[hidden email]> wrote:
>
>>Vincent Deng wrote:
>>
>>>Hi,
>>>
>>>I'm a new hand in R language. I have about 20 groups of data[x,y] and
>>>want to plot them on a graph. To do this, I write a for-loop as
>>>following: (some codes are omitted for simplicity)
>>>
>>>for (i in c(1:20))
>>>{
>>>  points(...,...,col=i)
>>>  lines(...,col=i)
>>>}
>>>
>>>The problem is "R only plot them with 8 colors repeatly". Could anyone
>>>help me solve this problem? Or is there any package providing plot
>>>function without color limit?
>>
>>
>>After typing
>>
>>  ?colors
>>
>>I get a nice help page that points me to a lot of other functions that
>>generate more than 8 colors. Maybe your installation of R is broken and
>>you cannot see this help page? You certainly tried to get help on colors
>>as well.
>>
>>There is no limit of the color number in the functions above, simply
>>specify the color you want to get. The only color limit applies for the
>>device and for most devices and rgb colors this is 256^3.
>>
>>Uwe Ligges
>>
>>
>>
>>
>>
>>>Best Regards...
>>>
>>>______________________________________________
>>>[hidden email] mailing list
>>>https://stat.ethz.ch/mailman/listinfo/r-help
>>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>>
>>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to plot curves with more than 8 colors

Vincent Deng
Hi,

Thanks for your kindly reply.
I think maybe I didn't specify color codes properly. That is,the
difference between each color is not sharp enough for me to identify
them as different colors.

So can you tell me about how to specify the color properly so that the
difference among each color can be identified clearly?

Thanks again and again ...

On 12/27/05, Uwe Ligges <[hidden email]> wrote:

> Vincent Deng wrote:
>
> > Dear Uwe,
> >
> > Sorry, I did not describe my question clearly. I created a matrix to
> > store color code using rgb function.
> >
> > abc = rgb(6:36,0,0,maxColorValue = 255)
> >
> > And after running codes like this
> >
> > for (i in c(1:20))
> > {
> >    points(...,...,col=abc[i])
> >    lines(...,col=abc[i])
> > }
> >
> > R still used 8 colors of abc color codes repeatedly to draw the diagram
> >
> > Any helps?
>
>
> No, it does not (in fact, all appears to be more or less black on my
> screen ;-)). Another example:
>
> plot(1:255, col=rgb(1:255,0,0,maxColorValue = 255))
>
> Uwe Ligges
>
>
>
> > Best Regards...
> >
> > On 12/27/05, Uwe Ligges <[hidden email]> wrote:
> >
> >>Vincent Deng wrote:
> >>
> >>>Hi,
> >>>
> >>>I'm a new hand in R language. I have about 20 groups of data[x,y] and
> >>>want to plot them on a graph. To do this, I write a for-loop as
> >>>following: (some codes are omitted for simplicity)
> >>>
> >>>for (i in c(1:20))
> >>>{
> >>>  points(...,...,col=i)
> >>>  lines(...,col=i)
> >>>}
> >>>
> >>>The problem is "R only plot them with 8 colors repeatly". Could anyone
> >>>help me solve this problem? Or is there any package providing plot
> >>>function without color limit?
> >>
> >>
> >>After typing
> >>
> >>  ?colors
> >>
> >>I get a nice help page that points me to a lot of other functions that
> >>generate more than 8 colors. Maybe your installation of R is broken and
> >>you cannot see this help page? You certainly tried to get help on colors
> >>as well.
> >>
> >>There is no limit of the color number in the functions above, simply
> >>specify the color you want to get. The only color limit applies for the
> >>device and for most devices and rgb colors this is 256^3.
> >>
> >>Uwe Ligges
> >>
> >>
> >>
> >>
> >>
> >>>Best Regards...
> >>>
> >>>______________________________________________
> >>>[hidden email] mailing list
> >>>https://stat.ethz.ch/mailman/listinfo/r-help
> >>>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> >>
> >>
>
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to plot curves with more than 8 colors

jholtman
It might be hard to differentiate between each color with having 255 of
them.  Here is an example of using ColorRampPalette to create a set of
colors.  You can experiment with as many differing ones as you want to to
get the difference that you want:

# use 5 colors to create a sequence (you can add more colors if you want to)
f.c <- colorRampPalette(c('red','green','orange','blue','yellow'))(255)
plot(0,type='n', ylim=c(0,255), xlim=c(0,1))
for (i in 1:255) segments(0, i, 1, i, col=f.c[i])




On 12/27/05, Vincent Deng <[hidden email]> wrote:

>
> Hi,
>
> Thanks for your kindly reply.
> I think maybe I didn't specify color codes properly. That is,the
> difference between each color is not sharp enough for me to identify
> them as different colors.
>
> So can you tell me about how to specify the color properly so that the
> difference among each color can be identified clearly?
>
> Thanks again and again ...
>
> On 12/27/05, Uwe Ligges <[hidden email]> wrote:
> > Vincent Deng wrote:
> >
> > > Dear Uwe,
> > >
> > > Sorry, I did not describe my question clearly. I created a matrix to
> > > store color code using rgb function.
> > >
> > > abc = rgb(6:36,0,0,maxColorValue = 255)
> > >
> > > And after running codes like this
> > >
> > > for (i in c(1:20))
> > > {
> > >    points(...,...,col=abc[i])
> > >    lines(...,col=abc[i])
> > > }
> > >
> > > R still used 8 colors of abc color codes repeatedly to draw the
> diagram
> > >
> > > Any helps?
> >
> >
> > No, it does not (in fact, all appears to be more or less black on my
> > screen ;-)). Another example:
> >
> > plot(1:255, col=rgb(1:255,0,0,maxColorValue = 255))
> >
> > Uwe Ligges
> >
> >
> >
> > > Best Regards...
> > >
> > > On 12/27/05, Uwe Ligges <[hidden email]> wrote:
> > >
> > >>Vincent Deng wrote:
> > >>
> > >>>Hi,
> > >>>
> > >>>I'm a new hand in R language. I have about 20 groups of data[x,y] and
> > >>>want to plot them on a graph. To do this, I write a for-loop as
> > >>>following: (some codes are omitted for simplicity)
> > >>>
> > >>>for (i in c(1:20))
> > >>>{
> > >>>  points(...,...,col=i)
> > >>>  lines(...,col=i)
> > >>>}
> > >>>
> > >>>The problem is "R only plot them with 8 colors repeatly". Could
> anyone
> > >>>help me solve this problem? Or is there any package providing plot
> > >>>function without color limit?
> > >>
> > >>
> > >>After typing
> > >>
> > >>  ?colors
> > >>
> > >>I get a nice help page that points me to a lot of other functions that
> > >>generate more than 8 colors. Maybe your installation of R is broken
> and
> > >>you cannot see this help page? You certainly tried to get help on
> colors
> > >>as well.
> > >>
> > >>There is no limit of the color number in the functions above, simply
> > >>specify the color you want to get. The only color limit applies for
> the
> > >>device and for most devices and rgb colors this is 256^3.
> > >>
> > >>Uwe Ligges
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>>Best Regards...
> > >>>
> > >>>______________________________________________
> > >>>[hidden email] mailing list
> > >>>https://stat.ethz.ch/mailman/listinfo/r-help
> > >>>PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
> > >>
> > >>
> >
> >
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to plot curves with more than 8 colors

Don MacQueen
In reply to this post by Vincent Deng

I have found this little function useful when trying to choose colors:

showcols <-  function (indx = 0:6)
{
     for (ii in unique(indx)) {
         is <- 100 * ii + 1:100
         if (min(is) > length(colors())) {
             cat("Maximum value of arg is", floor(length(colors())/100),
                 "\n")
             return(NULL)
         }
         foo <- matrix(colors()[is], nrow = 10)
         par(mar = c(3, 3, 0.25, 0.25))
         plot(1:10, 1:10, type = "n", yaxt = "n", xlab = "", ylab = "")
         axis(2, at = 1:10, lab = 10:1)
         for (j in 1:10) {
             for (i in 1:10) {
                 points(j, 11 - i, col = foo[i, j], pch = 16,
                   cex = 4)
                 text(j, 11 - i - 0.3, foo[i, j], cex = 0.8)
             }
         }
         if (length(indx) > 1 & ii < max(indx))
             readline(paste("Currently showing group", ii, "  CR to continue "))
     }
     invisible(foo)
}

Just type
    showcols()
at the R prompt. Then pick any 20 you happen to think are distinguishable.

Based on my own experience, I would doubt that it is possible to find
20 easily distinguishable colors.
But perhaps if you use both solid and dotted lines you can get 20
distinguishable lines.

-Don

At 10:48 AM +0800 12/28/05, Vincent Deng wrote:

>Hi,
>
>Thanks for your kindly reply.
>I think maybe I didn't specify color codes properly. That is,the
>difference between each color is not sharp enough for me to identify
>them as different colors.
>
>So can you tell me about how to specify the color properly so that the
>difference among each color can be identified clearly?
>
>Thanks again and again ...
>
>On 12/27/05, Uwe Ligges <[hidden email]> wrote:
>>  Vincent Deng wrote:
>>
>>  > Dear Uwe,
>>  >
>>  > Sorry, I did not describe my question clearly. I created a matrix to
>>  > store color code using rgb function.
>>  >
>>  > abc = rgb(6:36,0,0,maxColorValue = 255)
>>  >
>>  > And after running codes like this
>>  >
>>  > for (i in c(1:20))
>>  > {
>>  >    points(...,...,col=abc[i])
>>  >    lines(...,col=abc[i])
>>  > }
>>  >
>>  > R still used 8 colors of abc color codes repeatedly to draw the diagram
>>  >
>>  > Any helps?
>>
>>
>>  No, it does not (in fact, all appears to be more or less black on my
>>  screen ;-)). Another example:
>>
>>  plot(1:255, col=rgb(1:255,0,0,maxColorValue = 255))
>>
>>  Uwe Ligges
>>
>>
>>
>>  > Best Regards...
>>  >
>>  > On 12/27/05, Uwe Ligges <[hidden email]> wrote:
>>  >
>>  >>Vincent Deng wrote:
>>  >>
>>  >>>Hi,
>>  >>>
>>  >>>I'm a new hand in R language. I have about 20 groups of data[x,y] and
>>  >>>want to plot them on a graph. To do this, I write a for-loop as
>>  >>>following: (some codes are omitted for simplicity)
>>  >>>
>>  >>>for (i in c(1:20))
>>  >>>{
>>  >>>  points(...,...,col=i)
>>  >>>  lines(...,col=i)
>>  >>>}
>>  >>>
>>  >>>The problem is "R only plot them with 8 colors repeatly". Could anyone
>>  >>>help me solve this problem? Or is there any package providing plot
>>  >>>function without color limit?
>>  >>
>>  >>
>>  >>After typing
>>  >>
>>  >>  ?colors
>>  >>
>>  >>I get a nice help page that points me to a lot of other functions that
>>  >>generate more than 8 colors. Maybe your installation of R is broken and
>>  >>you cannot see this help page? You certainly tried to get help on colors
>>  >>as well.
>>  >>
>>  >>There is no limit of the color number in the functions above, simply
>>  >>specify the color you want to get. The only color limit applies for the
>>  >>device and for most devices and rgb colors this is 256^3.
>  > >>
>  > >>Uwe Ligges
>  > >>
>  > >>
>  > >>
>  > >>
>  > >>
>  > >>>Best Regards...
>  > >>>
>  > >>>______________________________________________
>  > >>>[hidden email] mailing list
>  > >>>https://stat.ethz.ch/mailman/listinfo/r-help
>>  >>>PLEASE do read the posting guide!
>>http://www.R-project.org/posting-guide.html
>>  >>
>>  >>
>>
>>
>
>______________________________________________
>[hidden email] mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


--
--------------------------------------
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: How to plot curves with more than 8 colors

Earl F. Glynn
"Don MacQueen" <[hidden email]> wrote in message
news:p06210200bfd9c680fda6@[128.115.153.6]...
>
> I have found this little function useful when trying to choose colors:

FWIW:  To choose colors, this page
http://research.stowers-institute.org/efg/R/Color/Chart/index.htm
and PDF
http://research.stowers-institute.org/efg/R/Color/Chart/ColorChart.pdf
can be used to view the "named" colors in R, along with RGB information in
decimal or hex.

Not everyone can "see" the same colors.  In particular, about 7% of males
have some color blindness, especially red-green.  See some of the links
under "Color Blindness":
http://www.efg2.com/Lab/Library/Color/index.html

Not all devices have the same color "gamut".  That is, not all devices can
display the same ranges of colors:
http://www.efg2.com/Lab/Library/Color/Science.htm#gamuts
Matching color between the screen and printers can be a problem.

efg

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html