0

I have data taken from an experiment which I have plotted using plt.plot and plt.scatter. The plot comes out with straight lines from point to point.

How can I plot a smooth curve for my data. I have used curve_fit before for linear and quadratic equations but can't think of a way to fit this data to a polynomial.

The code I have is:

prob = scatter_prob(ip1, ips1, is1, iss1)
plt.plot(voltage1, prob)
plt.xlabel('Voltage (V)')
plt.ylabel('Probability of Electron Scattering')
plt.title('Graph of Voltage vs. Probability')
plt.scatter(voltage1, prob)
plt.annotate('Minimum Probability P = ' + str(probmin), xy = (vmin, probmin), xytext = (vmin +1, probmin),
             arrowprops=dict(facecolor='yellow', shrink = 0.05))
plt.grid(True)
plt.tight_layout()
plt.show()

and an image of the graph I receive is here:

plot

prob, voltage1, ip1, is1, ips1, and iss1 are numpy arrays. scatter_prob returns

1 - ((Ip1 * Iss1)/(Ips1 * Is1))
Quang Hoang
  • 146,074
  • 10
  • 56
  • 74
niallygee
  • 19
  • 3
  • 3
    My answer would be: Don't. It gives the false impression of a continuous function, you imply a certain function type without reason why this curve should adhere to this function, and you gloss over noise that may actually be signal. Excel is my prime hate object for having introduced people to "smooth" graphs that are actually bordering on scientific fraud. – Mr. T Nov 05 '20 at 21:17

1 Answers1

0

My best way to smooth a curve is to use the Savitzky-Golay filter. Here a nice example here.

JohnB
  • 71
  • 2