The Python Data Visualization Essentials

import matplotlib.pyplot as plt%matplotlib inline

Scatter Plots — plt.scatter()

https://www.w3schools.com/python/img_scatterplot.png
  • plt.title(), which adds a title to your plot
  • plt.legend(), which will provide a key that describes what is being plotted. *Pro tip* If you use the label parameter mentioned above while also using plt.legend(), it will take what you put in the label parameter and include it in your key.
  • plt.xlabel(), which labels the x-axis
  • plt.ylabel(), which labels the y-axis
  • plt.figure(figsize=(width, height)), which will determine the size of your plot, in inches
plt.figure(figsize=(10,6))plt.scatter(x, y, label = "This will appear in legend")plt.xlabel('X Values')
plt.ylabel('Y Values')
plt.title('Scatter Plot in Matplotlib')
plt.legend()
plt.show()

Bar Graphs — plt.bar()/plt.barh()

https://www.tutorialspoint.com/matplotlib/images/matplotlib_bar_plot.jpg
https://python-graph-gallery.com/wp-content/uploads/2017/06/2_horizontal_barplot.png
plt.figure(figsize=(10,6))plt.bar(x, y, label=’Sample Data’)plt.xlabel(‘Programming Languages’)
plt.ylabel(‘Language Frequency’)
plt.title(‘Popular Programming Languages’)
plt.legend()
plt.show()

Histograms — plt.hist()

https://datatofish.com/wp-content/uploads/2019/01/003_hist.png
plt.hist(x, bins = 10, edgecolor=’black’)plt.xlabel(‘Groups’)
plt.ylabel(‘Frequency of Values’)
plt.title(‘A Histogram in Matplotlib’)
plt.show()
https://i.stack.imgur.com/jKQMo.png

--

--

--

Fitness, Sports, Data — And not necessarily in that order

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

The Gift of Rust — Merry Christmas!

Top 9 YouTube Channels for Programmers

NoNotes: Call Recording App for iPhones

AWS Elastic load balance and CORS issues

Composing Elements in a Cutscene- Game Dev Series 62

How to implement navigation drawer in your android app with an example

3/10–2

The Differences and Your First Time Setup

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Acusio Bivona

Acusio Bivona

Fitness, Sports, Data — And not necessarily in that order

More from Medium

Data visualization on python: lecture 2

An Alliance: Python and R (EDA)

Bring your boring plots to life by animating them (using plotly express)

Using style.applymap() as an Seaborn Heatmap alternative