简体   繁体   中英

How to a plot a line of best fit for max y values in seaborn

How do I draw a no linearline of best fit for the max values like the one in red below? I want to find the max y value for each x value. For example when x is 10 the max y is 2.5. When x is 20 the max y is 4. I then want to plot a line of best fit between these points.

The x and y values are coming from a table.

在此处输入图像描述

I don't quite understand the question (try to provide more information next time), I think you want a line that goes along just the max y values, and ignores all others. So to do this you could you could make a list in python similar to this (pseudocode)

# assuming x values is a table with all the x coordinates on the graph
max_y = []
for i in x values:
  large_y = largest y value for that x value
  max_y.append(large_y)

Then I would use interpolation using scipy. Scipy Interpolation Docs I would probably choose to use RBF, but there are plenty of interpolation methods, you can look around for the one that is best fit. After inputting your tables into the interpolation, you will be given an equation that matches these points (or the line of best fit, depending what method you use). You can then graph this equation, and it will be your line of best fit for only the max y values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM