Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Problem about trace which has a condition on y value

Hi,
I am trying to plot “trace6_7” which has a condition on y value. it only display part of data.
However trace_all which has no condition on y axis displays all data correctly.

There might be on the conditioning (or anything else). I couldn’t understand.
what might be the problem ?
here is the the structure

trace6_7= go.Scatter(
x=df.index,
y= df[(df[‘M’] >= 6) & ( df[‘M’] < 7) ][‘M’].astype(float),
mode=‘markers’,
marker=dict(size=10, color=‘navy’)

     )

trace_all= go.Scatter(
x=df.index,
y=df[‘M’],
mode=‘markers’,
marker=dict(size=10, color=‘black’)
)

kind regards

I don’t know for sure what y values you are tying to ultimately have in trace6_7, but based on your description of trace_all saying it “displays all the data correctly”, I assume that you are trying to have

df[(df[‘M’] >= 6) & ( df[‘M’] < 7) ][‘M’].astype(float) = df['M']

I think all you need to do is change the logical AND & to a logical OR | and this will result in the all the values of the M column.

Hope this helps.

1 Like

Thank you,
I think I solved the problem using npy and where expression.