Skip to content

Latex/Automargin issue: badly positioned markers #5000

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

Closed
kndidox opened this issue Jul 15, 2020 · 11 comments
Closed

Latex/Automargin issue: badly positioned markers #5000

kndidox opened this issue Jul 15, 2020 · 11 comments
Labels
bug something broken regression this used to work

Comments

@kndidox
Copy link

kndidox commented Jul 15, 2020

Hello guys, first of all thanks for such an amazing work with Plotly.

I understand that much progress has been made with resolving the automargin issues... however, I wanted that to bring to your attention that this still remains unresolved. ...

I am experiencing a curious bug when i try to create some plots with multiple axis and legends in latex.

When the mathjax library is loaded, the plot paint some markers to the right of the desired position, my first "solution" to this was to call the relayout method, and this kinda works, but when i call the toImage method to save my plot my markers are now again in the wrong position.

You can reproduce all the mentioned above in this: Fix Issue with MathJax + relayout

i have created two more codepen's explaining the problem
1- Correct marker display without mathjax & relayout
2- Incorrect marker display without mathjax & relayout

@sarabiaf
Copy link

Let me start by saying that I have been a user of plotly for a couple of years now, and I really appreciate all your efforts and have enjoyed using the program.    I was running into a similar issue to the one posted by kndidox, and while looking for a solution I ran into his post.  

I must confess that his post gave me chills.  This is not your typical problem, where the margins are not quite what I would like them to be, or the title does not show well, etc.  In this case, the integrity of the data being presented is compromised.   In his "correct" plot, the subplot on the right show $E_d$ with an average value of 15, while when using mathjax the data seems to oscillate around 100 (that is a huge discrepancy).

I use auto margins and mathjax all the time, and I am pretty sure most of the scientific community does too.  I cannot help to wonder how many plots I have published in the last couple of years where the data is inadvertently shown incorrectly.   
I understand that time and resources are quite limited and that the people who support plotly are doing the best they can, and I really hope that my post is not really taken in the wrong way.  However, I think that at the very least, the documentation should indicate the mathjax + automargins are not ready to be used reliably.  This kind of issue can have very serious implications for a lot of people.  

I wish I could help more than just offering commentary from the peanut gallery, but unfortunately, this level of programming is way above my head.  I think the community could really benefit from a response to this post; whether there is a fix for this issue, or if certain functionalities should not be used yet. 

Thank you.

@alexcjohnson
Copy link
Collaborator

Thanks @kndidox - confirmed, here is a simplified reproduction: https://codepen.io/alexcjohnson/pen/bGExyLW?editors=1001

Some observations:

  • It only seems to affect subplots whose left edge moved, due to automargin involving MathJax - but it need not be the MathJax element itself that set the final margin.
  • The data scale looks correct (not the larger scale it had prior to the margin change) - it's just offset. This bodes well for fixing the bug as it implies the plotting process itself was done correctly, it's probably just that the container we're plotting into hasn't had its position updated properly.
  • The bug appears between v1.42.5 and v1.43.0 of plotly.js - ie 18 months old. I'm guessing it comes from Clean up automargin pipeline a bit #3323
  • Anything that causes a full redraw (for example, click trace "xyz$" in the legend to hide it) will fix the issue (though I bet it would recur if you cause an update that changes the automargin calculation)

@alexcjohnson alexcjohnson added bug something broken regression this used to work labels Jul 15, 2020
@alexcjohnson
Copy link
Collaborator

Two more tidbits:

  • If you cause the margins to autorange via MathJax in an axis tick label, the problem goes away, even if the legend still has MathJax. So it seems like the issue is specific to the legend (maybe also colorbars with mathjax in the title? I haven't tested that.) https://codepen.io/alexcjohnson/pen/zYrJVVB?editors=0011
  • "subplots whose left edge moved" is the correct category: if the first x axis is moved so its domain does not start at 0, then this subplot has shifted data too, because its left edge moves farther left when the right margin expands. But I bet "subplots whose top edge moved" also have a problem - for example if the legend is drawn on the bottom (also not tested.)

@sarabiaf
Copy link

Alex, Thank you for looking into this. I can confirm that this same issue also occurs when the legend is placed above the graphs. It seems that you have a protocol in place for going through these bugs in a certain order. Do you think that this will be something that may be fixed soon, or shall we avoid using Mathjax+automargins for the time being.... thank you for your feedback.

@sarabiaf
Copy link

To follow up on my previous message. See the graph attached. All data is shifted upwards....
image

@nicolaskruchten
Copy link
Contributor

nicolaskruchten commented Jul 16, 2020

This is indeed a pretty serious bug, and we'll try to get it fixed ASAP (days not weeks).

I think the community could really benefit from a response to this post; whether there is a fix for this issue, or if certain functionalities should not be used yet.

As a rule, we never release functionality which we feel "should not be used yet"! :)

From time to time, bugs do creep in, especially in rarely-encountered interactions between features and when they are reported, we work hard to replicate them, respond to the community and fix them promptly, as in this case. This bug was reported yesterday (after having been in the wild for a year and a half, so we're assuming not that many people have encountered it), and we've already narrowed in on the source and scope, so give us another couple of days and we'll have a fix in place.

@sarabiaf
Copy link

Nicolas, I have no doubt that you guys are as thorough as it is humanly possible... thank you for your response, your prompt attention to this matter, and especially for all the time you and your team spend working on this amazing project!!!

@nicolaskruchten nicolaskruchten changed the title Bug: Automargin issue on scatter plots Latex/Automargin issue: badly positioned markers Jul 22, 2020
@kndidox
Copy link
Author

kndidox commented Sep 8, 2020

Nicolas, could you provide any update on this? You mentioned in your post above that you anticipated that this will be resolved in "days".

Is there any particular version that includes the fix for this issue?

Thank you very much.
Candido.

@nicolaskruchten
Copy link
Contributor

This bugfix got deprioritized behind some sponsored work unfortunately, so while we will definitely fix it, it's probably on the order of weeks-from-now at this point.

@sarabiaf
Copy link

sarabiaf commented Mar 4, 2021

Hi, I was just wondering about this. It has been a few months not being able to use latex. Any updates would be greatly appreciated. Thank you!

@gvwilson
Copy link
Contributor

Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken regression this used to work
Projects
None yet
Development

No branches or pull requests

5 participants