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

make savefig(..., "filename.svg") save self-contained SVG for plotlyjs #750

Closed
tpapp opened this issue Mar 28, 2017 · 4 comments
Closed

Comments

@tpapp
Copy link

tpapp commented Mar 28, 2017

MWE:

using Plots; plotlyjs()
savefig(plot(rand(100)), "/tmp/plot.svg")

produces a HTML file which calls Javascript to produce the SVG.

However,

plt = plot(rand(100))
PlotlyJS.savefig(plt.o, "/tmp/plot.svg")

produces an SVG. (workaround suggested by @piever on Gitter). It would be great if Plots.savefig and Plots.svg would do this instead.

@piever
Copy link
Member

piever commented Mar 29, 2017

I thought I'd make a PR: the issue is here and it'd be fixed if the show function was defined for svg as it is defined for the other formats (using the PlotlyJS method). Problem is, displaying plots in Jupyter notebook also calls _show with svg format, so if I change it there, the Jupyter plots go from being interactive to just displaying a static svg. I'm not sure what's the cleanest way of solving this and I couldn't figure out exactly what happens when you display in IJulia and why it calls _show with svg format whereas plotting in Electron doesn't.

@mkborregaard
Copy link
Member

Have you tested that interactivity is lost in IJulia if you change the code? I don't think we'd want to lost that.

@tpapp
Copy link
Author

tpapp commented Mar 29, 2017

Would the following upgrade path work:

  1. introduce another function or method which Jupyter can use, eg svg_dynamic,
  2. Make a fix for Jupyter to use that, let it trickle through,
  3. in the meantime, define a show method for MIME("image/svg") that can be used as a workaround,
  4. once the changes go through Jupyter, replace svg with the static version?

@piever
Copy link
Member

piever commented Mar 29, 2017

Found a cleaner solution: added a method to show html for PlotlyJS, so that now it doesn't resort to the svg method for plotting in IJulia. I've changed the svg to use PlotlyJS. I've also slightly changed the display in IJulia and it seems to resolve the flickering I add when using Interact. I'll add a PR right now.

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

3 participants