<legend id='qn6fz'><style id='qn6fz'><dir id='qn6fz'><q id='qn6fz'></q></dir></style></legend>

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

        • <bdo id='qn6fz'></bdo><ul id='qn6fz'></ul>

        如何将情节表达图保存到 html 或静态图像文件中?

        How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
        <i id='t7Bhj'><tr id='t7Bhj'><dt id='t7Bhj'><q id='t7Bhj'><span id='t7Bhj'><b id='t7Bhj'><form id='t7Bhj'><ins id='t7Bhj'></ins><ul id='t7Bhj'></ul><sub id='t7Bhj'></sub></form><legend id='t7Bhj'></legend><bdo id='t7Bhj'><pre id='t7Bhj'><center id='t7Bhj'></center></pre></bdo></b><th id='t7Bhj'></th></span></q></dt></tr></i><div id='t7Bhj'><tfoot id='t7Bhj'></tfoot><dl id='t7Bhj'><fieldset id='t7Bhj'></fieldset></dl></div>

          <tbody id='t7Bhj'></tbody>

            <bdo id='t7Bhj'></bdo><ul id='t7Bhj'></ul>
              <tfoot id='t7Bhj'></tfoot>
              <legend id='t7Bhj'><style id='t7Bhj'><dir id='t7Bhj'><q id='t7Bhj'></q></dir></style></legend>
            1. <small id='t7Bhj'></small><noframes id='t7Bhj'>

                  本文介绍了如何将情节表达图保存到 html 或静态图像文件中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  但是,我觉得用 plotly.express 保存图形非常棘手.

                  如何将 plotly.express 或 plotly plot 保存到单独的 html 或静态图像文件中?有人可以帮忙吗?

                  解决方案

                  更新答案:

                  使用较新版本的 plotly,

                  文件夹中显示的文件:

                  从这里您可以在任何浏览器或任何其他您想要的方式中打开文件.

                  这是使用 Notepad++

                  显示的内容

                  如果您不介意一些体力劳动,您可以使用工具栏保存一个 .png 版本:


                  静态图片的旧答案:

                  自动生成静态图像有点有点棘手.

                  如果您愿意,请查看 Static Image Export in Pythonhtml.

                  我喜欢使用包括 orca 在内的方法,可以生成各种图像文件.除了使用 npm 安装它之外,我还没有找到任何其他方法来安装它 node.js 如果你按顺序得到它,你只需要运行以下命令来启动并运行它(我在 Windows 上):

                  npm install -g electron@1.8.4 orcapip install psutil 请求

                  然后你可以用 fig.write_image("C:/plotlyplots/lifeExp.png") 改变上面代码片段的最后一行,生成一个 .png文件.

                  However, I feel saving the figure with plotly.express is pretty tricky.

                  How to save plotly.express or plotly plot into a individual html or static image file? Anyone can help?

                  解决方案

                  Updated answer:

                  With newer versions of plotly, static Image export in Python is a breeze. Just make sure to install kaleido using:

                  pip install -U kaleido
                  

                  or, for Anaconda:

                  conda install -c conda-forge python-kaleido
                  

                  And then run

                  fig.write_image("yourfile.png") 
                  

                  Filetypes such as .jpeg and .pdf are also available options.

                  Producing an individual html file is still very easy:

                  Just use plotly.offline.plot(fig, filename='C:/plotlyplots/canada_offline.html')

                  This will give you a html file of a plotly express bar chart with the name lifeExp in a desired folder. Remember import plotly and not only import plotly.express as px.

                  Complete code:

                  # imports
                  import plotly
                  import plotly.express as px
                  
                  # data
                  df = px.data.gapminder().query("continent=='Oceania'")
                  
                  # plotly express bar chart
                  fig = px.line(df, x="year", y="lifeExp", color='country')
                  
                  # html file
                  plotly.offline.plot(fig, filename='C:/plotlyplots/lifeExp.html')
                  

                  Plot:

                  File as it appears in the foler:

                  From here you can open the file in any browser or any other way you want.

                  Here's the content as it is displayed using Notepad++

                  If you don't mind a bit of manual labor, you dan save a .png version using the toolbar:


                  Old answer for static images:

                  Producing a static image automatically is a bit mote tricky.

                  Take a look at Static Image Export in Python if you prefer that to html.

                  I like to use the approach including orca that can produce a variety of image files. I haven't found any other way to install it other than using npm which is installed with node.js If you get that in order, you only have to go run the following to get it up and running (I'm on Windows):

                  npm install -g electron@1.8.4 orca
                  
                  pip install psutil requests
                  

                  Then you can change the last line in the snippet above with fig.write_image("C:/plotlyplots/lifeExp.png") to produce a .png file.

                  这篇关于如何将情节表达图保存到 html 或静态图像文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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?(情节:情节表达遵循什么颜色循环?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                  Plotly legend next to each subplot, Python(在每个子图旁边绘制图例,Python)

                      <bdo id='CvCBu'></bdo><ul id='CvCBu'></ul>

                      1. <legend id='CvCBu'><style id='CvCBu'><dir id='CvCBu'><q id='CvCBu'></q></dir></style></legend>

                      2. <tfoot id='CvCBu'></tfoot>
                          <tbody id='CvCBu'></tbody>
                        <i id='CvCBu'><tr id='CvCBu'><dt id='CvCBu'><q id='CvCBu'><span id='CvCBu'><b id='CvCBu'><form id='CvCBu'><ins id='CvCBu'></ins><ul id='CvCBu'></ul><sub id='CvCBu'></sub></form><legend id='CvCBu'></legend><bdo id='CvCBu'><pre id='CvCBu'><center id='CvCBu'></center></pre></bdo></b><th id='CvCBu'></th></span></q></dt></tr></i><div id='CvCBu'><tfoot id='CvCBu'></tfoot><dl id='CvCBu'><fieldset id='CvCBu'></fieldset></dl></div>
                      3. <small id='CvCBu'></small><noframes id='CvCBu'>