Matrix
Matrix block.
- param df:
Input data. The index and column names are used for the row/column naming.
- type df:
pd.DataFrame()
- param scale:
- Scale data in range Scaling in range by X*(100/max(X)).
True: Scale the values.
False: Do not scale.
- type scale:
Bool, (default: True).
- param stroke:
- Color of the recangle when hovering over a cell.
‘red’
‘black’
- type stroke:
String, (default: ‘red’).
- param description:
Description text of the heatmap.
- type description:
String.
- param vmax:
- Range of colors starting with maximum value. Increasing this value will color the cells more discrete.
1 : cells above value >1 are capped.
None : cells are colored based on the maximum value in the input data.
- type vmax:
Bool, (default: 100).
- param cmap:
- The colormap scheme. See references for more schmes.
‘interpolateInferno’
‘interpolatePRGn’
‘interpolateBlues’
‘interpolateGreens’
‘interpolateTurbo’
‘interpolateViridis’
‘interpolateInferno’
‘interpolateRainbow’
‘interpolateSinebow’
- type cmap:
String, (default: ‘interpolateInferno’).
- param fontsize:
Font size for the X and Y labels.
- type fontsize:
int, (default: 10).
- param title:
- Title of the figure.
‘Heatmap’
- type title:
String, (default: None)
- param figsize:
- Size of the figure in the browser, [width, height].
[800, 800]
- type figsize:
tuple
- param showfig:
True: Open browser-window.
False: Do not open browser-window.
- type showfig:
bool, (default: True)
- param filepath:
- File path to save the output.
Temporarily path: ‘d3blocks.html’
Relative path: ‘./d3blocks.html’
Absolute path: ‘c://temp//d3blocks.html’
None: Return HTML
- type filepath:
String, (Default: user temp directory)
- param overwrite:
True: Overwrite the html in the destination directory.
False: Do not overwrite destination file but show warning instead.
- type overwrite:
bool, (default: True)
- param notebook:
True: Use IPython to show chart in notebook.
False: Do not use IPython.
- type notebook:
bool
- param save_button:
True: Save button is shown in the HTML to save the image in svg.
False: No save button is shown in the HTML.
- type save_button:
bool, (default: True)
- param reset_properties:
True: Reset the node_properties at each run.
False: Use the d3.node_properties()
- type reset_properties:
bool, (default: True)
Examples
>>> # Initialize
>>> d3 = D3Blocks()
>>> #
>>> # Load example data
>>> df = pd.DataFrame(np.random.randint(0, 10, size=(6, 20)))
>>> #
>>> # Plot
>>> d3.matrix(df)
>>> #
>>> d3.matrix(df,
vmin=1,
fontsize=10,
title='D3blocks Matrix',
figsize=[600, 300],
cmap='interpolateGreens',
filepath='matrix.html',
)
References
Input Data
The input dataset is a DataFrame with three column, source, target and weight.
# source target weight
# 0 Agricultural 'waste' Bio-conversion 124.729
# 1 Bio-conversion Liquid 0.597
# 2 Bio-conversion Losses 26.862
# 3 Bio-conversion Solid 280.322
# 4 Bio-conversion Gas 81.144
# .. ... ... ...
# 63 Thermal generation District heating 79.329
# 64 Tidal Electricity grid 9.452
# 65 UK land based bioenergy Bio-conversion 182.010
# 66 Wave Electricity grid 19.013
# 67 Wind Electricity grid 289.366
# [68 rows x 3 columns]