Skip to content

Instantly share code, notes, and snippets.

@catslovedata
Created April 10, 2023 15:04
Show Gist options
  • Save catslovedata/c6f1611c77fde0219563f2364fe3b0d7 to your computer and use it in GitHub Desktop.
Save catslovedata/c6f1611c77fde0219563f2364fe3b0d7 to your computer and use it in GitHub Desktop.
# Formatting
# Remove borders
for s in (ax.spines['top'], ax.spines['right'], ax.spines['bottom'], ax.spines['left'], ax2.spines['top'], ax2.spines['right'], ax2.spines['bottom'], ax2.spines['left']):
s.set_visible(False)
# Force all the dates to show on the x axis
ax2.set_xticks(data['python_date'])
# Remove x ticks and labels from the prices chart, remove ticks from the y axes
ax.tick_params(axis='x', labelbottom=False, bottom=False)
ax2.tick_params(axis='x', bottom=True, rotation=90, colors='#eee')
ax.tick_params(axis='y', left=False)
ax2.tick_params(axis='y', left=False)
# Don't use "scientific" notation (1e6) for the labels
ax2.ticklabel_format(style='plain', axis='y')
# Format the ticks and values
for tick in (ax.get_yticklabels() + ax2.get_yticklabels() + ax2.get_xticklabels()):
tick.set_fontname('Consolas')
tick.set_fontsize(10)
tick.set_color(COLOR_AXES)
ax.set_ylabel('Price', font='Consolas', fontsize=12, color=COLOR_AXES)
ax2.set_ylabel ('Volume', font='Consolas', fontsize=12, color=COLOR_AXES)
# Set titles
# Read a font file from disk
font=fm.FontProperties(fname="D:\Downloads\Playfair_Display\static\PlayfairDisplay-Medium.ttf")
plt.suptitle('Price and Volume for\nFictitious Stock or Crypto Token', fontproperties=font, fontsize=24, color=COLOR_TITLE, y=1.05)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment