在Matplotlib中更改图形“删除”点的大小

时间:2019-06-15 09:49:51

标签: python matplotlib

我尝试调整身材的大小。但是,当我这样做的时候,通过添加plt.figure(figsize=(10,5))我再也看不到这些点了。我要更改大小的原因主要是因为ylabel并未像现在这样显示。 enter image description here enter image description here

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from sklearn import linear_model

# Check out the Data
df = pd.read_csv("https://s3.amazonaws.com/codecademy-content/programs/data-science-path/linear_regression/honeyproduction.csv")
# print(df.head())
# print(df.columns)

prod_per_year = df.groupby(['year']).totalprod.mean().reset_index()
# print(prod_per_year)

X = prod_per_year['year']
X = X.values.reshape(-1, 1)
y = prod_per_year['totalprod']

plt.scatter(X, y)
plt.xlabel('Year')
plt.ylabel('Total production')
plt.show()

# Create and Fit a Linear Regression Model
regr = linear_model.LinearRegression()
regr.fit(X, y)

# Print out the slope (regr.coef_) and the intercept (regr.intercept_)
print(regr.coef_)
print(regr.intercept_)

y_predict = regr.predict(X)
plt.figure(figsize=(10,5))
plt.plot(X, y_predict)
plt.show()

0 个答案:

没有答案