I am trying to smoothen this plot. But I was unable to do it. Tried to interpolate using splrep but its not working. Any help would be highly appreciated. The graph has been plotted by using Dataframe columns of Current, voltage and Operating hours.
df2=data[:2000]
plt.subplot(2,1,1)
plt.plot(df2['Op_Hours_Fcpm'],df2['Current'],'r')
plt.xlabel('Operating hours')
plt.title('Current Fluctuations')
plt.subplot(2,1,2)
plt.plot(df2['Op_Hours_Fcpm'],df2['Voltage'],'y')
plt.xlabel('Operating hours')
plt.title('Voltage Fluctuations')
plt.tight_layout()
plt.show()
I did try by another way as well:
fig, ax = plt.subplots()
ax.plot(x_int, current_int, lw = 5, alpha = 0.30, label = 'current')
ax.plot(x_int, voltage_int, lw = 5, alpha = 0.30, label = 'voltage')
ax.set_xlabel('ripples')
ax.set_ylabel('hrs')
# Set the correct xticks
ax.set_xticks(x_map)
ax.set_xticklabels(x)
fig.legend(bbox_to_anchor=(0.7, 0.3), loc='upper left', ncol=1)
fig.show()
This has given this output
Since you didn't provide the original data, I tried to recreate some of the points from the image using
import pandas
print(pandas.__version__)
import matplotlib.pyplot as plt
x = [0.5, 0.5, 1, 1, 2, 2, 2 , 3]
y = [0, 600, 0, 600, 0, 1000, 600, 0]
plt.plot(x,y,'r');
plt.xlabel('Operating hours')
plt.title('Current Fluctuations');
plt.savefig('original.png');
which yields
The issue with the first subplot is that some of the times contain multiple values, including both "zero" and non-zero values. This can be more easily seen as a scatter plot
plt.scatter(x, y);
plt.xlabel('Operating hours')
plt.title('Current Fluctuations');
plt.savefig('scatter.png')
This visualization issue points to a problem with the underlying data.
One option would be to discard data that is zero and only keep non-zero data points.