I am new to python and I need to do a class made of different functions. Each function should be plotting different type of plot with predefined color, size, etc. The user should only call the function and enter two values (x=df or lst, y=df or lst and z the title of the plot) and then get the plot with the format that I have already predefined in the code.
Here is my code:
class Plotter:
def plot_signal(x,y):
plt.figure(figsize=(20, 5) )
plt.plot(x,
y,
color=(142/255.0,186/255.0,229/255.0), alpha=0.1 , linewidth=0.5 );
plt.xlim(left=0)
plt.xlabel('Time [s]', fontsize=11, fontname='Arial')
plt.ylabel('Force [kN]', fontsize=11, fontname='Arial')
plt.xticks(fontsize=8)
plt.yticks(fontsize=8)
plt.savefig(r"filepath\\filename.jpg")
plt.show()
plt.title(z)
return plt.show()
z = "trial"
x = np.random.rand(100)*10
y = np.random.rand(100)
plot_signal(x,y)
and the result (as seen in the photo), is a plot with a different color other than the color I chose, no title, and not even the figure size, it does also save my file, and I do not know how to fix it or what is the problem.