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
import matplotlib.pyplot as plt | |
import pandas as pd | |
import numpy as np | |
# Read the csv file into a pandas dataframe | |
# A dataframe is basically a table of data. | |
df_housing = pd.read_csv("housing.csv") | |
# Get figure object and an array of axes objects | |
fig, arr_ax = plt.subplots(2, 2) |
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
import matplotlib.pyplot as plt | |
fig, arr_ax = plt.subplots(2,2) | |
# arr_ax is a 2d array of axes objects | |
arr_ax[0,0].set_title('First subplot') | |
arr_ax[0,1].set_title('Second subplot') | |
arr_ax[1,0].set_xlabel('Third subplot') | |
arr_ax[1,1].set_xlabel('Fourth subplot') |
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
import matplotlib.pyplot as plt | |
fig = plt.figure() | |
# Generate a grid of 2x2 subplots and get | |
# axes object for 1st location | |
ax1 = fig.add_subplot(2,2,1) | |
ax1.set_title('First Location') | |
# Get the axes object for subplot at 2nd |
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
import matplotlib.pyplot as plt | |
# Function to get the square of each element in the list | |
def list_square(a_list): | |
return [element**2 for element in a_list] | |
# Multiple subplots in same figure | |
fig3 = plt.figure() | |
x = [1, 2, 3, 4, 5] | |
y = x |
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
import matplotlib.pyplot as plt | |
# Function to get the square of each element in the list | |
def list_square(a_list): | |
return [element**2 for element in a_list] | |
# Multiple plot in same subplot window | |
# plot y = x and z = x^2 in the same subplot window | |
fig2 = plt.figure() |
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
import matplotlib.pyplot as plt | |
# Generate data for plots | |
x = [1, 2, 3, 4, 5] | |
y = x | |
# Get an empty figure | |
fig1 = plt.figure() | |
# Get the axes instance at 1st location in 1x1 grid |
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
# coding: utf-8 | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# Generate 1000 numbers from gaussian sample | |
mean = 10 | |
std = 0.5 | |
num_samples = 1000 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.