1 回答

TA貢獻1796條經驗 獲得超7個贊
plt.style.use('ggplot')
g = sns.catplot(
x = 'YearBuilt',
y = 'SalePrice',
data = train,
kind='swarm',
hue='OverallQual',
palette = 'Set2', height=6, aspect=2)
locs, labels = plt.xticks() # use if needed, as explained below.
for axes in g.axes.flat:
for ind, label in enumerate(axes.get_xticklabels()):
if ind % 8 == 0: # every nth label is kept
label.set_visible(True)
else:
label.set_visible(False)
plt.title('House Sale Prices (log scale) vs. Year Built and Overall Quality')
plt.xlabel('Year Built')
plt.yscale('log')
plt.ylim([4e4, 6e5])
plt.yticks([6e4, 1e5, 1.4e5, 1.8e5, 2.4e5, 3.2e5, 4e5, 6e5], ['60k', '100k', '140K', '180k', '240K', '320k', '600k'])
plt.ylabel('Sale Price ($)')
plt.show()
plt.style.use('ggplot')
g = sns.catplot(
x = 'YearBuilt',
y = 'SalePrice',
data = train,
kind='swarm',
hue='OverallQual',
palette = 'Set2', height=6, aspect=2)
locs, labels = plt.xticks() # use if needed, as explained below.
for axes in g.axes.flat:
for ind, label in enumerate(axes.get_xticklabels()):
if ind % 8 == 0: # every nth label is kept
label.set_visible(True)
else:
label.set_visible(False)
plt.title('House Sale Prices (log scale) vs. Year Built and Overall Quality')
plt.xlabel('Year Built')
plt.yscale('log')
plt.ylim([4e4, 6e5])
plt.yticks([6e4, 1e5, 1.4e5, 1.8e5, 2.4e5, 3.2e5, 4e5, 6e5], ['60k', '100k', '140K', '180k', '240K', '320k', '600k'])
plt.ylabel('Sale Price ($)')
plt.show()
添加回答
舉報