I would like to create an image file containing the color key for an R plot that uses a colorbrewer palette. This needs to be a separate file from the plot itself. Colorbrewer produces a nice plot describing the palette:
display.brewer.pal(11, "RdBu")
However, I cannot find any way to alter this plot -- e.g. add values, a title, control size, and dimensions, and save it as an image file. Is there a way to do this with the output of the display.brewer.pal function? Or some alternative using the underlying palette?
I am looking for a completely separate legend based on the palette, not a legend produced by a plot function.
I think you need to modify the
display.brewer.palfunction, but it's pretty simple, so this isn't hard. For example:Created on 2022-10-02 with reprex v2.0.2