<tfoot id='kyuKL'></tfoot>

          <bdo id='kyuKL'></bdo><ul id='kyuKL'></ul>
      1. <small id='kyuKL'></small><noframes id='kyuKL'>

        <i id='kyuKL'><tr id='kyuKL'><dt id='kyuKL'><q id='kyuKL'><span id='kyuKL'><b id='kyuKL'><form id='kyuKL'><ins id='kyuKL'></ins><ul id='kyuKL'></ul><sub id='kyuKL'></sub></form><legend id='kyuKL'></legend><bdo id='kyuKL'><pre id='kyuKL'><center id='kyuKL'></center></pre></bdo></b><th id='kyuKL'></th></span></q></dt></tr></i><div id='kyuKL'><tfoot id='kyuKL'></tfoot><dl id='kyuKL'><fieldset id='kyuKL'></fieldset></dl></div>
        <legend id='kyuKL'><style id='kyuKL'><dir id='kyuKL'><q id='kyuKL'></q></dir></style></legend>

        如何以 png 格式保存 Plotly 离线图?

        How to save Plotly Offline graph in format png?(如何以 png 格式保存 Plotly 离线图?)

          <bdo id='epwSi'></bdo><ul id='epwSi'></ul>
          <tfoot id='epwSi'></tfoot>
            <legend id='epwSi'><style id='epwSi'><dir id='epwSi'><q id='epwSi'></q></dir></style></legend>

                <tbody id='epwSi'></tbody>

                • <i id='epwSi'><tr id='epwSi'><dt id='epwSi'><q id='epwSi'><span id='epwSi'><b id='epwSi'><form id='epwSi'><ins id='epwSi'></ins><ul id='epwSi'></ul><sub id='epwSi'></sub></form><legend id='epwSi'></legend><bdo id='epwSi'><pre id='epwSi'><center id='epwSi'></center></pre></bdo></b><th id='epwSi'></th></span></q></dt></tr></i><div id='epwSi'><tfoot id='epwSi'></tfoot><dl id='epwSi'><fieldset id='epwSi'></fieldset></dl></div>

                  <small id='epwSi'></small><noframes id='epwSi'>

                  本文介绍了如何以 png 格式保存 Plotly 离线图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I am using Plotly offline to generate graph in python.

                  As per the documentation below,

                  https://plot.ly/python/offline/

                  Here is my code, which perfectly generates C:/tmp/test_plot.html file.

                  import plotly.offline as offline
                  
                  offline.init_notebook_mode()
                  
                  offline.plot({'data': [{'y': [4, 2, 3, 4]}], 
                                 'layout': {'title': 'Test Plot', 
                                            'font': dict(family='Comic Sans MS', size=16)}},
                               auto_open=False, filename='C:/tmp/test_plot')
                  

                  How can I save this graph as png instead of html?

                  解决方案

                  offline.plot method has image='png and image_filename='image_file_name' attributes to save the file as a png.

                  offline.plot({'data': [{'y': [4, 2, 3, 4]}], 
                                'layout': {'title': 'Test Plot', 
                                           'font': dict(family='Comic Sans MS', size=16)}},
                               auto_open=True, image = 'png', image_filename='plot_image',
                               output_type='file', image_width=800, image_height=600, 
                               filename='temp-plot.html', validate=False)
                  

                  See more details inside offline.py or online at plotly.

                  However, one caveat is that , since the output image is tied to HTML, it will open in browser and ask for permissions to save the image file. You can turn that off in your browser settings.

                  Alternately, You may want to look at plotly to matplotlib conversion using plot_mpl.
                  Following example is from offline.py

                  from plotly.offline import init_notebook_mode, plot_mpl
                      import matplotlib.pyplot as plt
                  
                      init_notebook_mode()
                  
                      fig = plt.figure()
                      x = [10, 15, 20, 25, 30]
                      y = [100, 250, 200, 150, 300]
                      plt.plot(x, y, "o")
                  
                      plot_mpl(fig)
                      # If you want to to download an image of the figure as well
                      plot_mpl(fig, image='png')
                  

                  这篇关于如何以 png 格式保存 Plotly 离线图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                    <bdo id='cOKsZ'></bdo><ul id='cOKsZ'></ul>

                      <tbody id='cOKsZ'></tbody>
                    1. <legend id='cOKsZ'><style id='cOKsZ'><dir id='cOKsZ'><q id='cOKsZ'></q></dir></style></legend>
                      1. <tfoot id='cOKsZ'></tfoot>

                            <small id='cOKsZ'></small><noframes id='cOKsZ'>

                            <i id='cOKsZ'><tr id='cOKsZ'><dt id='cOKsZ'><q id='cOKsZ'><span id='cOKsZ'><b id='cOKsZ'><form id='cOKsZ'><ins id='cOKsZ'></ins><ul id='cOKsZ'></ul><sub id='cOKsZ'></sub></form><legend id='cOKsZ'></legend><bdo id='cOKsZ'><pre id='cOKsZ'><center id='cOKsZ'></center></pre></bdo></b><th id='cOKsZ'></th></span></q></dt></tr></i><div id='cOKsZ'><tfoot id='cOKsZ'></tfoot><dl id='cOKsZ'><fieldset id='cOKsZ'></fieldset></dl></div>