Skip to content

Instantly share code, notes, and snippets.

@catslovedata
Last active April 10, 2023 15:00
Show Gist options
  • Save catslovedata/86595c62f10b1ebe13740e0469046738 to your computer and use it in GitHub Desktop.
Save catslovedata/86595c62f10b1ebe13740e0469046738 to your computer and use it in GitHub Desktop.
# Set some color constants
COLOR_RED = '#dc322f'
COLOR_GREEN = '#2aa198'
COLOR_VLINES = '#073642'
COLOR_VOLUME = '#268bd2'
COLOR_AXES = '#657b83'
COLOR_TITLE = '#002b36'
COLOR_BACKGROUND = '#f6f6f6'
fig = plt.figure(figsize=(8, 6), facecolor = COLOR_BACKGROUND)
gs = fig.add_gridspec(2, 1, height_ratios=(3, 1),
bottom=0.1, top=0.9,
hspace=0.05
)
# Add the prices plot
ax = fig.add_subplot(gs[0, 0])
ax.bar(data['python_date'],
bottom=data['Open'],
height=data['Close']-data['Open'],
color=[COLOR_RED if c < o else COLOR_GREEN for c, o in zip(data['Close'], data['Open'])],
alpha=0.9,
zorder=3,
width=0.85
)
for i in range(len(data)):
ax.vlines(x=data['python_date'][i], ymin=data['Low'][i], ymax=data['High'][i], color=COLOR_VLINES, zorder=2, linewidth=0.7)
ax.grid(axis='y', color='#eee', zorder=-1)
ax.set_facecolor(COLOR_BACKGROUND)
# Add the volumes plot
ax2 = fig.add_subplot(gs[1, 0], sharex=ax)
ax2.bar(data['python_date'], data['Volume'], width=1.00, color=COLOR_VOLUME, alpha=0.5)
ax2.set_facecolor(COLOR_BACKGROUND)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment