Annotated Heatmaps using Plotly in Python Last Updated : 05 Sep, 2020 Summarize Suggest changes Share Like Article Like Report A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library. Annotated Heatmaps Annotated Heatmaps is the most important component of the heatmap as they shows additional information that associates with rows or columns in the heatmap. Annotation heatmaps will be represented as rows of grids through which multiple metrics can be compared to others. Syntax: create_annotated_heatmap(z, x=None, y=None, annotation_text=None, colorscale='Plasma', font_colors=None, showscale=False, reversescale=False) Parameters: x: x axis labels. y: y axis labels. z: z matrix to create heatmap. annotation_text: Text strings for annotations. Should have the same dimensions as the z matrix. If no text is added, the values of the z matrix are annotated. Default = z matrix values. colorscale: heatmap colorscale. Example: Python3 import plotly.figure_factory as ff import numpy as np feature_x = np.arange(0, 10, 2) feature_y = np.arange(0, 10, 3) # Creating 2-D grid of features [X, Y] = np.meshgrid(feature_x, feature_y) Z = np.cos(X / 2) + np.sin(Y / 4) fig = ff.create_annotated_heatmap(Z) fig.show() Output: Defining Colorscale In plotly, colorscale or color chart is a flat physical object which have different types of colors. It can be set in this graph using the colorscale parameter. Example 1: Python3 import plotly.figure_factory as ff import numpy as np feature_x = np.arange(0, 10, 2) feature_y = np.arange(0, 10, 3) # Creating 2-D grid of features [X, Y] = np.meshgrid(feature_x, feature_y) Z = np.cos(X / 2) + np.sin(Y / 4) fig = ff.create_annotated_heatmap(Z, colorscale='rainbow') fig.show() Output: Example 2: Adding Custom Colorscale Python3 import plotly.figure_factory as ff import numpy as np feature_x = np.arange(0, 10, 2) feature_y = np.arange(0, 10, 3) # Creating 2-D grid of features [X, Y] = np.meshgrid(feature_x, feature_y) Z = np.cos(X / 2) + np.sin(Y / 4) custom = [[0, 'green'], [0.5, 'red']] fig = ff.create_annotated_heatmap(Z, colorscale=custom) fig.show() Output: Advertise with us Next Article Histogram using Plotly in Python N nishantsundriyal98 Follow Similar Reads Bubble chart using Plotly in Python Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization librar 3 min read Filled area chart using plotly in Python Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histograms, bar plots, box plots, spread plots, and many more. It is mainly used in data analysis as well as financial analysis. Plotly is an interactive visualization 6 min read Polar Charts using Plotly in Python A Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization libra 2 min read Histogram using Plotly in Python Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 3 min read 3D Bubble chart using Plotly in Python Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read How to draw 2D Heatmap using Matplotlib in python? A heatmap is a great tool for visualizing data across the surface. It highlights data that have a higher or lower concentration in the data distribution. A 2-D Heatmap is a data visualization tool that helps to represent the magnitude of the matrix in form of a colored table. In Python, we can plot 5 min read Article Tags : Python Python-Plotly Practice Tags : python Like