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

Ploty image.save.as can't complete display Chinese #1106

Closed
Bloomberg-zhong opened this issue Aug 13, 2018 · 7 comments
Closed

Ploty image.save.as can't complete display Chinese #1106

Bloomberg-zhong opened this issue Aug 13, 2018 · 7 comments
Labels
bug something broken
Milestone

Comments

@Bloomberg-zhong
Copy link

Bloomberg-zhong commented Aug 13, 2018

when i use plotly func
plotly.plotly.image.save_as(self.fig, filename=filepath + '.png')

there is problem,it cannot complete display ,not only Traditional-Chinese but also Simplified -Chinese,and Simplified -Chinese is more serious, i think the problem is on unicode,but i can't find where to change it .

plotly.plotly.image.save_as(self.fig, filename=filepath + '.png')
self.fig['layout']['yaxis4']['title'] = '客戶數'
self.fig['layout']['yaxis4']['titlefont'] = dict(size=11)
self.fig['layout']['yaxis5']['title'] = '客戶勝率'
self.fig['layout']['yaxis5']['titlefont'] = dict(size=11)

promble

@Bloomberg-zhong Bloomberg-zhong changed the title Ploty image.save.as can't complete display chiese Ploty image.save.as can't complete display Chinese Aug 13, 2018
@jonmmease
Copy link
Contributor

Hi @zhonon , thanks for the report, I can see what you mean.

Here's the full example I used:

import plotly.graph_objs as go
import plotly.plotly as ply
fig = go.Figure(data=[go.Scatter(y=[2, 1, 4])])
chinese_char_str = '客戶數'
fig.layout.yaxis.title = chinese_char_str
ply.image.save_as(fig, filename='chinese_char_test.png')

plot

The good news is that when I test this using an early prototype version of our coming Orca integration for static image export it works properly:

chinese_char_test_orca

You can learn more about the orca project at https://github.com/plotly/orca. Orca will be well integrated into plotly.py for version 3.2, but in the meantime you can install and run it as a command line application (See instructions in the README linked above).

Orca has a lot of advantages of the plotly.plotly.image.save_as approach, so that's where we're going to focus our future image export efforts. In particular, its open source, free to use, works fully offline, and supports both raster (png. jpeg) and vector (svg, pdf, eps) output formats.

If you're interested in how this all comes together please check out the links above and let us know what you think.

@jonmmease jonmmease added the bug something broken label Aug 13, 2018
@jonmmease jonmmease added this to the v3.2.0 milestone Aug 13, 2018
@Bloomberg-zhong
Copy link
Author

thinks for you Answer。
so,there is no others way to solve this ?
i just want use this image in Email.
and solve this as simple as possible.

@jonmmease
Copy link
Contributor

jonmmease commented Aug 13, 2018 via email

@Bloomberg-zhong
Copy link
Author

i have try Method on
https://plot.ly/python/email-reports/
but i only can get this. so it's has no updata for a years
image

@jonmmease
Copy link
Contributor

Hi @zhonon ,

Here's what I mean about using the toolbar to save the image. Display the plot using one of the plot or iplot methods. Here I'll use plotly.plotly.plot.

import plotly.graph_objs as go
import plotly.plotly as ply
fig = go.Figure(data=[go.Scatter(y=[2, 1, 4])])
chinese_char_str = '客戶數'
fig.layout.yaxis.title = chinese_char_str
ply.plot(fig, filename='chinese_char_test.png', auto_open=True)

This will open the plot in a new browser tab. Then click the camera button in the toolbar to download the plot as a .png.

Here's a screen capture of the process:

saveimagetoolbar

Hope that helps!

@jonmmease
Copy link
Contributor

This use-case is now covered by the orca-based static image export coming in 3.2.0. See #1120

@jonmmease
Copy link
Contributor

Update: Programmatic static image export support has been released in 3.2.0: See https://medium.com/@plotlygraphs/plotly-py-end-of-summer-updates-5422c98b9058

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants