LineGlyph¶
LineGlyph wraps Axes.plot, Axes.bar, and Axes.fill_between for line, bar, and band plots. y may be 1-D (one series) or 2-D (one series per column).
In [1]:
Copied!
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from cleopatra.line_glyph import LineGlyph
x = np.linspace(0, 2 * np.pi, 100)
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from cleopatra.line_glyph import LineGlyph
x = np.linspace(0, 2 * np.pi, 100)
1. Line plot (multiple series)¶
In [2]:
Copied!
y = np.column_stack([np.sin(x), np.cos(x)])
fig, ax, lines = LineGlyph(x, y).line(label=['sin', 'cos'], title='Lines')
ax.legend()
y = np.column_stack([np.sin(x), np.cos(x)])
fig, ax, lines = LineGlyph(x, y).line(label=['sin', 'cos'], title='Lines')
ax.legend()
Out[2]:
<matplotlib.legend.Legend at 0x222b99c06e0>
2. Bar chart¶
In [3]:
Copied!
xb = np.arange(6)
fig, ax, bars = LineGlyph(xb, np.array([3., 5., 2., 8., 4., 6.])).bar(title='Bars')
xb = np.arange(6)
fig, ax, bars = LineGlyph(xb, np.array([3., 5., 2., 8., 4., 6.])).bar(title='Bars')
3. Band / envelope (fill_between)¶
In [4]:
Copied!
upper = np.sin(x) + 0.3
lower = np.sin(x) - 0.3
fig, ax, band = LineGlyph(x, upper).fill_between(y2=lower, alpha=0.3, title='Band')
upper = np.sin(x) + 0.3
lower = np.sin(x) - 0.3
fig, ax, band = LineGlyph(x, upper).fill_between(y2=lower, alpha=0.3, title='Band')