Skip to content

Legend mis-alignement for parsing greek letters using scale::parse_format #4814

@Sibojang9

Description

@Sibojang9

In the first figure, the right-hand side legend is correctly aligned with the regular ggplot code. However, the greek characters were mis-aligned when labels=parse_format() is used to parse "microgram" in the second figure, as indicated by the gap (white space) next to the legend "1 ug". The erratic alignment behavior sounds like a bug to me.

library(ggplot2)
library(scales)
data <- data.frame(x=c(1,2),y=c(1,2),c= c("10000~mu*g","1~mu*g"))
ggplot(data,aes(x=x,y=y,color=c)) + geom_point()

ggplot(data,aes(x=x,y=y,color=c)) + geom_point()+ scale_colour_discrete(labels=parse_format()) 

Created on 2022-04-25 by the reprex package (v2.0.1)

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