Visualizing Argo Data

Last updated on 2026-02-02 | Edit this page

Estimated time: 30 minutes

Overview

Questions

  • “How can I visualize tabular data in Python?”
  • “How can I group several plots together?”

Objectives

  • “Plot simple graphs from data.”
  • “Plot multiple graphs in a single figure.”
  • “Use Argopy’s plotting functions.”

Visualizing data


The mathematician Richard Hamming once said, “The purpose of computing is insight, not numbers,” and the best way to develop insight is often to visualize data. Visualization deserves an entire lecture of its own, but we can explore a few features of Python’s matplotlib library here. While there is no official plotting library, matplotlib is the de facto standard. First, we will import the pyplot module from matplotlib and use two of its functions to create and display a line graph of our data:

Ensuring we have Loaded the Data


Let’s load some temperature, pressure and salinity data with Argopy.

PYTHON

import argopy
argo_data = argopy.DataFetcher().profile(6902746, 12).to_xarray()
temperature = argo_data.TEMP.values
pressure = argo_data.PRES.values
salinity = argo_data.PSAL.values

Graphing Temperature Data


Let’s use the Matplotlib library to plot this data. We’ll need to import from the matplotlib.pyplot library. We can then use pyplot’s plot function to plot the temperature data.

PYTHON

import matplotlib.pyplot
image = matplotlib.pyplot.plot(temperature)
A line graph representing the temperature readings from the Argo float data.

The X axis corresponds to each row in the data and the Y axis is temperature in degrees celcius.

Adding Labels to a Graph

It’s good practice to add axes labels to our graphs, these can be done with the xlabel and ylabel functions in matplolib.pyplot.

PYTHON

matplotlib.pyplot.ylabel("Temperature (Degrees C)")
matplotlib.pyplot.xlabel("Reading Number")
temperature_plot = matplotlib.pyplot.plot(temperature)
A line graph showing the temperatuer from the Argo data with axes labels.
Challenge

Plot the pressure data

Create a plot showing the pressure (depth) across a Argo profile.

PYTHON

import matplotlib.pyplot as plt
plt.xlabel("Reading number")
plt.ylabel("Depth (metres)")
pres_plot = plt.plot(pressure)

Plot using Argopy


Instead of calling functions in Matplotlib we can also call some plotting functions within Argopy (and these will call Matplotlib for us). This offers two advantages:

  1. we don’t need to import matplolib ourselves.
  2. there are some Argo specific plots available within Argopy.

Plotting a Map of Where our Float has Travelled

One of the plots that Argopy can generate is a map showing the position of the float every time it surfaced.

PYTHON

float_data = argopy.DataFetcher().float(6902746).load()
argopy.plot.scatter_map(float_data.index, set_global=False)
A scatter graph comparing temperature and presssure.

You can also see the same data on an interactive map at https://fleetmonitoring.euro-argo.eu/float/6902746. For some reason the data returned by ArgoPy for this float is limted to the first 118 profiles and there are a few more after that being shown on the fleetmonitoring website.

Plotting Temperature Across Multiple Profiles

Another useful feature of the Argopy library is that it can plot data from multiple Argo profiles (dives). This can be done by supplying a whole Xarray dataset for all our profiles; we can extract this from the float_data object we got earlier by calling the to_xarray() function on it. This can be passed to the scatter_plot function in Argopy. We also have to give it the variable name which is “TEMP” (or “PSAL” for salinity). This plot uses colour to show the temperature and puts depth/pressure on the y axis and date on the x axis.

PYTHON

fig = argopy.plot.scatter_plot(float_data.to_xarray(), 'TEMP')
A scatter graph from Argopy showing temperature, depth and time.
Challenge

Find Another Float to Plot

Pick a different float to load some data from. You can find a list of recently launched UK floats at https://fleetmonitoring.euro-argo.eu/dashboard?Status=Active&Year%20of%20deployment=2025&Country=United%20Kingdom&Network=CORE

Float numbers 7902230, 1902114, 1902725, 1902724, 1902109, 1902111, 1902110, 1902112, 4903834, 4903656, 6990513 or 2903943 could all be good contenders. Some floats will not work because they are missing data and you will ValueError, if this happens try a different float.

Create a new notebook with the following graphs for your float:

  • A map showing where it has been
  • A scatter plot of temperature against depth over time
  • A scatter plot of salinity against depth over time

If you have time add some description about each graph by creating a cell with the Markdown type. Look at https://www.markdownguide.org/basic-syntax/ to see some of the syntax you can use with markdown.

PYTHON

import argopy
float_data = argopy.DataFetcher().float(7902230).load()
argopy.plot.scatter_map(float_data.index, set_global=False)
fig = argopy.plot.scatter_plot(float_data.to_xarray(), 'TEMP')
fig = argopy.plot.scatter_plot(float_data.to_xarray(), 'PSAL')
Key Points
  • “Use the pyplot module from the matplotlib library for creating simple visualisations.”
  • “Argopy has its own built in visaulisation functions”