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

How to specify plotly version #7

Closed
disberd opened this issue Aug 11, 2023 · 2 comments · Fixed by #9
Closed

How to specify plotly version #7

disberd opened this issue Aug 11, 2023 · 2 comments · Fixed by #9

Comments

@disberd
Copy link
Member

disberd commented Aug 11, 2023

I was using PlotlyKaleido today to save a figure that I generated using the latest version of Plotly (2.25.1)

When trying to save the Plot object using PlotlyKaleido, the figure is slightly difference.

More specifically I used the tickmode = sync option that was added in version 2.18.0 of plotly to have matching ticks between two y axis but while this works correctly on the plot object rendered on the Pluto notebook, this does not result from the generated image from savefig, making me believe that kaleido is internally using a version of plotly that is older than 2.18.

Is there a way to specify which version of plotly to use?

@BeastyBlacksmith
Copy link
Member

BeastyBlacksmith commented Aug 11, 2023

My guess is, that we need a new build of Kaleido_jll It had no recent release, but it is also unclear to me, what version they use internally

@disberd
Copy link
Member Author

disberd commented Aug 11, 2023

I just tried working with the process arguments and it's possible to specify the plotly version as a flag.
I also have no clear clue about which version of plotly is used by default.

What I managed to do to fix the problem was replace the start() function as such:

@eval PlotlyKaleido function start()
    # Unchanged first 2 commands

    url = "https://cdn.plot.ly/plotly-2.25.1.min.js" # URL of the JS library with the target version
    # Add the url to the initialization command using the `plotlyjs` argument below
    BIN = Sys.isapple() ? `$(cmd) plotly --plotlyjs=$url --disable-gpu --single-process` : `$(cmd) plotly --plotlyjs=$url --disable-gpu --no-sandbox`

    # Rest of the function unchanged
end

With the following example plot object:

using PlotlyBase
plt = let
	sp = Subplots(;specs = fill(Spec(;secondary_y = true), 1, 1))
	l = Layout(sp)
	p = Plot(l)
	add_trace!(p, scatter(y = rand(4)))
	add_trace!(p, scatter(y = rand(4)); secondary_y = true)
	l[:yaxis2][:tickmode] = "sync"
	p
end

I get the image without the axis sync with the original start function:
image

while I get the correct plot when forcing the version 2.25.1 with the hack above:
image

Overall I think it would be good to support restarting the process with a specified version of the library (and it seems easy to specify, we just need to decide the API to allow this)

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

Successfully merging a pull request may close this issue.

2 participants