0

I am adding a transparent color filling by a factor variable in tmap object through the "alpha" option also present in ggplot. However, the degree of transparency fitting the figure renders the colors in the legend almost invisible. How can I change the alpha in the legend without having to change the alpha in the figure?

Márton
  • 35
  • 2
  • 1
    Does this help? https://stackoverflow.com/questions/5290003/how-to-set-legend-alpha-with-ggplot2, it suggests `+ guides(colour = guide_legend(override.aes = list(alpha = 1)))` – Jon Spring Apr 27 '22 at 08:35
  • Please share some code and reproducible data using `dput(df)`? So we can reproduce your problem. – Quinten Apr 27 '22 at 10:28
  • @JonSpring my code runs with it but the output remains the same. I am using the tmap package for a creating a map, it is very similar to ggplot, but guides() must be a newer update not implemented in tmap yet – Márton Apr 27 '22 at 10:37
  • The transparent colors of an object on map appear darker when the map has a color than the legend which has a white background, even though the alpha is the same. I am open to suggestions as to how the legend background color can be changed, but sounds less plausible – Márton Apr 28 '22 at 15:14
  • If I understood you correctly you want to have colors e.g. filling the map polygons (with alpha) and in the legend (without alpha). In my opinion that's not really reasonable since the legend then does not represent the colors that are present in the map (due to the different alpha's). If you only want to change the color of the legend background simply use ``legend.bg.color``. – mgrund Apr 29 '22 at 06:44

0 Answers0