[英]Categorical Scatter Plot with Dash/Plotly
我正在嘗試像這樣制作分類散點圖 plot:
這應該是一個分類散點圖 plot,其離散 x 值由位置(井)與時間點中的元素計數表示。
我寫了這段代碼:
df = pd.read_excel (r'file.xlsx')
fig = go.Figure()
fig.add_trace(
go.Scatter(
x = [df['Well A'], df['Well B'],df['Well C'],df['Well D']],
y = df['Time Point'],
mode='markers'
)
)
結果我得到了這個:
這太瘋狂了,我什至不知道那里發生了什么。 能否請你幫忙?..
PS 我的 df 看起來像這樣:
請幫忙:(
如果這是您想要的結果:
for c in df.columns[1:]:
fig.add_trace(go.Scatter(x = df['Time Point'], y = df[c],
mode = 'markers',
name = c
)
)
import pandas as pd
import numpy as np
import plotly.graph_objects as go
import plotly.express as px
obs = 8
df = pd.DataFrame({'Time Point': [1,2,3,4,5,6,7,8],
'Well A':np.random.randint(10, size=8),
'Well B':np.random.randint(10, size=8),
'Well C':np.random.randint(10, size=8),
'Well D':np.random.randint(10, size=8)})
fig = go.Figure()
for c in df.columns[1:]:
fig.add_trace(go.Scatter(x = df['Time Point'], y = df[c],
mode = 'markers',
name = c
)
)
fig.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.