Is there a way to trigger /change x label values based on the legend variable

fig = px.scatter(video_df, x=["likeCount",'commentCount'], y="viewCount", trendline='ols',trendline_color_override="black")
fig.update_xaxes(zeroline=False)
fig.update_yaxes(zeroline=False)
fig.show()


in above fig case 1 if i click legend variable to like count the x axis label should change to the legend name likecount
case 2 if i click both legend variable to like count and comment count both the name should be displayed on the x axis label

if this ifs not possible do recommend any other method

guys can any body help me with this

Hi, not exactly what you are asking but maybe this helps:

I think you should make it as @AIMPED suggested for now.

You can make it a radio button, if likeCount is selected, you pass likeCount into x-axis and if commentCount is chosen, you pass it into the x-axis.

If the order does not matter, you can consider passing likeComment and commentCount to the y-axis instead, that way, you can get what you want when you click on the legend.

thanks
tired with radio button’s

1 Like