Python | Hybrid Line Plot with Heatmap

In this article, we are going to learn how to draw a line plot with a heatmap in the background for better data visualization?
Submitted by Anuj Singh, on August 08, 2020

Following example illustrates the implementation of our desired plot.

Python | Hybrid Line Plot (1)

Python | Hybrid Line Plot (2)

Python code 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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.