Thursday, December 1, 2022

sub plotting multiple graphs

 import numpy as np

import matplotlib.pyplot as plt

# Consider method "load_house_data" load the dataset

X_train, y_train = load_house_data()

X_features = ['size(sqft)','bedrooms','floors','age']

fig,ax=plt.subplots(1, 4, figsize=(12, 3), sharey=True)

for i in range(len(ax)):

    ax[i].scatter(X_train[:,i],y_train)

    ax[i].set_xlabel(X_features[i])

ax[0].set_ylabel("Price (1000's)")

plt.show()



No comments:

Post a Comment