I am trying to find a specific point in my dataset and change the color and size of it. I am a beginner and very new to this, so I may be missing something basic here, but I cannot find the solution in all the resources I’ve looked at. I don’t want to create categories, nor do I want to have the points be larger than size 1. I have 332k data points that I am trying to visualize, so anything larger makes the graph look unpleasant.
my_data_df = merged_df[['x', 'y', 'entry']]
search_name = st.text_input("Search for an entry:", "")
is_match = np.array(my_data_df['entry'] == search_name)
colors = np.where(is_match, 'red', 'lightblue')
sizes = np.where(is_match, 7, 1)
fig = px.scatter(
my_data_df,
x='x',
y='y',
hover_name='entry',
hover_data={'x': True, 'y': True},
labels={'x': 'My X Data', 'y': 'My Y Data'},
title='My X Data VS My Y Data',
).update_traces(
marker=dict(
color=colors,
size=sizes
)
)
fig.update_traces(marker=dict(size=1))
fig.update_xaxes(type='log')
st.plotly_chart(fig)
Essentially, I am trying to make the points appear as light blue, but they are appearing as white. I speculate it could be because it’s a bubble and it’s the white border of the bubble when the bubbles are really small, but I’m not so certain that’s what’s happening here. On the other hand, the red point appears like normal, and I have checked the dataframe to verify they contain the expected values. If you guys know any better way to approach this problem I am open to ideas.
What confuses me the most is when I simply set size=1, the lightblue and red both work, but the size of course can’t be 7 for the selected point. I don’t know why changing the size variable influences the color, which brought me to the bubble border theory. If that is true, I don’t know how to get what I am trying to do. I have tried complex workarounds, but I figured there must be a simpler solution.
Version 5.24.1
Output: