0

I was trying to fill multiple polygons with color using the following code:

  geom_polygon(data = Case1_polygon, aes(x, y, fill = factor(cluster_id),group = cluster_id, color = factor(cluster_id)), show.legend = FALSE)

But this returns the following error:

Error: Insufficient values in manual scale. 84 needed but only 3 provided.

I don't understand why this came since the arguments 'group' and 'color' could work properly.

What is the problem? Here are the first 20 rows of the data:

  cluster_id        x        y
           2 15.11161 12.44378
           2 15.13238 12.51207
           2 15.13430 12.55426
           2 15.22371 12.59345
           2 15.23244 12.65508
           2 15.12325 12.62875
           2 15.11938 12.63302
           2 15.08193 12.64385
           2 15.04474 12.64052
           2 15.05771 12.59970
           2 15.04334 12.53319
           2 15.04363 12.52807           
           2 15.04408 12.52420          
           2 15.09167 12.48072          
           2 15.11161 12.44378          
           3 14.86679 12.76042           
           3 14.81625 12.77065         
           3 14.80090 12.83679        
           3 14.79523 12.85389           
           3 14.79443 12.86224
DigiPath
  • 179
  • 2
  • 10
  • You code is fine for your example data. What else are you using to make your plot? `scale_fill_manual` or `scale_color_manual`? Other? – Ben Feb 17 '20 at 22:27
  • It seems that you provided only three colors although you probably needed 84 colors? – jazzurro Feb 18 '20 at 01:24
  • This may be post https://stackoverflow.com/questions/18999284/ggplot2-error-insufficient-values-in-manual-scale may be helpful. – xilliam Feb 18 '20 at 09:52

0 Answers0