Skip to content
Advertisement

Draw longest possible vertical line between two curves in seaborn

I currently have a plot like this (consider that data is the dataframe I pasted at the very bottom):

JavaScript

Which produces:

enter image description here

Now, I want to know how can I annotate a line in this plot, such that it is located between the curves, at the x-Axis value where the distance between curves are maximized. I would also need to annotate text to show the distance value.

It should be something like this:

enter image description here

Here is the pandas dataframe:

JavaScript

Advertisement

Answer

  1. Use pivot to transform the data from long to wide
  2. Use idxmax to find the x (Threshold) of the max difference between y1 and y2 (Fall-out and Recall)
  3. Use vlines to plot the vertical line at x from y1 to y2
  4. Use annotate to plot the label at the midpoint of y1 and y2
JavaScript

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement