3 回答
TA贡献1864条经验 获得超2个赞
您没有ax正确指定参数。试试这个:
fig, (ax1,ax2) = plt.subplots(1,2, figsize=(16,6))
ax1.set_title('Latitute')
sns.scatterplot(x='price', y='lat', data=df, ax=ax1)
ax2.set_title('Longitude')
sns.scatterplot(x='price', y='long', data=df, ax=ax2)
TA贡献1836条经验 获得超5个赞
您似乎遗漏了第二个ax参数。尝试:
plt.figure(figsize = (16, 12))
ax = plt.subplot(1,2,1)
sns.relplot(x="total_bill", y="tip", data=tips, ax= ax);
ax = plt.subplot(1,2,2)
sns.scatterplot(x="total_bill", y="tip", data=tips, ax= ax);
TA贡献1839条经验 获得超15个赞
#Somthing like this should work
import numpy as np
import matplotlib.pyplot as plt
x1 = [1, 2, 3, 4, 5]
x2 = [1, 2, 3, 4, 5]
y1 = [1, 8, 27, 36, 125]
y2 = [1, 4, 9, 16, 25]
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(5, 3))
axes[0].plot(x1, y1)
axes[1].plot(x2, y2)
fig.tight_layout()
plt.show()
添加回答
举报