Entering edit mode
9.5 years ago
Assa Yeroslaviz
★
1.8k
Hi,
I have a data.frame which I would like to plot using the ggplot2 package.
This is what i am doing:
myBreaks <- c(seq(0,0.001, 0.0002),seq(0.002,0.01,0.005), 0.01, seq(0.2,1,0.3), 2,5)#create the intervals
PlotData$bins <- findInterval(PlotData[,3],myBreaks) # plotting the braks
cols <- c('cadetblue1', 'cadetblue3', 'cadetblue4', 'cadetblue', 'burlywood', 'burlywood2', 'burlywood4', 'brown3', 'darkorchid4', 'darkorange2', 'darkolivegreen3', 'red3', 'midnightblue', 'chocolate2') # wanted colours
ggplot(PlotData, aes(y = start, x = start.1)) +
labs(title = "normalized values") +
geom_tile(aes(fill = bins)) +
scale_fill_gradientn(name = "values",
breaks = myBreaks,
colours=cols,
labels = format(paste("\u2265", myBreaks,sep="")),
values= myBreaks,
rescaler = function(x, ...) x,
oob = identity, na.value="grey89",
guide="legend")
The plot I get shows all the colours in the plot itself but not in the legend. How can I convert the legend to also show all the colours as well as the breaks as labels?
Thanks in advance
Assa
Are you sure you posted the correct file? I can't see much in the plot you posted.
Yes I am. The file itself is not important. I did have the correct colours there.
Yes I know there not many elements there, but this expected
I need to have the correct legend