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

problem with log10 axis ticks formatting and legend overflow #846

Closed
Zaf4 opened this issue Aug 14, 2023 · 5 comments
Closed

problem with log10 axis ticks formatting and legend overflow #846

Zaf4 opened this issue Aug 14, 2023 · 5 comments

Comments

@Zaf4
Copy link

Zaf4 commented Aug 14, 2023

Increasing the plot size from ggsize(400,300) to ggsize(800,600) leads to addition of ticks that are not integer powers of 10. As you can see in the second plot it adds ticks for values which corresponds to the 10 to the power of n+0.5.

Additionally, when setting manual limits (xlim() ylim()), legend overflows out of the plot which is visible in both plots below.

ax3 = (ggplot(qfitm,aes(x='t',y='value',color='case'))+
    geom_point(size=3,data=durm)+
    geom_line()+
    ggsize(400,300)+
    scale_y_log10()+ylim(0.7,100000)+
    scale_x_log10()+xlim(0.7,10000)+
    theme_classic()+
    scale_color_viridis()
    )
ax3

image

ax3 = (ggplot(qfitm,aes(x='t',y='value',color='case'))+
    geom_point(size=3,data=durm)+
    geom_line()+
    ggsize(800,600)+
    scale_y_log10()+ylim(0.7,100000)+
    scale_x_log10()+xlim(0.7,10000)+
    theme_classic()+
    scale_color_viridis()
    )
ax3

image

@alshan
Copy link
Collaborator

alshan commented Aug 15, 2023

Hi, you can correct ticks by defining desired scale 'breaks' manually:

scale_x_log10(breaks=[1, 10, 100, 1000, 10000])

The legend overflow situation is more concerning. Could you add the following theme settings to your plot:

theme(plot_background=element_rect(color="red", size=4), legend_background=element_rect(color="blue", size=4))

and then describe the result?

If you can save plot to a SVG file and attach it to this issue that would help as well.

@Zaf4
Copy link
Author

Zaf4 commented Aug 15, 2023

Thanks for the suggestion on manual breaks. However, I think breaks, by default, should only be 10^n in log10 scale.

As for the overflow, here is the result:

sample

@alshan
Copy link
Collaborator

alshan commented Aug 16, 2023

This is an issue with our plot layout. It seems we do not handle tick labels overflow correctly (the label "10,000" goes beyond the axis length) which results in a partially trimmed legend.

As a workaround you can
a) increase upper limit along the x-axis: + xlim(None, 10400)
b) reposition the legend, put it ontop, below or inside the plot

@Zaf4
Copy link
Author

Zaf4 commented Aug 16, 2023

Thank you for your suggestions. I just wanted to point out the problems.

@alshan
Copy link
Collaborator

alshan commented Aug 16, 2023

Appreciate it, I've submitted 2 related issues:

@alshan alshan added this to the New milestone Aug 16, 2023
@alshan alshan modified the milestones: New, 2023Q4 Sep 29, 2023
@Zaf4 Zaf4 closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants