Dear ggplot2 users,
I have a question about the legend. For example, my dataset "dataf" is like this:
id cl x y
1 1 2.5 11.0
2 1 4.3 12.0
3 1 2.2 10.0
4 1 5.4 9.0
5 1 6.0 10.0
6 2 7.7 8.0
7 2 7.1 7.8
8 2 2.5 8.9
9 3 5.5 8.8
10 3 4.0 72.0
11 3 4.5 8.0
12 4 6.2 10.0
13 4 7.0 10.5
I use the code to print the points.
plot1 = ggplot(dataf,aes(x=x,y=y,color=factor(cl)))+theme_bw()+ geom_point()
print(plot1)
However, if there are more than 100 classes in the 'cl' column, the legend becomes compact and is not easy to recognize. I'm wondering how to use a gradient color bar to represent the legend? This means that not every 'cl' value is listed in the legend, but just a gradient bar (maybe show the smallest and largest values at the two ends of the bar) to represent the color changes. Thanks for your help in advance.