Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

python

plot

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?

like image 223
Hotaru Avatar asked Nov 11 '16 23:11

Hotaru


People also ask

What is the meaning of [: 0 in Python?

[ : , 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).

What does PLT plot do?

The plot() function is used to draw points (markers) in a diagram. By default, the plot() function draws a line from point to point.


1 Answers

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 the values in column 0 (from all rows).

like image 96
furas Avatar answered Oct 09 '22 13:10

furas