×

Python Tutorial

Python Basics

Python I/O

Python Operators

Python Conditions & Controls

Python Functions

Python Strings

Python Modules

Python Lists

Python OOPs

Python Arrays

Python Dictionary

Python Sets

Python Tuples

Python Exception Handling

Python NumPy

Python Pandas

Python File Handling

Python WebSocket

Python GUI Programming

Python Image Processing

Python Miscellaneous

Python Practice

Python Programs

Python | Hybrid Line Plot with Heatmap

Hybrid Line Plot with Heatmap: In this tutorial, we are going to learn how to draw a line plot with a heatmap in the background for better data visualization? By Anuj Singh Last updated : August 18, 2023

Example

Following example illustrates the implementation of our desired plot.

Python | Hybrid Line Plot (1) Python | Hybrid Line Plot (2)

Python program for hybrid line plot with heatmap

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(5)
y = np.random.randint(1,5,5)
mata = np.random.random([5,4])
mataa = np.matmul(mata, mata.T)
plt.imshow(mataa, cmap='GnBu', alpha=0.7)
plt.plot(x,y, linewidth=2.5)
plt.axis(False)
plt.show()

plt.figure()
mata = np.random.random([5,4])
mataa = np.matmul(mata, mata.T)
plt.imshow(mataa, cmap='GnBu', alpha=0.7)
plt.plot(x,y, linewidth=2.5)
plt.show()

Output:

Output is as Figure
Advertisement
Advertisement

Comments and Discussions!

Load comments ↻


Advertisement
Advertisement
Advertisement

Copyright © 2025 www.includehelp.com. All rights reserved.