Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: Missing values in colourbars#6023

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
teunbrand wants to merge7 commits intotidyverse:main
base:main
Choose a base branch
Loading
fromteunbrand:bar_missing

Conversation

@teunbrand
Copy link
Collaborator

@teunbrandteunbrand commentedAug 2, 2024
edited
Loading

This PR aims tofix#4567.

Briefly,guide_colourbar() andguide_coloursteps() use theGuideLegend class to render a key for missing values.
Note that continuous scales never automatically includeNA in breaks (AFAIK), which means that you'd have to add these manually.
It'd also will prevent some complaints that suddenly the colourbars showNAs by default (as they don't).

In the plot below you can see a demo of what these look like. Note that puttingNA as the first break will put it on top of the bar, whereas using it as any other break will put it on the bottom. However, maybe we should reverse this logic to follow the order of the other breaks?

devtools::load_all("~/packages/ggplot2")#> ℹ Loading ggplot2brks<- c(10,15,20,25,30)ggplot(mpg, aes(displ,hwy))+  geom_point(aes(colour=cty,fill=cty),shape=21)+# NA break first  scale_colour_viridis_c(breaks= c(NA,brks),labels= c("missing",brks),na.value="red"  )+# NA break last  scale_fill_viridis_c(breaks= c(brks,NA),option="inferno",na.value="dodgerblue"  )

Created on 2024-08-02 withreprex v2.1.1

I'm not 100% happy with the code as-is; it feels a little bit messy. Most of the logic is captured inGuide$assemble_drawing() but it doesn't quite feel like the correct place. In addition, getting binned breaks to includeNA is messier than I'd like. Lastly, maybe we should also do this forguide_bins(), but I feel like it has less priority due to it being a more niche guide (and I'd rather not mess with binned breaks again).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Feature request: plotting the NA info in the legend when using scales withna.value=

1 participant

@teunbrand

[8]ページ先頭

©2009-2025 Movatter.jp