Python Forum
Smooth curve in matplotlib - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Smooth curve in matplotlib (/thread-25547.html)



Smooth curve in matplotlib - medatib531 - Apr-02-2020

Hello,
suppose I have the following dataset as represented in the code.
This dataset is coming from measurements which are sometimes inconsistent and there are some "peaks" in the curve.
Is there any way to smoothe the curve?

import matplotlib as mpl

from matplotlib import pyplot as plt

y = [ 0.008000000000000002, 0.007600000000000001,  0.010200000000000002,  0.010100000000000001,  0.0097,  0.010299999999999998,  0.0113]
x = [10, 20, 40, 80, 160, 320, 640]

plt.rc('font', family='serif', size='10')

fig, ax1 = plt.subplots()
ax1.plot(x,y,linewidth=1)

ax1.set_xscale('log')
ax1.set_yscale('log')
plt.show()