cetz-package / cetz-plot

Create Plots and Charts with CeTZ
GNU Lesser General Public License v3.0
7 stars 1 forks source link

plot: Manual legend manipulation #9

Closed tingerrr closed 5 days ago

tingerrr commented 1 month ago

I have a plot like so: image

Which is constructed sort of like this:

#cetz.chart({
  plot.add(label: $n'_min$, ...)
  plot.add(label: $n'_max$, ...)
  for value in values {
    plot.add(style: palette.purple, label: if value.t == 1 { $n$ })
  }
})

This is obviously simplified, but it should across what kind of structure the data has that I'm visualizing.

I would like to add an entry to the legend which more clearly communicates that n is every line in the purple palette, without actually adding 7 different lines.

Currently, there doesn't seem to be a way to easily add some entry to the legend of a plot manually, or for a group of elements in the plot. Ideally, I would manually add an item to the plot at the end, such that it renders a gradient of the palette. Alternatively, I could somehow tell the plot that they all share a label, and it would figure it out from their chosen colors.