Skip to content

Instantly share code, notes, and snippets.

@njsmith
Created January 26, 2016 04:11
Show Gist options
  • Select an option

  • Save njsmith/ad4958cd1eb674fbed67 to your computer and use it in GitHub Desktop.

Select an option

Save njsmith/ad4958cd1eb674fbed67 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
PROPOSAL = {
"dashed": [7, 3],
"dashdot": [12, 3, 2, 3],
"dotted": [3, 1.5],
}
X = np.linspace(0, 4, 200)
#Y = np.sin(X) + np.linspace(0, 0.4, 4)[:, np.newaxis]
Y = np.sin(X ** 2) + np.linspace(0, 0.8, 4)[:, np.newaxis]
OTHER_STYLE = {
"color": "black",
}
def make_plot(ax, remap, title):
styles = ["solid", "dashed", "dashdot", "dotted"]
for i, style in enumerate(styles):
line, = ax.plot(X, Y[i, :], label=style,
linestyle=style,
**OTHER_STYLE)
if style in remap:
line.set_dashes(remap[style])
ax.legend()
# ax.text(0.04, 0.04, title,
# size=30,
# horizontalalignment="left", verticalalignment="bottom",
# transform=ax.transAxes)
ax.set_title(title, size=20, weight="bold")
f, (ax1, ax2) = plt.subplots(1, 2)
make_plot(ax1, {}, "Current")
make_plot(ax2, PROPOSAL, "Proposed")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment