Created
November 13, 2019 03:24
-
-
Save jbarton311/4d0a1f6612fff18104b4f7e55a82dbe1 to your computer and use it in GitHub Desktop.
How to draw a simple plot in matplotlib
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
from matplotlib import pyplot as plt | |
plt.style.use("fivethirtyeight") | |
COLORS = ['#456789', '#894567', '#678945', '#3B3D4B', '#FF8181'] | |
# Create data | |
x4 = ['$50K (Median Salary)', '$1 Million', '$1 Billion'] | |
y4 = [50000, 1000000, 1000000000] | |
# Create a figure and axis | |
fig4, ax4 = plt.subplots(figsize=(50, 10)) | |
ax4.set_title('How much money is a billion dollars?', fontsize=60) | |
# Plot the data | |
ax4.barh(x4, y4, color=COLORS[:2]) | |
# Remove x-axis ticks | |
ax4.get_xaxis().set_ticks([]) | |
# Adjust font size for a few different attritubtes | |
for item in ([ax4.title, ax4.xaxis.label, ax4.yaxis.label] + | |
ax4.get_xticklabels() + ax4.get_yticklabels()): | |
item.set_fontsize(25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment