Skip to content

Continuous color legends #95

Description

@ralsei

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.

Activity

  1. alex-hhh commented on May 17, 2021

    @alex-hhh
    SponsorCollaborator

    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

  2. ralsei commented on May 17, 2021

    @ralsei
    ContributorAuthor

    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.

  3. alex-hhh commented on Jul 8, 2021

    @alex-hhh
    SponsorCollaborator

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions