Using px.scatter() there are actually two slightly different ways, depending on whether your data is of a long or wide format. You've already put together a procedure that solves your problem, but I would like to mention that you can use plotly.express and do the very same thing with only a very few lines of code. Y=(wp_m * df_wp + wp_b),įig.update_layout(title="Tree Circumference vs Height (meters)", Wp_m, wp_b = np.polyfit(df_wp.to_numpy(), df_wp.to_numpy(), 1)įig.add_trace(go.Scatter(x=df_df, I then added the slop for each data set as a tracer import numpy as npĭf_m, df_b = np.polyfit(df_df.to_numpy(), df_df.to_numpy(), 1) Basically I used numpy polyfit function to calculation my slop.
In this tutorial, we learn how to create a scatter plot based on our data.Īs we mentioned, the scatter plot shows the dispersion of numerical data sets and displays the correlation between them. Both of the scatter axes contain numeric values. The Scatter chart (XY graph or Scattering plot) is a 2D chart that compares the relevance of two sets of data.
One of the comparator charts in Excel is the Scatter chart.