简体   繁体   English

Jupyter:Seaborn对图很难设置图形尺寸?

[英]Jupyter: Seaborn pairplot difficult to set graph dimensions for?

I was trying to create a bivariate scatterplot of each variable against every other that are in a dataframe, and I found sns.pairplot() was exactly what I needed. 我试图针对数据sns.pairplot()的每个变量创建一个双变量散点图,我发现sns.pairplot()正是我所需要的。

However, no matter what I do (and I have tried all of the advice found in this question ), the plots keep coming out too spread out , as well as in general too big. 但是,无论我做什么(并且我已经尝试过在此问题中找到的所有建议),地块总是散布得太大 ,而且通常也太大。 In the picture below, only the first two rows and four columns out of 12 variables display on my entire screen. 在下面的图片中,我的整个屏幕上只显示12个变量中的前两行和四列。

在此处输入图片说明

I have found out that my use of 我发现我对

%config InlineBackend.figure_format = 'svg'

to create non-blurry graphs on my high-ppi screen is partially at blame, as without it, I instead get this graph, which fits perfectly on my screen, but is now too small and I would prefer to scroll slightly around while having a bigger pic. 在高ppi屏幕上创建非模糊图形的部分原因是,如果没有它,我会得到这张图形,它非常适合我的屏幕,但是现在它太小了,我宁愿稍微滚动一下,更大的照片。

(note: the additional options below have no effect) (注意:以下附加选项无效)

在此处输入图片说明

How can I make the grid of plots customizable in its overall size as well as spacing? 如何使图样的总体大小和间距可定制? As it stands, no options work, and one graphics backend (the default one) produces too small graphs, while the 'svg' backend produces too large ones. 就目前而言,没有选项起作用,一个图形后端(默认值)产生的图形太小,而'svg'后端产生的图形太大。

EDIT: Editing sns.set(rc={'figure.figsize':(x,y)}) or the height / aspect options improve nothing: the former produces no change, while the latter two change how big the individual plots are (with height=1 making them indecipherable), but the overall "grid" is still as bulky and overly large as before. 编辑:编辑sns.set(rc={'figure.figsize':(x,y)})height / aspect选项没有任何改善:前者不会产生任何变化,而后两者会改变各个图的大小( height=1因此无法辨认),但总体“网格”仍然像以前一样庞大且过大。

Essentially you are asking how to display the figure in its original size in a jupyter notebook. 本质上,您是在问如何在jupyter笔记本中以原始尺寸显示图形。
That translates into how to add scrollbars if it exceeds the room it's given by the layout of the output cell. 如果它超出了输出单元格的布局所给定的空间,那就意味着如何添加滚动条。

I think for the horizontal direction this can be done as follows. 我认为对于水平方向,可以按照以下步骤进行操作。 However for the vertical direction this does not seem to work. 但是,对于垂直方向,这似乎不起作用。

%matplotlib inline

# Cell2
from IPython.display import display, HTML
CSS = """div.output_area img {max-width:None !important;max-height: None !important";}"""
display(HTML('<style>{}</style>'.format(CSS)))

# Cell3
import matplotlib.pyplot as plt
fig, ax = plt.subplots(ncols=8, figsize=(20,10))

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM