20141230_2DPlotsonPythonP2.ipynb

Two-dimensional plots on Python [Part II]

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

de Siqueira, Alexandre Fioravante. "Two-dimensional plots on Python [Part II]". Programming Science. 2014, Dec 30. Available at http://www.programmingscience.org/?p=33. 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/.

Custom 2D plots.

  • Generating a simple 2D plot.

In [1]:
from pylab import *
 
t = arange(0.0, 2.0,0.01)
y = sin(2*pi*t)
plot(t, y)
 
xlabel('Time (s)')
ylabel('Voltage (mV)')
title('The simplest one, buddies')
grid(True)
 
show()


  • Custom plot line: color='red'.

In [2]:
from pylab import *
 
t = arange(0.0, 2.0,0.01)
y = sin(2*pi*t)
plot(t, y, color='red')
 
xlabel('Time (s)')
ylabel('Voltage (mV)')
title('The simplest one, buddies')
grid(True)
 
show()


  • A custom 2D plot, based on our first example.

In [3]:
from pylab import *
 
t = arange(0.0, 2.0,0.01)
y = sin(2*pi*t)
plot(t, y, color='green', linestyle='-.', linewidth=3)
 
xlabel('Time (s)', fontweight='bold', fontsize=14)
ylabel('Voltage (mV)', fontweight='bold', fontsize=14)
title('The simplest one, buddies')
grid(True)
 
show()



In [ ]: