import matplotlib.pyplot as plt
import numpy as np
# Define approaches and challenges/research gaps
approaches = [
"Conventional Methods",
"Modeling with ANNs",
"Machine Learning Applications",
"Vision-based Detection",
"Real-world Implementations"
]
challenges = [
"Scalability & Applicability",
"Data Quality & Scarcity",
"Interpretability & Explainability",
"Environmental Conditions",
"Cost & Scalability",
"User Adoption"
]
# Research gap severity matrix (1 = low, 5 = high)
research_gap_matrix = np.array([
[3, 2, 4, 3, 2, 2], # Conventional Methods
[4, 5, 5, 4, 3, 2], # Modeling with ANNs
[3, 4, 5, 3, 2, 4], # Machine Learning Applications
[2, 4, 3, 5, 3, 2], # Vision-based Detection
[4, 3, 2, 3, 5, 4] # Real-world Implementations
])
# Create the heatmap using matplotlib
fig, ax = plt.subplots(figsize=(10, 6))
# Create a color map based on the values in the research_gap_matrix
cax = ax.imshow(research_gap_matrix, cmap="Blues", aspect='auto')
# Add a color bar (linked to 'cax' which is a ScalarMappable)
fig.colorbar(cax)
# Set axis labels and ticks
ax.set_xticks(np.arange(len(challenges)))
ax.set_yticks(np.arange(len(approaches)))
ax.set_xticklabels(challenges, rotation=45, ha='left')
ax.set_yticklabels(approaches)
# Annotate each cell with its value
for i in range(len(approaches)):
for j in range(len(challenges)):
ax.text(j, i, research_gap_matrix[i, j], va='center', ha='center', color="black")
# Add title and adjust layout
plt.title("Research Gap Matrix: Approaches vs Challenges", pad=20)
plt.tight_layout()
# Save the heatmap as an image file
plt.savefig('foo.png', dpi=300)
# Show the heatmap
plt.show()
Click Run or press shift + ENTER to run code