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

geom_text: too small label size when applied log10 transformation #1267

Open
ASmirnov-HORIS opened this issue Dec 18, 2024 · 2 comments
Open
Labels
bug Something isn't working
Milestone

Comments

@ASmirnov-HORIS
Copy link
Collaborator

Example:

ggplot({'v': [1e10]}, aes(x='v')) + \
    geom_point(aes(size='v'), y=0) + \
    geom_text(aes(label='v'), y=1, size=10) + \
    scale_size(trans='sqrt')

Output:

Expected (like in ggplot2):

@alshan alshan added this to the New milestone Dec 30, 2024
@alshan
Copy link
Collaborator

alshan commented Dec 30, 2024

Since size=10 in geom_text() the size scale does not affect size of the text regardless of trans.

Is this issue about a difference in interpretation of size in lets-plot vs ggplot2? In lets-plot geom_text size is in px (doubled). I.e. 20 px in this case. In ggplot2 it might be pt or other units.

Please clarify.

@alshan alshan modified the milestones: New, 2025Q1 Dec 30, 2024
@ASmirnov-HORIS
Copy link
Collaborator Author

No, the issue has nothing to do with units. It is precisely that trans should not affect the constant size.

In lets-plot, removing trans changes the plot:

gggrid([
    ggplot({'v': [1e10]}, aes(x='v')) + \
        geom_point(aes(size='v'), y=0) + \
        geom_text(aes(label='v'), y=1, size=10) + \
        scale_size(trans='sqrt', guide='none'),
    ggplot({'v': [1e10]}, aes(x='v')) + \
        geom_point(aes(size='v'), y=0) + \
        geom_text(aes(label='v'), y=1, size=10) + \
        scale_size(guide='none'),
])

In ggplot2 it doesn't:

library(ggplot2)
library(cowplot)

plot_grid(
    ggplot(data.frame(v = c(1e10)), aes(x = v)) +
        geom_point(aes(size = v), y = 0) +
        geom_text(aes(label = v), y = 1, size = 10) +
        scale_size(trans = "sqrt", guide = "none"),
    ggplot(data.frame(v = c(1e10)), aes(x = v)) +
        geom_point(aes(size = v), y = 0) +
        geom_text(aes(label = v), y = 1, size = 10) +
        scale_size(guide = "none")
)

@alshan alshan added the bug Something isn't working label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants