3D Bar Chart
EV Charging Station Load
Power consumption across charging stations and time slots
Output
Python
import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.colors import LinearSegmentedColormap
fig = plt.figure(figsize=(12, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d')
ax.set_facecolor('#ffffff')
stations = 5
times = 6
xpos = np.arange(stations)
zpos = np.arange(times)
xpos, zpos = np.meshgrid(xpos, zpos)
xpos = xpos.flatten()
zpos = zpos.flatten()
ypos = np.zeros_like(xpos)
dx = 0.55
dz = 0.5
np.random.seed(987)
time_weights = [0.3, 0.5, 0.8, 1.0, 0.9, 0.6]
dy = np.array([np.random.normal(150, 30) * time_weights[i // 5] for i in range(30)])
cmap = LinearSegmentedColormap.from_list('neon', ['#6CF527', '#F5D327', '#F5B027', '#F54927'])
norm = plt.Normalize(min(dy), max(dy))
colors = [cmap(norm(v)) for v in dy]
ax.bar3d(xpos, ypos, zpos, dx, dy, dz, color=colors, alpha=0.85, edgecolor='#e5e7eb', linewidth=0.4)
ax.set_xlabel('Station', fontsize=11, color='#1f2937', labelpad=12)
ax.set_ylabel('Power (kW)', fontsize=11, color='#1f2937', labelpad=12)
ax.set_zlabel('Time', fontsize=11, color='#1f2937', labelpad=10)
ax.set_title('EV Charging Station Load Profile', fontsize=14, color='#1f2937', fontweight='bold', pad=20)
ax.set_xticks(range(5))
ax.set_xticklabels(['Hub-A', 'Hub-B', 'Hub-C', 'Hub-D', 'Hub-E'], fontsize=8, color='#374151')
ax.set_zticks(range(6))
ax.set_zticklabels(['6AM', '9AM', '12PM', '3PM', '6PM', '9PM'], fontsize=7, color='#374151')
ax.tick_params(colors='#374151', labelsize=9)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.grid(True, alpha=0.3, linewidth=0.5)
ax.view_init(elev=25, azim=40)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Bar Chart examples
☕