plotly / plotly/plotly.py

Align the use of `y=` argument with `error_y` in `plotly.express`

未關閉
#4,909 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

feature P3
主要語言
Python
星號
18.8k
分支
2.8k
平均合併
16 小時 26 分鐘
30 天內合併 PR
21

描述

At the moment, I can plot multiple y series with an API that looks like this:

import pandas as pd
import plotly.express as px

data = {
    'X_Values': pd.date_range(start='2023-01-01', periods=10, freq='D'),
    'Y1_Values': [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],
    'Y2_Values': [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],
    'Y3_Values': [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],
}
df = pd.DataFrame(data)

px.scatter(df, x='X_Values', y=['Y1_Values', 'Y2_Values', 'Y3_Values'])

I would expect to be able to provide an array of error bars for each of the y's but that doesn't seem to be the case:

import pandas as pd
import plotly.express as px

data = {
    'X_Values': pd.date_range(start='2023-01-01', periods=10, freq='D'),
    'Y1_Values': [3, 5, 7, 9, 11, 13, 15, 17, 19, 21],
    'Y1_Errors': [0.5, 0.6, 0.7, 0.5, 0.8, 0.5, 0.7, 0.6, 0.5, 0.7],
    'Y2_Values': [2, 4, 6, 8, 10, 12, 14, 16, 18, 20],
    'Y2_Errors': [0.3, 0.5, 0.4, 0.6, 0.7, 0.5, 0.6, 0.4, 0.5, 0.6],
    'Y3_Values': [1, 3, 5, 7, 9, 11, 13, 15, 17, 19],
    'Y3_Errors': [0.4, 0.3, 0.6, 0.5, 0.7, 0.4, 0.5, 0.3, 0.6, 0.5],
}
df = pd.DataFrame(data)

px.scatter(df, x='X_Values', y=['Y1_Values', 'Y2_Values', 'Y3_Values'], error_y=['Y1_Errors', 'Y2_Errors', 'Y3_Errors'])

but this fails with

ValueError: All arguments should have the same length. The length of argument `error_y` is 3, whereas the length of  previously-processed arguments ['X_Values'] is 10

Can this get similar semantics to an array-like object in the y= argument?

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

使用 plotly.express.scatter 重現這些範例,首先處理 y 和 error_y 引數。比較類陣列 y 值的展開方式與 error_y 的驗證方式。當能夠為每個 y 系列提供相符的誤差陣列而不再出現所回報的長度錯誤,且相關行為已由測試涵蓋時,即視為完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
python
領域
data-visualization
Issue 類型
功能
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。