Interactive Portrait Plot
This notebook shows usage examples of interactive Portrait Diagram. Detailed API description can be found here.
Import functions
[1]:
from bokeh.plotting import output_file, save, output_notebook
[2]:
from ESMBenchmarkViz import portrait_plot
[3]:
# Enable Bokeh output in the notebook
output_notebook()
[4]:
import numpy as np
# Test dummy array -- fill random numbers for each array
data1 = np.random.randn(8, 7)
data2 = np.random.randn(8, 7)
data3 = np.random.randn(8, 7)
data4 = np.random.randn(8, 7)
"""
# Test dummy array -- fill same numbers for each array to make sure they are at the right position
data1 = np.full((8, 7), -2)
data2 = np.full((8, 7), -1)
data3 = np.full((8, 7), 1)
data4 = np.full((8, 7), 2)
"""
[4]:
'\n# Test dummy array -- fill same numbers for each array to make sure they are at the right position\ndata1 = np.full((8, 7), -2)\ndata2 = np.full((8, 7), -1)\ndata3 = np.full((8, 7), 1)\ndata4 = np.full((8, 7), 2)\n'
[5]:
data_all = [data1, data2, data3, data4]
xaxis_labels = ['A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7']
yaxis_labels = ['B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8']
xaxis_labels = ['Metric '+x for x in xaxis_labels]
yaxis_labels = ['Model '+y for y in yaxis_labels]
Basic usage examples
Following examples show portriat plots with different number of splits in each box.
[6]:
p = portrait_plot(
data1,
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
width=600,
)
[7]:
p = portrait_plot(
[data1, data2],
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
width=600,
)
[8]:
p = portrait_plot(
[data1, data2, data3],
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
width=600,
)
[9]:
p = portrait_plot(
data_all, # or [data1, data2, data3, data4] (top, right, bottom, left: clockwise from top)
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
legend_labels=['Data1', 'Data2', 'Data3', 'Data4'],
cmap_bounds=[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],
width=600,
)
[10]:
p = portrait_plot(
[data1, data2, data3, data4, data1],
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
legend_labels=['Data1', 'Data2', 'Data3', 'Data4', 'Data1-2'],
cmap_bounds=[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],
width=600,
)
[11]:
p = portrait_plot(
[data1, data2, data3, data4, data1, data2],
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
legend_labels=['Data1', 'Data2', 'Data3', 'Data4', 'Data1-2', 'Data2-2'],
cmap_bounds=[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],
width=600,
)
[12]:
p = portrait_plot(
[data1, data2, data3, data4, data1, data2, data3],
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
legend_labels=['Data1', 'Data2', 'Data3', 'Data4', 'Data1-2', 'Data2-2', 'Data3-2'],
cmap_bounds=[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],
width=600,
)
[13]:
p = portrait_plot(
[data1, data2, data3, data4, data1, data2, data3, data4],
xaxis_labels=xaxis_labels,
yaxis_labels=yaxis_labels,
legend_labels=['Data1', 'Data2', 'Data3', 'Data4', 'Data1-2', 'Data2-2', 'Data3-2', 'Data4-2'],
cmap_bounds=[-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5],
width=600,
)
Save the plot
[14]:
# set output to static HTML file
output_file(filename="interactive_portrait_plot.html", title="Interactive Portrait Plot")
# save the results to a file
save(p)
# Result: [`interactive_portrait_plot.html`](interactive_scatter_plot.html)
[14]:
'/Users/lee1043/Documents/Research/git/ESMBenchmarkViz/docs/examples/interactive_portrait_plot.html'