Search code examples
pythonplotkernel-density

Find all values such that .. from a density plot in Python


I plot(x,y) a chart, for which I want to find two things: - all values of x for which y>some specified value, - all values of y for which y>some specified value.

chart

How can I do it?


Solution

  • Using numpy:

    import numpy as np
    
    x = np.linspace(0,25,101) #x: 101 values between 0 and 25
    y = x**2/20 
    
    x[y>30]  #filter output: [ 24.5 ,  24.75,  25.  ]  
    y[y>30]  #filter output: [ 30.0125  ,  30.628125,  31.25    ]
    

    This assumes that you have access to the values which generated the plot.