pythonplot

plt.plot meaning of [:,0] and [:,1]


I am plotting a graph using plt.plot using information found online.

However, I do not know what the y[:,0] means:

    plt.plot(t, y[:,0], label= 'active Mos') 

Similarly, I see y[:,1] a lot too...

plt.plot is to plot a line to the graph, right?


Solution

  • It is a notation used in Numpy/Pandas.

    [ : , 0 ] means (more or less) [ first_row:last_row , column_0 ].

    If you have a 2-dimensional list/matrix/array, this notation will give you all values in column 0 (from all rows).