Reputation: 131
I am trying to make a categorical scatter plot like this:
This is supposed to be a categorical scatter plot with discrete x values represented by counts of elements in locations(Wells) vs Time Point.
I have written this code:
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'
)
)
And I get this as a result:
Which is crazy, I have no idea what is even happening there. Could you please help?..
P.S. My df looks like this:
Please, help :(
Upvotes: 2
Views: 427
Reputation: 61084
If this is your desired result:
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()
Upvotes: 2