Git Product home page Git Product logo

Comments (8)

pirrmann avatar pirrmann commented on May 29, 2024 2

There is a scale parameter in Plotly.toImage in the PuppeteerSharpRenderer here.

+ $".then(x => Plotly.toImage(x, {{ format: '{StyleParam.ImageFormat.toString format}', scale: 1, width: {width}, height: {height} }}))"

It's just that we don't allow it to surface in the API, but I don't see what would prevent us from doing that...

from plotly.net.

pirrmann avatar pirrmann commented on May 29, 2024 1

Hmm weird, that parameter is not documented on the plotly.js function reference. Anyways, i'll try it and check whether it has the expected results.

This had an effect back when I first contributed to Plotly.NET :) #179

from plotly.net.

kMutagene avatar kMutagene commented on May 29, 2024

I have done some digging in the docs of the function that is used in the browser to generate these images, and it sadly seems like there is no direct option for this. Other rendering engines for plotly.py support a scale parameter, but that does not seem to be an option for plotly.toImage, which is used in the PuppeteerSharpRenderer.

This thread goes a bit into details on a workaround: plotly/dash-core-components#403 (comment) . It involves using the ToImageButtons, which can be used on a plot displayed in the browser to offer a button to download a plot as image. On that button, you can set the scale (see here).

However, this is a manual process and therefore no real solution for static image export. I'd suggest going the route of the issue i mentioned - exporting to svg and using another program to export the svg to a correctly scaled image format (this is also how i usually make figures publication-ready).

from plotly.net.

nhirschey avatar nhirschey commented on May 29, 2024

I see, thank you for the svg tip @kMutagene, I understand now why your publication example charts use svg. Time to learn inkscape...

from plotly.net.

kMutagene avatar kMutagene commented on May 29, 2024

There is a scale parameter in Plotly.toImage in the PuppeteerSharpRenderer here

Hmm weird, that parameter is not documented on the plotly.js function reference. Anyways, i'll try it and check whether it has the expected results.

from plotly.net.

kMutagene avatar kMutagene commented on May 29, 2024

Just played around and can confirm that scale works (kinda). The image has a larger size with the same DPI (instead of increasing the dpi on the same size), so i guess increasing the scale and then downsizing the image should have the intended effect right?

Still, very weird to not document this at the js docs. I'll prepare an update to the whole render engine thing soon.

from plotly.net.

kMutagene avatar kMutagene commented on May 29, 2024

would this achieve what you need @nhirschey ?

from plotly.net.

kMutagene avatar kMutagene commented on May 29, 2024

closing this, it will be available with the next major version release

from plotly.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.