Draw equipotential lines on scatter plot in Python -


i have random data on x , y axis. i'd draw equipotential lines on |xy|=constant on scatter plot of (x,y). need this. thank you!

here example of want: enter image description here

as @fgnu says, can plot 1 or more lines on same axis plot scatter points. example:

import numpy np import matplotlib.pyplot plt  u = np.random.random(500) * 2 - 1 v = np.random.random(500) * 200 - 100  fig = plt.figure() ax = fig.add_subplot(111) ax.scatter(u,v)  # plot hyperbola |xy| = 1  x = np.linspace(-1,1,100) y1 = 1/np.abs(x) y2 = -y1 ax.plot(x,y1,'k-') ax.plot(x,y2,'k-') plt.show() 

i don't know range of random points, can't guess constant appropriate lines here.

enter image description here

edit count number of points "inside" curve, use:

ninside = 0 xi, yi in zip(u, v):     if abs(yi) < 1/np.abs(xi):         ninside += 1 print(ninside) 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Website Login Issue developed in magento -

Can the constants be defined inside a model file of a framework in PHP? -