heatmap_chart


This function creates a heatmap chart.

heatmap_chart(**kwargs)

Input Variables

Name Description Type
plot_setup

Dictionary for heatmap configuration, including the following keys:

  • name: Path and name of the output figure file
  • width: Width of the figure (in SI units)
  • height: Height of the figure (in SI units)
  • extension: File extension for the saved figure
  • dots_per_inch: Resolution of the figure in dots per inch (DPI)
  • mask: Boolean indicating whether to mask the upper triangle of the heatmap
  • line_widths: Width of the lines between cells in the heatmap
  • color_map: Colormap to use for the heatmap
  • line_color: Color of the grid lines between cells
  • annot: Boolean indicating whether to annotate cells with correlation values
  • annot_font_size: Font size for the annotations
Dictionary
dataset

Array-like dataset containing the values for plotting the heatmap

List or array

Output Variables

Name Description Type
None

The function displays the heatmap on the screen and saves it to the local folder of the script or notebook (.ipynb or .py).

None

Example 1

Use the heatmap_chart function to generate a heatmap.

# Data
DF = pd.DataFrame({ 'A1': [random.randint(1, 100) for _ in range(10)],
                    'A2': [random.randint(1, 100) for _ in range(10)],
                    'A3': [random.randint(1, 100) for _ in range(10)],
                    'A4': [random.randint(1, 100) for _ in range(10)],
                    'A5': [random.randint(1, 100) for _ in range(10)]
                  })

# Chart setup
plot_setup = {
    'name': 'figure1-7-1',
    'width': 30,
    'height': 15,
    'mask': False,
    'line widths': 8,
    'color map': 'plasma',
    'line color': 'white',
    'annot': True,
    'annot size font': 12,
    'dots per inch': 600,
    'extension': 'svg'
}


# Data statement 
DATA = {'dataset': DF}

# Call function
heatmap_chart(dataset = DATA, plot_setup = plot_setup)

Figure 1. Heatmap of DataFrame Correlation.