20141220_2DPlotsonPythonP1.ipynb

Two-dimensional plots on Python [Part I]

Support material for the blog post "Two-dimensional plots on Python [Part I]", on Programming Science.

de Siqueira, Alexandre Fioravante. "Two-dimensional plots on Python [Part I]". Programming Science. 2014, Dec 20. Available at http://www.programmingscience.org/?p=19. Access date: (please put your access date here).

Copyright (C) Alexandre Fioravante de Siqueira

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Generating a simple 2D plot.

  • Importing eveything from Pylab.

In [1]:
from pylab import *
  • Defining t and y.

In [2]:
t = arange(0.0, 2.0, 0.01)
y = sin(2*pi*t)
  • (Kinda) Plotting the function.

In [3]:
plot(t, y)


Out[3]:
[<matplotlib.lines.Line2D at 0x7f4f80cb6dd8>]
  • Defining labels for X and Y, and a title.

In [4]:
xlabel('Time (s)')
ylabel('Voltage (mV)')
title('The simplest one, buddies')


Out[4]:
<matplotlib.text.Text at 0x7f4f80cce908>
  • Defining grid.

In [5]:
grid(True)
  • Showing our plot.

In [6]:
show()



In [ ]: