請問如何將error_y添加到fig.add_scatter?與 px.scatter 不同,引數 error_y 不適用于 fig.add_scatter。在我仔細查看的檔案中,我沒有找到任何合適的論據。它存在嗎?
import plotly.express as px
import numpy as np
import pandas as pd
import plotly.graph_objects as go
with open("file", "w") as f:
f.write("""1 27 10 20.10.2021
2 10 11 21.10.2021
3 10 2 28.10.2021
4 13 8 05.11.2021
5 17 5 17.11.2021""")
datum = np.loadtxt("file", unpack=True, dtype="str", usecols=[3])
cislo, K, H = np.loadtxt("file", unpack=True, usecols=[0, 1, 2])
d = {"Datum": datum, "B": K, "C": H, "cislo": cislo}
df = pd.DataFrame(data=d)
fig = px.scatter(df, x=[-100], y=[100], error_y=[10])
# How to add error_y to fig.add_scatter?
fig.add_scatter(
x=df["cislo"],
y=df["C"],
customdata=df["Datum"].values.reshape([len(df), 1]),
hoverinfo="skip",
mode="markers",
marker=dict(size=10, color="Purple"),
name="C",
)
fig.add_scatter(
x=df["cislo"],
y=df["B"],
customdata=df["Datum"].values.reshape([len(df), 1]),
hoverinfo="skip",
mode="markers",
marker=dict(size=10, color="Green"),
name="B",
)
fig.update_traces(
hovertemplate="<br>".join(
[
"<b>Value:</b> %{y:.0f}",
"<b>Date:</b> %{customdata[0]}",
]
)
)
fig.update_traces(mode="lines markers")
fig.show()
uj5u.com熱心網友回復:
這在檔案中有所介紹:
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/445432.html
標籤:python-3.x 情节地
