Skip to main content

Command Palette

Search for a command to run...

#33 - Python MATPLOTLIB

By Ifeanyi Omeata

Published
2 min read
#33 - Python MATPLOTLIB
I

Hi, I am a Software Developer of 3-4 years specialising in React, Javascript, Node, NextJS, Express, Python, Django, Fast API, SQL and a few other technology stack, with a good background in Networking and Cloud Infrastructure. I am working to become a DevOps Solutions Engineer and happily married to my long time girlfriend.


Topics:


1. MATPLOTLIB


1. MATPLOTLIB


>>Return to Menu







pip3 install matplotlib

#LINEAR CHART

from matplotlib import pyplot as plt

ages_x = [25,26,27,28,29,30,31,32,33,34,35]

java_dev_y = [38496,42000,46752,49320,53200,56000,62316,64928,67317,68748,73752]
py_dev_y = [45372,48876,53850,57287,63016,65998,70003,70000,71496,75370,83640]

plt.plot(ages_x, java_dev_y, color='#444444', linestyle='--', marker='.', label='All Devs')
plt.plot(ages_x, py_dev_y, color='#5a7d9a', marker='o', label='Python')

plt.xlabel('Ages')
plt.ylabel('Median Salary (USD)')
plt.title('Median Salary (USD) by Age')

plt.legend()
plt.show()

#PIE CHART

from matplotlib import pyplot as plt

plt.style.use('fivethirtyeight')

slices = [120, 80, 60, 40]
labels = ['one','two','three','four']
colors = ['#008fd5','#fc4f30','#e5ae37','#6d904f']

plt.pie(slices, labels=labels, colors=colors, wedgeprops={'edgecolor':'black'})
plt.title('My Pie Chart')
plt.tight_layout()
plt.show()
from matplotlib import pyplot as plt

plt.style.use('fivethirtyeight')

slices = [120, 80, 60, 40, 30]
labels = ['one','two','three','four', 'five']
colors = ['#008fd5','#fc4f30','#e5ae37','#6d904f','#f4f4cc']

plt.pie(slices, labels=labels, shadow=True, startangle=90, autopct='%1.1f%%', colors=colors, wedgeprops={'edgecolor':'black'})
plt.title('My Pie Chart')
plt.tight_layout()
plt.show()

#End


Hope you enjoyed this! :) Follow me for more contents...


Get in Touch:
www.ifeanyiomeata.com
contact@ifeanyiomeata.com

Youtube: https://www.youtube.com/c/IfeanyiOmeata
Linkedin: https://www.linkedin.com/in/omeatai/
Twitter: https://twitter.com/iomeata
Github: https://github.com/omeatai/
Stackoverflow: https://stackoverflow.com/users/2689166/omeatai
Hashnode: https://hashnode.com/@omeatai
Medium: https://medium.com/@omeatai
© 2022

LEARN PYTHON/DJANGO

Part 4 of 37

Learn Python and Django the easy way!..... PYTHON | DJANGO | FASTAPI

Up next

#32 - Python PANDAS

By Ifeanyi Omeata