Hexbin Plot

Muscle Activation EMG

Electromyography hexbin showing bicep vs tricep activation

Output
Muscle Activation EMG
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap

np.random.seed(1111)
bicep = np.abs(np.random.normal(50, 25, 6000))
tricep = np.abs(100 - bicep + np.random.normal(0, 15, 6000))

fig, ax = plt.subplots(figsize=(10, 8), facecolor='#faf5ff')
ax.set_facecolor('#f3e8ff')

colors = ['#f3e8ff', '#e9d5ff', '#d8b4fe', '#c084fc', '#a855f7', '#9333ea', '#7e22ce', '#6b21a8']
cmap = LinearSegmentedColormap.from_list('violet', colors, N=256)

hb = ax.hexbin(bicep, tricep, gridsize=28, cmap=cmap, mincnt=1, edgecolors='white', linewidths=0.3)

cbar = plt.colorbar(hb, ax=ax, pad=0.02, shrink=0.8)
cbar.outline.set_edgecolor('#e9d5ff')
cbar.ax.tick_params(colors='#7e22ce', labelsize=9)
cbar.set_label('Samples', color='#7e22ce', fontsize=10)

ax.set_xlabel('Bicep Activation (%)', color='#7e22ce', fontsize=11)
ax.set_ylabel('Tricep Activation (%)', color='#7e22ce', fontsize=11)
ax.tick_params(colors='#7e22ce', labelsize=10)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#e9d5ff')
ax.spines['bottom'].set_color('#e9d5ff')

plt.tight_layout()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support