ISIA – Data Visualization

Plotting two-dimensional data

Install the package matplotlib and import pyplot as follows:

import matplotlib.pyplot as plt

Use the following code snipped to test plotting with Python:

x = [1,2,3,4,5]
y = [0,-5,6,5,2]
z = list(range(0,5))
z = [2**i/2 for i in z]

plt.figure(num=None, figsize=(8, 5), dpi=100)


What happens, if you change the plot to plt.plot(x,z,"ro")?

Refer to the manual: Change Markers in matplotlib

Refer to the manual: Change Colors in matplotlib

Scatter plots, one ‘marker’ dot at a time

# For reference only!
for record in databaseEntries:
	x = record[’horizontalDatum’]
	y = record[’verticalDatum’]
	plt.plot([x], [y], ’ro’) # plot a red circle at (x,y)

Overlapping markers?
Make them semi-transparent

plt.plot([x], [y], ’ro’, alpha=0.5) # alpha is between 0.0 and 1.0

Labelling two-dimensional data

Annotate or label each marker with some text

plt.text(x + 0.1, y, str(y), va=’center’)

Small offset added to x to keep label away from marker
va (vertical alignment) set to ‘center’ to place text next to marker

Q: how would you place the text directly above its marker? (graph below)

Plotting three-dimensional data

  • Marker x and y co-ordinates use the two dimensions of the page (screen)
  • z (which would be perpendicular to the page/screen) can be
    • added as another co-ordinate, in a projection of a 3D plot
    • simulated, by varying some property of the marker

Adding the third dimension to a 2D data plot

An additional information layer can be added to use three four or more data dimensions in one data graph.

Q: How many dimensions does the above grave contain?


plt.plot([x], [y], ’ro’, alpha=0.5)


plt.plot([x], [y], ’ro’, markersize=5)


plt.plot([x], [y], ’o’, color=c)
  • Where c is
    • the initial of a color name: r g b c m y k w
    • a triplet of RGB intensity fractions, e.g., ‘Ritsu red’: (0.62, 0.0, 0.0)
  • Make a flag!
import matplotlib.pyplot as plt
plt.plot([10], [10], "o", color=(.62, 0, 0), markersize=100)


Write a program that extracts the ICAO markers from the following website:

Store the information in Python’s dictionary format so that, e.g., print(yourICAOlist["RJOO"]) results in "Itami Airport".

Access the following website:

Each weather station is also broadcasting their GPS location (longitude and latitude). For RJOO, it is 34.77,135.43

Plot any of the numerical weather information (recommended to start with the temperature) by longitude and latitude. The circle size must represent the numerical value.

Example of a bubble chart
Example of an overlaying map