Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continuous color legends #95

Open
ralsei opened this issue May 17, 2021 · 3 comments
Open

Continuous color legends #95

ralsei opened this issue May 17, 2021 · 3 comments

Comments

@ralsei
Copy link
Contributor

ralsei commented May 17, 2021

Currently, the legend only appears to be controllable with the #:label argument. Sometimes, however, this is not what is wanted. Namely, for example, take Figure 3.17 in socviz:
image

Due to the legend, this is not reproducible in plot, as the "color interval" effect towards the right is not controllable with just #:label (or at all, for that matter). It would be nice if this was the case.

@alex-hhh
Copy link
Collaborator

You can do these kinds of plots in plot, but perhaps it is more complex than necessary (see image below). While the legend generated by plot will not be able to use a "continuous color map", you can generate those using the pict package and attach them to the side of the plot (for bitmap plots) or just float them over the plot snip in interactive plots (ActivityLog2 has those kinds of custom legends as well).

The first step to making this easier using the plot package would be to define an API for this type of functionality and work out the implementation from there...

image

@ralsei
Copy link
Contributor Author

ralsei commented May 17, 2021

Yes, I was referring more specifically to the legend. The actual plot can be created using points and one of the maps from the colormaps package.

I think we have two options, and it is possible to take both:

  1. Integrate colored points, or point variants, in the points renderer, and vary its output in the legend
  2. Allow manual control of the legend, meaning that #:label wouldn't be the only way to set it

but regardless, it is still necessary to modify the way the legend is drawn to facilitate a "gradient continuous color" as shown in the attached image.

@alex-hhh
Copy link
Collaborator

alex-hhh commented Jul 8, 2021

Hi @ralsei, this is not exactly what you were looking for, but it may be of interest for creating the legend: https://alex-hhh.github.io/2021/07/shaded-area-plot.html

To adapt the legend from the above post to a continuous gradient, you could draw a rectangle using a special brush% with a linear-gradient%. This is not supported directly in the pict package, but the racket/draw facilities can be accessed from the pict package using the dc pict constructor. Note that I have not tried doing this, so I don't know if it would work or not...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants