question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plots pane has problems saving images generated by Plotly

See original GitHub issue

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

The newly add feature: plots has problems with saving the plotted image produced by Plotly.

When using the Save Image As… button, the saved image will have the default size of 700x450 px. This cannot be changed even if the size is specified otherwise in plotly API.

If the image is saved by Plotly itself, the image will have a correct size (ex. 800x600 px).

What steps reproduce the problem?

  1. plot anything in Plotly.
  2. specify the image size.
  3. save the image using “Save Image As…” button in Spyder.

What is the expected output? What do you see instead?

The saved image will have a default size (i.e. 700x450) which cannot be changed.

Paste Traceback/Error Below (if applicable)


PASTE TRACEBACK HERE

Versions

  • Spyder version: 4.0.0
  • Python version: 3.7.3
  • Plotly version: 4.1.1

Dependencies

Reproducing the problem:

import plotly.graph_objects as go
import os

script_path = os.path.dirname(os.path.realpath(__file__))
animals=['giraffes', 'orangutans', 'monkeys']

fig = go.Figure([go.Bar(x=animals, y=[20, 14, 23])])

fig.update_layout(height = 600,
              width = 800,)
fig.show()
fig.write_image(script_path + '/fig.png')

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
ccordoba12commented, Dec 15, 2019

This is pretty nice @jnsebgosselin! I think we should add this to spyder-kernels, like this:

2reactions
jnsebgosselincommented, Dec 14, 2019

Can we do this in our side and register it when Plotly is imported? Or how does this work @jnsebgosselin?

I don’t know, I’ll take a look and report back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Static image export in Python - Plotly
Plotly allows you to save static images of your plots. Save the image to your local computer, or embed it inside your Jupyter...
Read more >
Not able to save plotly plots using to_image or write_image
This makes my VSCode go bananas, the terminal hangs and the program stops then and there. Everything works fine if I remove just...
Read more >
Problem with Plots or Graphics Device in the RStudio IDE
This error indicates that the margins of the particular plot are very large while the region allocated for the plot is too small....
Read more >
Plotly — Panel v0.14.2
The Plotly pane renders Plotly plots inside a panel. It optimizes the plot rendering by using binary serialization for any array data found...
Read more >
2 Saving Plots | Using R Plots in Documents
One strategy we could take to size our plots is to adjust the Plots pane. This allows for us to see how the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found