Line & Scatter

Line Styles Comparison

Comparison of plot styles: markers only, continuous line, and line with markers.

Output
Line Styles Comparison
Python
import matplotlib.pyplot as plt
import numpy as np

# === STYLE CONFIG ===
COLORS = {
    'coral': '#F97316',      # Orange - markers
    'blue': '#3B82F6',       # Blue - smooth line
    'violet': '#8B5CF6',     # Violet - connected
    'background': '#FAFBFC',
    'text': '#1E293B',
    'text_muted': '#64748B',
    'grid': '#E2E8F0',
}

# === DATA ===
x = np.linspace(0, 10, 100)
y = 4 + 1.2 * np.sin(2 * x)

x_sparse = np.linspace(0, 10, 20)
y_top = 4 + 1.2 * np.sin(2 * x_sparse) + 2.2
y_bottom = 4 + 1.2 * np.sin(2 * x_sparse) - 2.2

# === FIGURE ===
fig, ax = plt.subplots(figsize=(10, 6), dpi=100)
ax.set_facecolor(COLORS['background'])
fig.patch.set_facecolor(COLORS['background'])

# === PLOT - Layered by visual weight ===
# Markers only (top series)
ax.plot(x_sparse, y_top, 'x', 
        color=COLORS['coral'], 
        markersize=8, markeredgewidth=2.5,
        label='Markers', zorder=3)

# Smooth line (middle series - hero)
ax.plot(x, y, 
        color=COLORS['blue'], linewidth=2.5,
        label='Continuous', zorder=4)

# Line + markers (bottom series)
ax.plot(x_sparse, y_bottom, 'o-',
        color=COLORS['violet'], linewidth=2,
        markersize=6, markerfacecolor='white', 
        markeredgewidth=2,
        label='Connected', zorder=2)

# === AXES ===
ax.set_xlim(0, 10)
ax.set_ylim(0, 9)

ax.set_xlabel('Time', fontsize=10, color=COLORS['text_muted'], 
              labelpad=10, fontweight='500')
ax.set_ylabel('Value', fontsize=10, color=COLORS['text_muted'], 
              labelpad=10, fontweight='500')

# === SPINES ===
for spine in ['top', 'right']:
    ax.spines[spine].set_visible(False)
for spine in ['bottom', 'left']:
    ax.spines[spine].set_color(COLORS['grid'])
    ax.spines[spine].set_linewidth(0.8)

# === GRID ===
ax.yaxis.grid(True, color=COLORS['grid'], linewidth=0.5, alpha=0.7)
ax.xaxis.grid(False)
ax.set_axisbelow(True)

# === TICKS ===
ax.tick_params(axis='both', colors=COLORS['text_muted'], 
               labelsize=9, length=0, pad=8)

# === LEGEND ===
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.12),
          ncol=3, frameon=False, fontsize=9,
          labelcolor=COLORS['text_muted'])

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Pairwise Data

Did this help you?

Support PyLucid to keep it free & growing

Support