1

I've been having fun playing around with the riverplot package, as in the below example.

Is there a way to add a legend to a riverplot, showing what the colors correspond to? I'm imagining something below the plot with blocks of colors and text saying what those colors are.

library(riverplot)


river <- riverplot.example()
test <- plot(river,plot_area=0.9)


zx8754
  • 52,746
  • 12
  • 114
  • 209
PaulB
  • 299
  • 1
  • 11
  • Did you try `legend()`? Try: `legend(0, 1, c("A", "B"))`. – zx8754 Nov 15 '21 at 14:58
  • z8754 - do I then manually add the colors? Do you know how that is done? – PaulB Nov 15 '21 at 15:52
  • I don't think it needs a legend, as the text is already on the plot, defining each colour. For example "H" is red, "A" is green, etc. – zx8754 Nov 15 '21 at 16:37
  • Yes, we would need to assign colours manually if we intend to use legend, something like: `legend("bottomright", legend = c("A", "H"), fill = c("red", "green"))` – zx8754 Nov 15 '21 at 16:40
  • Possible duplicate https://stackoverflow.com/q/13936223/680068 – zx8754 Nov 15 '21 at 16:41

0 Answers0