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

  1. <tfoot id='murML'></tfoot>
  2. <legend id='murML'><style id='murML'><dir id='murML'><q id='murML'></q></dir></style></legend>
      <bdo id='murML'></bdo><ul id='murML'></ul>

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

      如何用PLOTLY_EXPRESS绘制多线图?

      How to draw a multiple line chart using plotly_express?(如何用PLOTLY_EXPRESS绘制多线图?)
          <tbody id='XILrd'></tbody>
      1. <tfoot id='XILrd'></tfoot>
            <legend id='XILrd'><style id='XILrd'><dir id='XILrd'><q id='XILrd'></q></dir></style></legend>

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

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

                本文介绍了如何用PLOTLY_EXPRESS绘制多线图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我需要从数据帧的多列创建折线图。在 pandas 中,您可以使用如下代码绘制多线图:

                df.plot(x='date', y=['sessions', 'cost'], figsize=(20,10), grid=True)
                

                如何使用PLOTLY_EXPRESS执行此操作?

                推荐答案

                使用version 4.8 of Plotly.py,原问题中的代码现在几乎没有修改就被支持了:

                pd.options.plotting.backend = "plotly"
                df.plot(x='date', y=['sessions', 'cost'])
                

                上一次回答,截至2019年7月

                对于本例,您可以稍微不同地准备数据。

                df_melt = df.melt(id_vars='date', value_vars=['sessions', 'cost'])
                

                如果您将列(会话、成本)转置/融化到其他行中,则可以在color参数中指定新的列"变量"作为分区依据。

                px.line(df_melt, x='date' , y='value' , color='variable')
                

                Example plotly_express output

                这篇关于如何用PLOTLY_EXPRESS绘制多线图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

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

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