I am writing a graph plotting program. I thus am looking ways to obtain colours that are distinguishable to each other in order to plot various graphs in one cell.
Is there an algorithm or some website that obtains rgb values that matches this criteria?
EDIT: I am looking for 16 different colours
For an automatic solution, you can take one color as the base color and obtain good matching colors by changing the hue in the HSV/HSB color space. If you need 4 colors for example you could rotate the hue by 90° for each color.
If the number of lines on the graph isn't too large (i.e. you can pick colours by hand), I rather like this (http://colorschemedesigner.com/) for choosing colours that work together, but stand out from each other.
Related
I needed to plot cumulative distribution curves for 15 different groups but the default color setting generated some curves with visually similar colors, which caused some trouble for presentation, especially when the two curves have similar cumulative distributions.
My current approach is to generate one plot first and then based on the plot assign colors on specific curves to visually separate them.
I was wondering if there are other easier approaches to plot a large number (>10) curves in distinct colors.
If you need to distinguish many items, such as curves, you should use other visual means in addition to color (or rather than color) to distinguish them. For example, you can identify the curves with letters or numbers, draw them with different line-dash patterns, use different line thicknesses, and so on.
You should only use color if you can't distinguish your curves in other ways.
I have been looking for a way to color markers in a scatter plot without creating an entire new series for every point. Is there a way to color them individually with different RGB values for each?
a single color gradient (the solution to the question asked in:
How do you color (x,y) scatter plots according to values in z using Plots.jl?)
is not what I´m looking for. Maybe if I could overlap 3 gradients, one for each RBG color, that could work. Thanks.
As Fredrik said, you can pass a vector... it's pretty flexible, and if your vector is too short it should cycle.
using Plots
scatter(sin, c=[:red, colorant"blue", RGB(0,1,0)])
So right now I've got this plot:
my plot
(sorry it's not inline image, this is my first time on Stack Overflow and it wouldn't let me post images)
The plot is produced with this code:
ggplot(potassium.data,
aes(x=Experiment,y=value,
colour=Pedigree))+geom_jitter()+labs(title=element)
The problem is, there are 31 different maize pedigrees being plotted here, so it's difficult to distinguish the colors from each other. I was wondering if it's possible to make it so that the color and shape of the point are used to uniquely identify a pedigree, so that for example one pedigree is red squares, another is red circles, a third one is blue squares, a fourth is blue circles, and so on. This would make it far easier to distinguish the points. Anyone know how to do this?
I don't think thats possible, if you do the shaping by pedigree you will just end up with as many categories of shapes as you have colors now.
geom_label() and geom_text() would let you plot the cultivar id directly onto the plot, then maybe you could build a separate column for something equivalent to genus, so that the cultivars could be grouped somehow (maybe A, B, PH, etc). Then you could color by that "genus" column, which would make the plot look better:
ggplot(potassium.data,
aes(x=Experiment,y=value, label=Pedigree, colour = genus))+
geom_label(position = position_jitter())+
labs(title=element)
Ideally you would end up with a plot colored by the genus while only plotting the suffix digits currently in Pedigree.
I have to agree with Nathan and Joran, the plot is quite confusing by having so many different points and adding shapes into the mix is unlikely to help.
To answer your question you should be able to use shape=pedigree, but maybe to make the graph more readable you could join the pedigrees from one experiment to the other with a geom_line so the reader spends less time scanning.
I have data that I would like to plot and use shapes to symbolise the data . In total I have 20 potential different pieces of data to be represented by shapes.
e.g they are labeled such as R/Hand elbow, R/Hand knee, R/Hand foot, L/Hand shoulder, L/Hand neck etc etc
So far I keep coming up with a limitation of 6 shapes and they are all different colors.
One option I do have is to not only use shapes but also color code the shapes.
So 10 different shapes with each shape representing a different piece of categorical data, but all shapes being Blue.
and then the same 10 shapes but all shapes begin colored Red.
The 20 pieces of data are locations on the body (10 on the left and 10 on the right).
thanks
You can create your own discrete scale with the scale_manual variants. It this case you will need scale_shape_manual. When you type ?pch you get the help page hich gives the values you can use. In your case, you use for example:
scale_shape_manual(values=1:20, labels=c("R/Hand elbow", "R/Hand knee", "R/Hand foot", "L/Hand shoulder", "L/Hand neck", and so on ...))
However, using 20 different shapes could result in a confusing plot. As you want to distuinghish body parts, you might consider using faceting between for example left and right part of the body.
I am trying to illustrate a histogram of 33 different variables. Due to the number of variables I think "beside" different Colors I need to label each bar in a clear way, even using an arrow, if its doable.
I was wondering about
1) How can I define 33 distinct color in R
2) How can I label them, say vertical below X axis with a certain distance from each other to make my figure more clear.
I am using multhist function from Plotrix package, and for data you can image just 33 random vector with different length !
Thanks
As Chris mentioned, trying to distinguish 33 colours doesn't work for humans. You need to find a different plot type that doesn't rely on only colour.
Without a reproducible example, it is not possible to say what this plot should be, but here's some generic colour advice.
Use HCL colours rather the RGB or HSV. Read Escaping RGBland by Achim Zeileis for an explanation. There are some useful functions for generating palettes in the colorspace package.
If your variables are unordered categories (i.e., encoded as factors) then your colours should have different hues. (Use rainbow_hcl.)
If your variables are in some sort of order (ranges or ordered factors) then your colours should have different lightness or chroma. (Use sequential_hcl.) A variation on this is if they differ about some midpoint, in which case you need diverge_hcl.
You can define colors in R in any number of ways; try ?rainbow or ?greyscale for some suggestions
You could also look at all the colors here and just create a vector of your desired colors that you call inside your plot function.
Your problem though is that the human eye and the printing process has trouble distinguishing and reproducing that many distinct colors. See the documentation at the colorbrewer site for more information (and advice on picking colors).
Not sure I understand what your trying to do with the labels, but you can re-label an axis with a call to axis. See the documentation in ?axis.