1

I am using plotly to create a horizontal bar chart in Google Colab using this library:

import plotly.graph_objects as go
fig = go.Figure()

It displays correctly on the screen, but when I try to print it to a PNG file using :

!pip install -U kaleido
fig.write_image(symbol + ' Financial Summary.png')

The PNG is created, but the Bar text is being truncated. Here is an image of the output.

Here are my settings for the Return on Invested Capital Bar. How can I get it to display the full text?

https://pastebin.com/YdhVBhM6

and here is the final fig.show() section:

https://pastebin.com/tJy0Jnw9

Any ideas?

3
  • What if you change the width of the figure? Commented Nov 11, 2021 at 23:41
  • 1
    You are a genius Derek O. I added a width and it worked beautifully. fig.update_layout(height = 1000, width = 1500, font=dict(size = 16), margin = {'t':0, 'b':0, 'l':40}) Commented Nov 12, 2021 at 1:13
  • Please do not use pastebin for code (or other text). Include relevant code in your question instead. Commented Nov 12, 2021 at 9:05

1 Answer 1

1

Adding a width solves the problem. Thanks to Derek O. Here is the revised code:

fig.update_layout(height = 1000,
                  width = 1500,
                  font=dict(size = 16),
                  margin = {'t':0, 'b':0, 'l':40})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.