I have a geom_point ggplot and I'm trying to employ custom backgrounds and colors (text). I've written a couple of simple function to set the background and color. Here is my plot code.
When I run this code a get the following errors numerous times. The chart is ultimately rendered, but there is no text and the labels are distorted. See below.
Warning in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
supplied color is neither numeric nor character
Warning in grid.Call.graphics(C_setviewport, vp, TRUE): supplied color is
neither numeric nor character
Alternatively, if I run the code with the geom_label below the chart works, but I have no custom colors - I need custom colors.
@raytong, Thanks for the reply. This is very helpful. One point of clarification. I need to assign specific colors to specific values. For example, my function pgmcolor returns a color based upon the value of pgm. Given that, would the following be the approach I should use:
scale_color_manual(values =map(pgm,pgmcolor) )
scale_fill_manual(values =map(pgm,pgmcolorb) )
@mutuelinvestor. You can use your own function to assign color. But the values pass to your map function will be changed because the columns of tchart cannot map outside aes. If pgmcolor and pgmcolorb are the column name in tchart, the code will be scale_color_manual(values=map(tchart$pgm, tchart$pgmcolor)). If pgmcolor and pgmcolorb are variables, the code will be scale_color_manual(values=map(tchart$pgm, pgmcolor)).
@mutuelinvestor. The error because your map function return a numeric vector, not colour code. So, you can only use RColorBrewer or pass a vector of RGB color code to it.