How to Change Plot Background in Matplotlib
Introduction
Matplotlib is one of the most widely used data visualization libraries in Python. From simple to complex visualizations, it’s the go-to library for most.
In this tutorial, we’ll take a look at how to change the background of a plot in Matplotlib.
Importing Data and Libraries
Let’s import the required libraries first. We’ll obviously need Matplotlib, and we’ll use Pandas to read the data:
import matplotlib.pyplot as plt
import pandas as pd
Specifically, we’ll be using the Seattle Weather Dataset:
weather_data = pd.read_csv("seattleWeather.csv")
print(weather_data.head())
DATE PRCP TMAX TMIN RAIN
0 1948-01-01 0.47 51 42 True
1 1948-01-02 0.59 45 36 True
2 1948-01-03 0.42 45 35 True
3 1948-01-04 0.31 45 34 True
4 1948-01-05 0.17 45 32 True
Creating a Plot
Now, let’s create a simple Matplotlib Scatterplot, with a few