I have to make this exact plot but I can't seem to find the right color in the hexadecimal chart.
Also does anyone know how to change the labels on the y-axis as well. My values show up as 1e+07 instead of 10,000.
Here is the code I used to make my plot
The data is from the USAarrests data set from R.
p=ggplot(data=examdata,aes(Assault,Population))
p=p+geom_point(size=3,color="red",shape="asterisk")
p=p+geom_smooth(color="Purple",lty="dashed",fill="#71F563")
Here is the picture after I tried the color code you all found.
Edited Plot]2
I think I have to change the alpha on it, but I dont know how to do that with fill. Sorry if these questions have been asked.
I looks like a custom color palette to me. You can use an color picker tool (such as https://imagecolorpicker.com/) to see the exact hex. I tried it out and got this:
Green (CI): #7ef376
Purple (dashed line): #a251ef
Red (data points): #e93f33
Can you also show the code so we know what you did to get your y-axis?
Related
I often have to use plots mixing lines and points (ggplot2), with the colors of the line representing one variable (here, "Dose"), and the shape of the points another one (here, "Treatment). Figure 1 shows what I typically get:
Figure 1: what I get
I like having different legends for the two variables, but would like to remove the round markers from the color scale, to only show the colors (see legend mockup below, made with Gimp). Doing so would allow me to have a clean legend, with colors and shapes clearly segregated.
Figure 2 (mockup): what I would like
Would anyone know if there is a way to do that? Any help would be much appreciated.
Note: the plots above show means and error bars, but I have the same problem with any plot mixing geom_line and geom_point, even simple ones.
Thanks in advance !
Can someone let me know the various colors which produced the excellent color mix in the 4-panel plot on this link:?
http://www.enr.gov.nt.ca/state-environment/13-projected-trends-temperature-and-precipitation-arctic
I need the color ramp on the right of the plot for precipitation.
I tried something like:
col=colorRampPalette(c( "red3","orange","gold1", "yellow", "lightskyblue","steelblue3", "royalblue3",
"darkblue","darkblue"))(30))
but could not get it right. A list of colors in R is found here:
http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf
Many thanks.
AZ.
You can identify the colors using the Eyedropper Tool in Firefox, although it's a bit tedious. As you can see below, the actual palette is close but not quite the same as the Color Brewer palette.
actual <- c('#2F2C62', '#42399B', '#4A52A7', '#59AFEA', '#7BCEB8', '#A7DA64',
'#EFF121', '#F5952D', '#E93131', '#D70131', '#D70131')
library(colorRamps)
barplot(cbind(1:11,1:11),beside=TRUE,names=c("actual","brewer.pal(11,'RdYlBu')"),
col=c(rev(actual),brewer.pal(11,"RdYlBu")))
It looks very close to the color scheme called 'RdYlBl' from RColorBrewer.
Here is how it looks like:
require('RColorBrewer')
display.brewer.pal(11,'RdYlBu')
(to use it: brewer.pal(11,'RdYlBu'))
I was wondering if anybody had much experience with the function bplot in R, I am making a 3d plot and the plot works fine. The only thing I want to change is the gradient of colour which you get from drape=TRUE. At the moment it has a single pink colour fading into blue, I really need a third colour in the middle to highlight the central data better as this is the most important for my study, and at the moment in some of the plots I am doing its too difficult to pick out and correlate with the level of y in the colour scale bar.
Does anybody have any idea how to do this?
I need more reputation to post an image of the plot but you can see what I mean in the second image of this thread.
Plot Regression Surface
Many thanks
Aaron
Try adding a colorRampPalette argument to your plot like so:
col.regions = colorRampPalette(colors=c("red","yellow"))(1000)
This will give you a gradient of 1000 shades between red and yellow, You can use any of the R colors in the color ramp, and you can specify more than two e.g.colors=c("red","orange3","palegoldenrod") if you like. You should put this argument at the same place you are putting drape=TRUE
I ran heatmap.2 in R, and am not able to generate a colored color key to show the density of the plot in the upper left corner.
I am able to make the color key with the following:
library(gplots)
a=cbind(a=1:5000,b=1:5000*2,c=1:5000*4,d=1:5000*8,e=1:5000*16)
h=hclust(dist(log(t(a))))
d=as.dendrogram(h)
dd=reorder(d,c(-10,1,1,1,100))
hm=colorRampPalette(c('yellow','green','red'))(nrow(a)*ncol(a))
png(file="CompleteHeatmap.png",width=1200,height=800)
par(oma=c(1,1,1,5))
heatmap.2(log(a),scale='none',trace='none',col=hm,density.info='density',denscol='black',Colv=dd)
With this, the color key comes up fine and accurate. Yet when I run it with my actual data (39000 * 6 columns) I do not get a colored color key, although the density plot shown is accurate.
If anyone has any ideas why this might occur, I would like to hear, as my boss would like to have the color key colored correctly.
My data table is a little more than 7 times the size of the matrix made above, but other than that, all the calls are the same.
Many thanks
Alex
I found an answer, and altered the colorpallete with
hm=colorRampPalette(c('yellow','green','red'))(256)
in position of nrow()*ncol() and it worked out!
I am trying to get a correct legend for a series of points in a plot, which look like:
plot(c(3,1),pch=21,bg="white",col="black")
points(c(2,1),pch=21,bg="black",col="black")
points(c(1,1),pch=21,bg="dark grey",col="black")
I thought the legend code would be:
legend("topright",legend=c('Point3','Point2','Point1'),pch=c(21,21,21),
bg=c('white','black','dark grey'),col=c('black','black','black'),bty='n')
But apparently I am wrong, because I only get three white points with black boarder. Why isn't this working and what is the correct code?
If you read help("legend") you find out that bg specifies the background of the legend. You need to use pt.bg:
legend("topright", legend=c('Point3','Point2','Point1'), pch=c(21,21,21),
pt.bg=c('white','black','dark grey'), col=c('black','black','black'), bty='n')