python - 如何在 seaborn Pairplot 中设置 x 轴大小
问题描述
我正在使用 Seaborn 来绘制 Pairplots。问题是,对于某些变量,x 轴的大小很小,数据点彼此非常接近,如下所示(第一行图):
如您所见,第二行中的图很好。
这是我正在使用的代码:
import math
import matplotlib.pyplot as plt
import seaborn as sns
y_name = 'y'
features = data.iloc[:, :-1]
features_names = features.columns
plot_size=7
num_plots_x=10 # No. of plots in every row
num_plots_y = math.ceil(len(features_names)/num_plots_x) # No. of plots in y direction
fig = plt.figure(figsize=(plot_size*num_plots_y, plot_size*num_plots_x), facecolor='white')
axes = [fig.add_subplot(num_plots_y,1,i+1) for i in range(num_plots_y)]
for i, ax in enumerate(axes):
start_index = i * num_plots_x
end_index = (i+1) * num_plots_x
if end_index > len(features_names): end_index = len(features_names)
sns.pairplot(x_vars=features_names[start_index:end_index], y_vars=y_name, data = data)
plt.savefig('figure.png')
有什么方法可以设置 x 轴的大小或比例?
解决方案
推荐阅读
- cs-cart - 如何通过 API 在 cs 购物车中按名称获取 category_id?
- objective-c - 后台进程的目标 C 代码
- docker - Docker-compose:exec用户进程导致“没有这样的文件或目录”但文件存在
- css - 两列,一列可滚动
- c# - C#设置接收超时(最佳/充足时间)
- ios - 将代码从 Swift 2 更改为 swift 4
- git - 无法访问,schannel: 无法打开 CA 文件,没有这个进程,GitHub Desktop
- python - Scrapy CSS Selector 选择文本和空白
- java - 泛型的类型安全
- java - 用户手机上应用搜索的关键字列表