Matrix
- D3Blocks.matrix(df, scale=False, stroke='red', description=None, vmin=None, vmax=None, cmap='interpolateInferno', fontsize=10, title='Matrix - D3blocks', figsize=[700, 500], showfig=True, filepath='matrix.html', overwrite=True, notebook=False, save_button: bool = True, return_html: bool = False, reset_properties=True)
Matrix block.
- Parameters:
df (pd.DataFrame()) – Input data. The index and column names are used for the row/column naming.
scale (Bool, (default: True).) –
- Scale data in range Scaling in range by X*(100/max(X)).
True: Scale the values.
False: Do not scale.
stroke (String, (default: 'red').) –
- Color of the recangle when hovering over a cell.
’red’
’black’
description (String.) – Description text of the heatmap.
vmax (Bool, (default: 100).) –
- 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.
cmap (String, (default: 'interpolateInferno').) –
- The colormap scheme. See references for more schmes.
’interpolateInferno’
’interpolatePRGn’
’interpolateBlues’
’interpolateGreens’
’interpolateTurbo’
’interpolateViridis’
’interpolateInferno’
’interpolateRainbow’
’interpolateSinebow’
fontsize (int, (default: 10).) – Font size for the X and Y labels.
title (String, (default: None)) –
- Title of the figure.
’Heatmap’
figsize (tuple) –
- Size of the figure in the browser, [width, height].
[800, 800]
showfig (bool, (default: True)) –
True: Open browser-window.
False: Do not open browser-window.
filepath (String, (Default: user temp directory)) –
- File path to save the output.
Temporarily path: ‘d3blocks.html’
Relative path: ‘./d3blocks.html’
Absolute path: ‘c://temp//d3blocks.html’
None: Return HTML
overwrite (bool, (default: True)) –
True: Overwrite the html in the destination directory.
False: Do not overwrite destination file but show warning instead.
notebook (bool) –
True: Use IPython to show chart in notebook.
False: Do not use IPython.
save_button (bool, (default: True)) –
True: Save button is shown in the HTML to save the image in svg.
False: No save button is shown in the HTML.
return_html (bool, (default: False)) –
True: Return html
False: Nothing is returned
reset_properties (bool, (default: True)) –
True: Reset the node_properties at each run.
False: Use the d3.node_properties()
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]