I use ggplot2 to display data, and use the function "scale_fill_distiller" to display continuous color bar. However, I want to increase the interval from every 100 to every 200 in the color bar, how to do this? The target variable is annual precipitation, so from 0 to 2000 mm.
Also, how to increase the length of the color bar so that the numbers will be displayed clearly. I display the color bar as horizontal rather than vertical, so that the numbers such as 100, 200, 300, etc. are clumped together and hard to differentiate. Thanks for your help
Actually, I have another question based on this.
Suppose I have two datasets, with similar coordinates but different rainfall values. In df1, as the dataset you created, the values vary from 100 to 550. While in df2, the values vary from 50 to 800. Then I use the same scale_fill_distiller in order to put the two figures on one panel. The code is shown below:
fill_com = scale_fill_distiller('pr',palette='Spectral', breaks = c(200, 400))
figure1= ggplot(df1, aes(x, y, fill = COL)) + geom_tile() + theme_classic() + fill_com
figure2= ggplot(df2, aes(x, y, fill = COL)) + geom_tile() + theme_classic() + fill_com
ggarrange(figure1, figure2, ncol=2, nrow=1, common.legend = TRUE, legend="bottom")
But I think the color bar depends on the dataframe with the lowest range (550 in this case, rather than 800), such as df1. Thus, the high values in df2 does not show on the color bar. How to solve that? Thanks again.