Set Max value for color bar on Seaborn heatmap using Matplotlib



To set a value for color bar on Seaborn heatmap, we can take following Steps−

  • Create random data using numpy.
  • Use heatmap() method to plot rectangular data as a color-encoded matrix.
  • To display the figure, use show() method.

Example

import numpy as np import seaborn as sns from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(4, 4) ax = sns.heatmap(data, vmax=1) plt.show()

Output

Updated on: 2021-05-07T07:52:19+05:30

658 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements