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

        <bdo id='3HZR3'></bdo><ul id='3HZR3'></ul>
    1. <tfoot id='3HZR3'></tfoot>

    2. <small id='3HZR3'></small><noframes id='3HZR3'>

        更改 pandas 绘图后端以获取交互式绘图而不是 matplotlib 静态绘图

        Change pandas plotting backend to get interactive plots instead of matplotlib static plots(更改 pandas 绘图后端以获取交互式绘图而不是 matplotlib 静态绘图)
      1. <tfoot id='Am4me'></tfoot>

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

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

                    <tbody id='Am4me'></tbody>
                  <legend id='Am4me'><style id='Am4me'><dir id='Am4me'><q id='Am4me'></q></dir></style></legend>
                  <i id='Am4me'><tr id='Am4me'><dt id='Am4me'><q id='Am4me'><span id='Am4me'><b id='Am4me'><form id='Am4me'><ins id='Am4me'></ins><ul id='Am4me'></ul><sub id='Am4me'></sub></form><legend id='Am4me'></legend><bdo id='Am4me'><pre id='Am4me'><center id='Am4me'></center></pre></bdo></b><th id='Am4me'></th></span></q></dt></tr></i><div id='Am4me'><tfoot id='Am4me'></tfoot><dl id='Am4me'><fieldset id='Am4me'></fieldset></dl></div>
                • 本文介绍了更改 pandas 绘图后端以获取交互式绘图而不是 matplotlib 静态绘图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我使用 pandas df.plot() 时,它使用 matplotlib 作为默认的绘图后端.但这会创建静态图.

                  我想要交互式绘图,所以我必须更改熊猫绘图背景.

                  当我使用 .plot() 时,如何更改 pandas 的绘图后端以让不同的库创建我的绘图?

                  When I use pandas df.plot() it has matplotlib as a default plotting backend. But this creates static plots.

                  I would like interactive plots, so I have to change the pandas plotting background.

                  How do I do change the plotting backend of pandas to have a different library creating my plots when i use .plot()?

                  推荐答案

                  你需要 pandas >= 0.25 来改变 pandas 的绘图后端.

                  可用的绘图后端有:

                  • matplotlib
                  • hvplot >= 0.5.1
                  • holoviews
                  • pandas_bokeh
                  • plotly >= 4.8
                  • altair

                  所以,默认设置是:

                  pd.options.plotting.backend = 'matplotlib'
                  

                  您可以更改 pandas 使用的绘图库,如下所示.在这种情况下,它将 hvplot/holoviews 设置为绘图后端:

                  You can change the plotting library that pandas uses as follows. In this case it sets hvplot / holoviews as the plotting backend:

                  pd.options.plotting.backend = 'hvplot'
                  

                  或者也可以使用(基本一样):

                  pd.set_option('plotting.backend', 'hvplot')
                  

                  现在您将 hvplot/holoviews 作为 pandas 的绘图后端,它将为您提供交互式 holoviews 图而不是静态 matplotlib 图.

                  Now you have hvplot / holoviews as your plotting backend for pandas and it will give you interactive holoviews plots instead of static matplotlib plots.

                  当然,您需要安装库 hvplot/holoviews + 依赖项才能正常工作.

                  Of course you need to have library hvplot / holoviews + dependencies installed for this to work.

                  这是一个生成交互式绘图的代码示例.它使用标准的 .plot() pandas 语法:

                  import numpy as np
                  import pandas as pd
                  
                  import hvplot
                  import hvplot.pandas
                  
                  pd.options.plotting.backend = 'hvplot'
                  
                  data = np.random.normal(size=[50, 2])
                  
                  df = pd.DataFrame(data, columns=['x', 'y'])
                  
                  df.plot(kind='scatter', x='x', y='y')
                  

                  这篇关于更改 pandas 绘图后端以获取交互式绘图而不是 matplotlib 静态绘图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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='gbf0j'></bdo><ul id='gbf0j'></ul>

                      <tfoot id='gbf0j'></tfoot>

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

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