Thanks to visit codestin.com
Credit goes to github.com

Skip to content

The 'NA' label is not displayed on axis.text with element_markdown() #121

@jgires

Description

@jgires

ggtext() modifies ggplot's default behavior, which is to display the label 'NA' in axis texts.

For example:

library(tidyverse)
library(ggtext)

tibble(
  group = c("group1", "group2", "group3", NA, "**total**"),
  value = c(-0.5, 0.5, 2, 3, 2)
)  %>%
  ggplot(aes(value, group)) + 
  geom_col(alpha = 0.5, fill = "purple") + 
  theme(
    axis.text.y = element_markdown()
  )

Image

VS

tibble(
  group = c("group1", "group2", "group3", NA, "**total**"),
  value = c(-0.5, 0.5, 2, 3, 2)
)  %>%
  ggplot(aes(value, group)) + 
  geom_col(alpha = 0.5, fill = "orange2")

Image

Is there any way to change element_markdown()'s behavior so that it displays the 'NA' label without first transforming the missing NA value into a string modality “NA”? The way ggplot handles NAs by default is very useful to me (automatic color, etc), and using ggtext() then requires major transformations in my functions.

Thank you!

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