Skip to content

Examples: Taylor Diagrams

Peter Rochford edited this page Mar 15, 2023 · 3 revisions

Purpose

Several example scripts are given below to illustrate how to produce Taylor diagrams in a variety of formats using the Skill Metrics package.

Taylor Diagram Example 1

How to create a simple Taylor diagram.

A first example of how to create a simple Taylor diagram given one set of reference observations and multiple model predictions for the quantity. The Python code is kept to a minimum.

This example shows how to calculate the required statistics and produce the Taylor diagram. All functions in the Skill Metrics package are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via a pickle file: ref['data'], pred1['data'], pred2['data'], and pred3['data']. The plot is written to a file in Portable Network Graphics (PNG) format.The plot is written to a file in Portable Network Graphics (PNG) format.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor1.py -noshow

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 2

How to create a simple Taylor diagram that also shows the observational standard deviation.

A second example of how to create a simple Taylor diagram, given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the first example (taylor1) where now the standard deviation of the observations is also shown.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

$ python taylor2.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 3

How to create a Taylor diagram with labelled data points and modified axes.

A third example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the first example (taylor1) where now the data points are labelled and axes properties are specified. The number format is also specified for the RMS contour labels.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor3.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 4

How to create a Taylor diagram with with modified axes and data point colors.

A fourth example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the third example (taylor3) where now the maximum scale for the standard deviation axis is increased, color properties are modified for the data point labels, and color & style properties are modified for the axes.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor4.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 5

How to create a Taylor diagram with a legend plus suppressed axes titles.

A fifth example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the fourth example (taylor4) where now a legend is added, and axes titles are suppressed. Note that symbols are used for the points when requesting a legend.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor5.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 6

How to create a Taylor diagram with a color bar.

A sixth example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the fourth example (taylor4) where now the markers are displayed in a color spectrum corresponding to their RMSD. A color bar is automatically displayed showing the correspondence with the RMSD values.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor6.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 7

How to create a Taylor diagram with correlations that vary from -1 to 1 (2 panels).

A seventh example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the fourth example (taylor4) where now the Taylor diagram is shown for correlations that vary from -1 to 1 (2 panels). Note that 2 panels will be used by default if any of the correlations are negative.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor7.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 8

How to create a Taylor diagram with overlaid markers.

An eight example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the seventh example (taylor7) where now a fourth data point having a negative correlation is overlaid on an existing Taylor diagram that already has 3 data points with positive correlations. It is chosen to have data points with positive correlations appear in red while data points with negative correlations are displayed in blue.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor8.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 9

How to create a Taylor diagram with modified axes and data point colors that show co-located points.

A ninth example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the fifth example (taylor5) where now a legend is added, axes titles are suppressed, and four points are co-located (i.e. overly each other). Symbols with transparent faces are used so the co-located points can be seen. The list of points are checked for those that agree within 1% of each other and reported to the screen.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

python taylor9.py -nosave

All functions in the SkillMetrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are read in as dictionaries via Comma, Separated, Value (CSV) files:

data_files = ['pred1.csv', 'pred2.csv', 'pred3.csv', 'ref.csv']

This is done to make it easy for people who are new to Python to adapt this script to read their data. Refer to the Read Data page for usage.

The plot is written to a file in Portable Network Graphics (PNG) format. Other formats are available by specifying the appropriate file suffix for graphics supported by matplotlib in the savefig function.

The reference data used in this example are cell concentrations of a phytoplankton collected from cruise surveys at selected locations and time. The model predictions are from three different simulations that have been space-time interpolated to the location and time of the sample collection.

Taylor Diagram Example 10

How to create a Taylor diagram with a large number of symbols of different color along with a legend.

A tenth example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

Produces a Taylor diagram showing how data available from public sources can be used to populate an acceptable model of water temperatures in the Farmington River basin of Connecticut.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

$ python taylor10.py -nosave

The data are stored in arrays named: sdev, crmsd, ccoef, and gageID. Each of these contain 1 reference value (first position) and 22 prediction values, for a total of 23 values. These arrays are stored in a container which is then written to a pickle file. A different file suffix is used depending upon whether the file is created using Python 2 (.pkl) or Python 3 (.pkl3) because the pickle package is not cross version compatible for pickle files containing containers of dictionaries.

The source data is an observation set at each location as well as a simulation set. The reference value is chosen that more or less represents the consensus on acceptable values of the root-mean square error.

This data was provide courtesy of John Yearsley, Affiliate Professor, UW-Hydro|Computational Hydrology, University of Washington.

Taylor Diagram Example 11

How to create a Taylor diagram with a color bar showing bias

An eleventh example of how to create a Taylor diagram given one set of reference observations and multiple model predictions for the quantity.

This example is a variation on the sixth example (taylor6) where now the markers are displayed in a color spectrum corresponding to their BIAS. A color bar is automatically displayed showing the correspondence with the BIAS values.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

$ python taylor11.py -nosave

All functions in the Skill Metrics library are designed to only work with one-dimensional arrays, e.g. time series of observations at a selected location. The one-dimensional data are stored in arrays named: sdev, crmsd, ccoef, and bias. Each of these contain 1 reference value (first position) and 4 prediction values, for a total of 5 values. The plot is written to a file in Portable Network Graphics (PNG) format.

This data was provide courtesy of Mostafa Khoshchehreh.

Taylor Diagram Example 12

How to create a Taylor diagram with multiple sets of data overlaid

A twelfth example of how to create a Taylor diagram given one set of reference observations and two sets of model predictions for the quantity.

This example shows how to display multiple data sets on the same Taylor diagram where a different color marker is used for each data set to identify its source. This is accomplished by overlaying the points from the second data set onto the Taylor diagram created using the first data set. Three data sets are used in this example where one is the reference and the other two are model predictions. This example also shows how to specify the legend using a dictionary instead of a list.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

$ python taylor12.py -nosave

The data sets are yearly time series for years 2001-2014, each stored as a list in a dictionary having a key of the form 'spi_2001', 'spi_2002', etc. There is a separate dictionary for each of the observation data set and the two model predictions. Each dictionary is written to its own pickle file. A different file suffix is used depending upon whether the file is created using Python 2 (.pkl) or Python 3 (.pkl3) because the pickle package is not cross version compatible for pickle files containing dictionaries.

The data in these files are statistics calculated from yearly time series of Standard Precipitation Index value over the Mekong basin, a trans-boundary river in Southeast Asia that originates in the Tibetan Plateau and runs through China's Yunnan Province, Myanmar, Laos, Thailand, Cambodia, and Vietnam. The data sources are the ERA5 climate reanalysis dataset from the European Centre for Medium-Range Weather Forecasts (ECMWF) and the Tropical Rainfall Measuring Mission (TRMM 3B42 v7) satellite data, whilst the observation data is the Asian Precipitation - Highly-Resolved Observational Data Integration Towards Evaluation (APHRODITE V1801R1) rain-gauge data. All the statistics for the yearly time series are calculated using the observations for 2001 as the reference.

This data was provided courtesy of Iacopo Ferrario, Resources Scientist, HR Wallingford, Flood and Water Resources group, Wallingford Oxfordshire, United Kingdom

Taylor Diagram Example 13

How to create a Taylor diagram with no centered RMSD contours

A thirteenth example of how to create a Taylor diagram given one set of reference observations and two sets of model predictions for the quantity. This is a variant of example 12, but where the centered RMSD contours are suppressed.

This example shows how to display multiple data sets on the same Taylor diagram where a different color marker is used for each data set to identify its source. This is accomplished by overlaying the points from the second data set onto the Taylor diagram created using the first data set. Three data sets are used in this example where one is the reference and the other two are model predictions. This example also shows how to specify the legend using a dictionary instead of a list.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

$ python taylor13.py -nosave

The data sets are yearly time series for years 2001-2014, each stored as a list in a dictionary having a key of the form 'spi_2001', 'spi_2002', etc. There is a separate dictionary for each of the observation data set and the two model predictions. Each dictionary is written to its own pickle file. A different file suffix is used depending upon whether the file is created using Python 2 (.pkl) or Python 3 (.pkl3) because the pickle package is not cross version compatible for pickle files containing dictionaries.

The data in these files are statistics calculated from yearly time series of Standard Precipitation Index value over the Mekong basin, a trans-boundary river in Southeast Asia that originates in the Tibetan Plateau and runs through China's Yunnan Province, Myanmar, Laos, Thailand, Cambodia, and Vietnam. The data sources are the ERA5 climate reanalysis dataset from the European Centre for Medium-Range Weather Forecasts (ECMWF) and the Tropical Rainfall Measuring Mission (TRMM 3B42 v7) satellite data, whilst the observation data is the Asian Precipitation - Highly-Resolved Observational Data Integration Towards Evaluation (APHRODITE V1801R1) rain-gauge data. All the statistics for the yearly time series are calculated as a function of the year, i.e. 2001 ERA5 and TRMM are calculated using APHRODITE 2001, 2002 ERA5 and TRMM are calculated using APHRODITE 2002, etc.

Note that the centered RMSD contours are suppressed for this Taylor diagram. This is important because the origin for the RMSD contours is specified by the standard deviation of the observations as dictated by the Taylor relationship. While statistics for each data point can be calculated using observations for that year and displayed on the diagram, there is no universal set of RMSD contours to correctly indicate the centered RMSD values of the different points, because each point is associated with a different observation standard deviation, and hence each has a different set of RMS contours with its own distinct origin. To show statistics respect to reference time series of the same year, one must suppress the RMSD contours, as otherwise it would provide a misleading indication of the centered RMSD values.

This data was provided courtesy of Iacopo Ferrario, Resources Scientist, HR Wallingford, Flood and Water Resources group, Wallingford Oxfordshire, United Kingdom

Taylor Diagram Example 14

How to create a figure with multiple Taylor diagrams using subplots.

A fourteenth example of how to create a Taylor diagram given five sets of data, each set composed by the statistics of the observation of five different models, and each set referring to a different forecasting time. This example shows the high level of customization possible using the capability to directly pass in subplot axes to create high quality figures for journal publications. Note this level of customization requires the user have a high level of proficiency with Python.

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

-output_file : Defines the output file name

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

$ python taylor14.py -nosave

Mock data is used in the example.

This example was provided courtesy of Andre D. L. Zanchetta.

Taylor Diagram Example 15

How to create a Taylor diagram with a large number of symbols of different color along with a legend.

A fifteenth example of how to create a Taylor diagram with individual control of the marker symbols, color, type, size, etc. This allows the use to have custom control over the appearance of the markers and the legend. However, it requires the user to specify all the details for each marker in a dictionary where the key is the marker label provided as a string. For example, for river gauge "14197":

MARKERS = {
    "14197": {              # marker label
        "labelColor": "k",  # label color of black
        "symbol": "+",      # plus marker symbol
        "size": 9,          # marker size of 9 pt
        "faceColor": "r",   # marker face color of red
        "edgeColor": "r",   # marker edge color of red
    }

It supports the following arguments as options.

-noshow : No figure is shown if this flag is present

-nosave : No figure is saved if this flag is present

They can be invoked from a command line as, for example, to not show the plot to allow batch execution:

$ python taylor15.py -nosave

The Taylor diagram created is for a model of water temperatures in the Farmington River basin of Connecticut. This script is based on Taylor diagram example 10.

The data are stored in arrays named: bias, sdev, crmsd, rmsd, ccoef, and gageID. Each of these contain 1 reference value (first position) and 22 prediction values, for a total of 23 values. These arrays are stored in a container which is then written to a pickle file for Python 3 (.pkl3).

The source data is an observation set at each location as well as a simulation set. The reference value is chosen that more or less represents the consensus on acceptable values of the root-mean square error.

This data was provide courtesy of John Yearsley, Affiliate Professor, UW-Hydro|Computational Hydrology, University of Washington.