3D Bar Chart
CPU Temperature Grid
3D bar chart of CPU temperatures across cores and time
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(12, 8), facecolor='white')
ax = fig.add_subplot(111, projection='3d')
ax.set_facecolor('white')
# Data: 6 time points, 8 cores
time_pts = 6
cores = 8
xpos = np.arange(time_pts)
ypos = np.arange(cores)
xpos, ypos = np.meshgrid(xpos, ypos)
xpos = xpos.flatten()
ypos = ypos.flatten()
zpos = np.zeros_like(xpos)
dx = dy = 0.65
np.random.seed(111)
dz = np.random.randint(45, 85, size=48)
# Red to orange gradient (heat)
colors = plt.cm.colors.LinearSegmentedColormap.from_list('', ['#F5B027', '#C82909'])
bar_colors = [colors(v/max(dz)) for v in dz]
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color=bar_colors, alpha=0.9, edgecolor='#000000', linewidth=0.3)
ax.set_xlabel('Time', fontsize=11, color='#1f2937', labelpad=10)
ax.set_ylabel('Core', fontsize=11, color='#1f2937', labelpad=10)
ax.set_zlabel('Temp (C)', fontsize=11, color='#1f2937', labelpad=10)
ax.set_title('CPU Core Temperatures', fontsize=14, color='#1f2937', fontweight='bold', pad=20)
ax.set_xticks(range(6))
ax.set_xticklabels(['T0', 'T1', 'T2', 'T3', 'T4', 'T5'])
ax.set_yticks(range(8))
ax.set_yticklabels(['C0', 'C1', 'C2', 'C3', 'C4', 'C5', 'C6', 'C7'])
ax.tick_params(colors='#000000', labelsize=9)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#000000')
ax.yaxis.pane.set_edgecolor('#000000')
ax.zaxis.pane.set_edgecolor('#000000')
ax.grid(True, alpha=0.5, linewidth=0.5)
ax.xaxis._axinfo['grid']['color'] = '#000000'
ax.yaxis._axinfo['grid']['color'] = '#000000'
ax.zaxis._axinfo['grid']['color'] = '#000000'
ax.xaxis._axinfo['tick']['color'] = '#000000'
ax.yaxis._axinfo['tick']['color'] = '#000000'
ax.zaxis._axinfo['tick']['color'] = '#000000'
ax.xaxis.line.set_color('#000000')
ax.yaxis.line.set_color('#000000')
ax.zaxis.line.set_color('#000000')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Bar Chart examples
☕