簡體   English   中英

matplotlib 中未顯示散點圖中的軸

[英]Axis in scatterplot are not shown in matplotlib

我在 matplotlib 中有一個散點圖,創建如下代碼

import matplotlib.pyplot as plt
import seaborn as sns


plt.figure(figsize=(20,10))

#
#cmap = sns.cubehelix_palette(rot=-.2, as_cmap=True)
ax = sns.scatterplot(x="avg_PE_train",
                 y="sale_log",
                 hue="ARTCL_DESC",
                 legend = False,
                 s = 300,
                 data = ...)


# Set x-axis label
plt.xlabel('PE Values', fontsize = 35)
# Set y-axis label
plt.ylabel('Q4 2019 Sales (log scale)', fontsize = 35)
plt.axvline(x=-1, ls='--', color='r')
#sns.set(rc={'figure.facecolor':'white'})

plt.rcParams['font.sans-serif'] = 'Arial'
plt.rcParams['font.family'] = 'sans-serif'
plt.rcParams['text.color'] = '#181a17'
plt.rcParams['axes.labelcolor']= '#181a17'
plt.rcParams['xtick.color'] = '#181a17'
plt.rcParams['ytick.color'] = '#181a17'
plt.rcParams['font.size']=30
ax.xaxis.label.set_color('black')
plt.xticks(size = 30)
plt.yticks(size = 30)
#plt.axis('on')
#ax.axes.get_xaxis().set_visible(True)

但它不顯示 x 軸或 y 軸(標簽是顯示這些軸,但我需要顯示 x 和 y 軸或在我的整個圖表周圍放置一個正方形

也許使用命令:

plt.show()

在您的代碼末尾。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM