Seaborn

Seaborn is a Python visualization library based on matplotlib. It provides a high-level interface for drawing attractive statistical graphics.

Policy

Seaborn is available to users at HPC2N.

Citations

If seaborn is integral to a scientific publication, please cite it. A paper describing seaborn has been published in the Journal of Open Source Software:

Waskom, M. L., (2021). seaborn: statistical data visualization. Journal of Open Source Software, 6(60), 3021, https://doi.org/10.21105/joss.03021.

Overview

Seaborn is a plotting library built entirely with Matplotlib and designed to quickly and easily create presentation-ready statistical plots from Pandas data structures.

Seaborn can produce a wide variety of statistical plots, and even offers built-in regression functions, but in the interest of time, we will focus on just a few that are hard to replicate with Matplotlib alone. We will make extensive use of Seaborn’s built-in testing datasets, of which there are many. You will have seen a couple already in the Matplotlib and Pandas lectures.

Caution

Don’t Rely on Seaborn for Regression Analysis

Seaborn does not return any parameters needed to assess the quality of the fit. The official documentation itself warns that the Seaborn regression functions are only intended for quick and dirty visualizations to motivate proper in-depth analysis.

Usage at HPC2N

On HPC2N we have Seaborn available as a module.

Loading

To use the Seaborn module, add it to your environment. You can find versions with

module spider Seaborn

and you can then find how to load a specific version (including prerequisites), with

module spider Seaborn/<VERSION> 

Example

This shows how to load the module for Seaborn version 0.13.2

module load GCC/12.3.0 
module load Python/3.11.3 
module load SciPy-bundle/2023.07 
module load matplotlib/3.7.2 Tkinter/3.11.3 Seaborn/0.13.2

If you work at the command line, after importing Matplotlib, you will need to set matplotlib.use(‘Tkinter’) in order to view your plots. This is not necessary if you work in a GUI.

Running

If you are running more than a very short program, you must use the batch system.

This is an example batch script for running a Python script that uses Seaborn:

#!/bin/bash
#SBATCH -A hpc2nXXXX-YYY # Change to your own project ID 
#SBATCH --time=00:10:00 # Asking for 10 minutes - change as suitable 
#SBATCH -n 1 # Asking for 1 core, for a serial program 

# Clean the environment 
module purge  > /dev/null 2>&1 

# Load any modules you need. This is an example for Seaborn version 0.13.2  
module load GCC/12.3.0
module load Python/3.11.3
module load SciPy-bundle/2023.07
module load matplotlib/3.7.2 Tkinter/3.11.3 Seaborn/0.13.2

# Run your Python script - remember to add the actual ame of your script
python <seaborn-example>.py

Additional info

More information can be found on