第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

因子圖的軸有什么問題?

因子圖的軸有什么問題?

阿晨1998 2022-09-20 17:23:07
我有這個(gè)數(shù)據(jù)集:kaggle:房價(jià):高級(jí)回歸技術(shù)。我按如下方式加載了它:import numpy as npimport pandas as pdimport matplotlib.pyplot as plt%matplotlib inlineimport seaborn as snsimport scipy.stats as sttrain = pd.read_csv("train.csv")然后,我嘗試使用整體質(zhì)量作為色調(diào),按年份構(gòu)建繪制銷售價(jià)格:plt.figure(figsize = [8, 6])sns.factorplot(    x = 'YearBuilt',    y = 'SalePrice',     data = train,    kind='swarm',    hue='OverallQual',    palette = 'Set2')plt.title('House Sale Prices (log scale) vs. Year Built and Overall Quality')plt.xticks([1880, 1900, 1920, 1940, 1960, 1980, 2000], ['1880', '1900', '1920', '1940', '1960', '1980', '2000'])#plt.xlim([1872,2009])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()結(jié)果如下圖所示:如果我包含 xlim 或 ylim,則圖形根本不會(huì)顯示出來。我是新手,所以任何幫助都非常感謝。
查看完整描述

1 回答

?
蕪湖不蕪

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超7個(gè)贊

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()

http://img1.sycdn.imooc.com//632986da000145b309240428.jpg

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()

http://img1.sycdn.imooc.com//632986fd000180a009290434.jpg

查看完整回答
反對 回復(fù) 2022-09-20
  • 1 回答
  • 0 關(guān)注
  • 78 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)