I'm trying to plot a curve through a very simple function :
def plotter(Taus, G2_data, titre) :
plt.figure()
plt.title('{}'.format(titre))
plt.xlabel('Tau (s)')
plt.ylabel('g2 - 1')
plt.ylim(-1, 1.1)
plt.xlim(-0.1, 7000)
plt.plot()
plt.show()
return None
plotter(taus, Y, 'test')
taus
and Y
are two list of same length, with Y
containing a few NaN values at the end.
This code returns this :
I have browsed a few posts : Matplotlib does not plot curve, Lines not showing up on Matplotlib graph and Matplotlib plt.show() isn't showing graph but none of them help me.
Does someone has an idea about why the curve isn't showing ? Thanks for the time.
First of all, make sure the data is in the range of axis values you are plotting. And you have to pass the data you want to plot in plt.plot() like
plt.plot(Taus, G2_data)
If you need to remove NaN values and you are working with numpy:
mask = ~np.isnan(G2_data)
Taus, G2_data = Taus[mask], G2_data[mask]
Anyway, you can plot them.