The GlecklerPlot class provides functionality to generate a Portraet diagram as introduced by Gleckler et al. (2008). The class is very usefull if you want to vizualize e.g. different statistical results.
In [1]:
%matplotlib inline
from pycmbs.plots import GlecklerPlot
G = GlecklerPlot()
#register first models (these fill become the rows in the plot)
G.add_model('echam5')
G.add_model('mpi-esm-LR')
G.add_model('mpi-esm-MR')
#then register variables (these become the columns in the plot)
G.add_variable('ta')
#after that you can add values to be plotted; pos=1 mean that result is plotted in upper triangle
# you can specify up to 4 positions
# assign values you want to plot
G.add_data('ta','echam5',0.2,pos=1)
G.add_data('ta','mpi-esm-LR',0.5,pos=1)
G.add_data('ta','mpi-esm-MR',1.3,pos=1)
# do the plot
G.plot()
# save figure to file
#G.fig.savefig('filename.png')
Out[1]:
Note that two figures might be plotted here. This is just a problem with the ipython notebook used and not a problem with the actual GlecklerPlot!
In [2]:
del G
G = GlecklerPlot()
#register first models (these fill become the rows in the plot)
G.add_model('echam5')
G.add_model('mpi-esm-LR')
G.add_model('mpi-esm-MR')
#then register variables (these become the columns in the plot)
G.add_variable('ta')
G.add_variable('P')
G.add_variable('sea_ice')
#after that you can add values to be plotted; pos=1 mean that result is plotted in upper triangle
# you can specify up to 4 positions
G.add_data('ta','echam5',0.5,pos=1)
G.add_data('ta','mpi-esm-LR',0.3,pos=1)
G.add_data('P','echam5',0.25,pos=1)
G.add_data('P','mpi-esm-MR',-0.25,pos=2)
G.add_data('P','mpi-esm-MR',1.3,pos=1)
G.add_data('P','mpi-esm-LR',0.3,pos=1)
G.add_data('P','mpi-esm-LR',0.6,pos=2)
# random numbers are generated here using numpy
import numpy as np
G.add_data('sea_ice','echam5',np.random.random(1),pos=1)
G.add_data('sea_ice','echam5',np.random.random(1),pos=2)
G.add_data('sea_ice','echam5',np.random.random(1),pos=3)
G.add_data('sea_ice','echam5',np.random.random(1),pos=4)
G.add_data('sea_ice','mpi-esm-MR',np.random.random(1),pos=1)
G.add_data('sea_ice','mpi-esm-MR',np.random.random(1),pos=2)
G.add_data('sea_ice','mpi-esm-MR',np.random.random(1),pos=3)
G.add_data('sea_ice','mpi-esm-MR',np.random.random(1),pos=4)
G.add_data('sea_ice','mpi-esm-LR',np.random.random(1),pos=1)
G.add_data('sea_ice','mpi-esm-LR',np.random.random(1),pos=2)
G.add_data('sea_ice','mpi-esm-LR',np.random.random(1),pos=3)
G.add_data('sea_ice','mpi-esm-LR',np.random.random(1),pos=4)
G.plot() #do plot
Out[2]:
More help? Look at the help of the plot function