Created
October 16, 2019 09:53
-
-
Save siddharthpaliwal/b5313d40871c751baa253aef9d4b6b92 to your computer and use it in GitHub Desktop.
Matplotlib color cycler indexing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cycle = plt.rcParams['axes.prop_cycle'].by_key()['color'] | |
import numpy as np | |
import matplotlib.pyplot as plt | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
t = np.arange(5) | |
for i in range(4): | |
line, = ax.plot(t,i*(t+1), linestyle = '-') | |
ax.plot(t,i*(t+1)+.3,color = line.get_color(), linestyle = ':') | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
t = np.arange(5) | |
cmap = plt.get_cmap("tab10") | |
for i in range(4): | |
ax.plot(t,i*(t+1), color=cmap(i), linestyle = '-') | |
ax.plot(t,i*(t+1)+.3,color=cmap(i), linestyle = ':') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment