I am trying to display a scatter chart for two columns in a Deedly data frame, ideally grouped by a third column. And I would like to show a linear regression line on the same chart.
In Python this can be done with seaborn.lmplot
https://seaborn.pydata.org/generated/seaborn.lmplot.html
sns.lmplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species")
I was hoping to do something like that with Plotly.Net, but so far I only got a simple scatterplot:
(
df.["rating"].Values,
df.["calories"].Values
)
||> Seq.zip
|> Chart.Point
How do I add a linear regression line similar to seaborn? Do I need to do it manually somehow?
How do I group the points by a third column? This one I may be able to figure out myself, but I wonder if there is a more elegant solution.
Thanks to Brian Berns' comment, pointing me to this example, I was able to create a helper function that works similar to Python's
seaborn.lmplot
function.Here is the code if anyone wants to use it:
Example of using it to render a scatter plot with regression line for a dataframe:
Example of using it to render a scatter plots with regression lines for a dataframe grouped by a row value: