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

Mismatch Between Cell Output and Rendering in Figure Directive #1702

Open
agahkarakuzu opened this issue Dec 18, 2024 · 2 comments
Open

Mismatch Between Cell Output and Rendering in Figure Directive #1702

agahkarakuzu opened this issue Dec 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@agahkarakuzu
Copy link

I have a labeled cell (#| label: fig1-cell) whose output (in jupyter lab) is the following interactive (plotly) figure:

pio.renderers.default = "plotly_mimetype"

...

fig.update_layout(
    title='Sentient Array of Knowledge Unraveling and Assessment (SAKURA)',
    hovermode='closest',
    autosize=True,
    width=850,
    height=850,
    paper_bgcolor = "white",
    plot_bgcolor = "white")
fig.show()

Image

Here, scatter markers are nicely aligned with the background image, and I set figure dimensions 850x850 explicity.

Then in the markdown I define my directive as:

:::{figure} #fig1-cell
:label: fig1
:align: center
:width: 850px
:height: 850px
Caption
:::

However, the output looks like this:

Image

I cannot figure out why the scatter markers are transformed in the myst webpage. I'd be glad if anyone could help.

Thanks!

@agahkarakuzu agahkarakuzu added the bug Something isn't working label Dec 18, 2024
@stevejpurves
Copy link
Contributor

stevejpurves commented Dec 18, 2024

Guessing that the output here is an svg / vector though?

Only thing I can think of is that css in myst is somehow impacting that. It almost looks like a rotation+scale transform though not just a scale along the main axes. I would try using the browser dev tools to inspect the classes / styles applied to the markers in both jupyter lab and myst and try to get a sense of what the differences are, to see if any classes / styles are overridden in the myst but applied/active in jlab -- especially if I could narrow it down to a particular class name that could be colliding - that's just a starting point though.

But! another angle are the respective plotly versions, we are building myst with a specific version of the plotly plugin just now. See https://github.com/jupyter-book/myst-theme/blob/ca8893f967a551ba02d3ec1022a056c2750a4563/packages/jupyter/package.json#L32

@agahkarakuzu
Copy link
Author

Guessing that the output here is an svg / vector though?

It is html (yet indeed rendered under main-svg), you can download it from here:

https://drive.google.com/file/d/1brfCGzJ_zW0GYHBWyB7im12iavABb1by/view?usp=sharing

and myst page is here.

Div class="plot-container plotly" is 850x850, and the figure appears as it should.

I did some digging, the only obvious transformation I could see for the scatter was this:

Image

and that does not really explain the transformation here 🧐

My plotly version is plotly==5.11.0

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