简体   繁体   English

避免在海积地块上重叠

[英]Avoid overlapping on seaborn plots

I'm making some EDA using pandas and seaborn, this is the code I have to plot the histograms of a group of features: 我正在使用pandas和seaborn进行一些EDA,这是我必须绘制一组要素的直方图的代码:

skewed_data =  pd.DataFrame.skew(data)
skewed_features =skewed_data.index

fig, axs = plt.subplots(ncols=len(skewed_features))
plt.ticklabel_format(style='sci', axis='both', scilimits=(0,0))
for i,skewed_feature in  enumerate(skewed_features):
    g = sns.distplot(data[column])  
    sns.distplot(data[skewed_feature],  ax=axs[i])

This is the result I'm getting: 这是我得到的结果:

在此处输入图片说明

Is not readable, how can I avoid that issue? 不可读,如何避免该问题?

I know you are concerning about the layout of the figures. 我知道您担心这些数字的布局。 However, you need to first decide how to represent your data. 但是,您需要首先决定如何表示数据。 Here are two choices for your case 这是您的情况的两种选择

(1) Multiple lines in one figure and (1)在一个图中多行和

(2) Multiple subplots 2x2, each subplot draws one line. (2)多个子图2x2,每个子图绘制一条线。

I am not quite familiar with searborn, but the plotting of searborn is based on matplotlib. 我对searborn不太熟悉,但是searborn的绘制基于matplotlib。 I could give you some basic ideas. 我可以给你一些基本的想法。

To archive (1), you can first declare the figure and ax, then add all line to this ax. 要存档(1),您可以先声明图形和斧头,然后将所有行添加到此斧头。 Example codes: 示例代码:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
# YOUR LOOP, use the ax parameter
for i in range(3)
    sns.distplot(data[i], ax=ax)

To archive (2), same as above, but with different number subplots, and put your line in the different subplot. 要存档(2),与上面相同,但是具有不同数量的子图,并将行放在不同的子图中。

# Four subplots, 2x2
fig, axarr = plt.subplots(2,2)
# YOUR LOOP, use different cell

You may check matplotlib subplots demo . 您可以检查matplotlib子图演示 To do a good visualization is a very tough work. 进行良好的可视化是一项艰巨的工作。 There are so many documents to read. 有太多的文档要阅读。 Check the gallery of matplotlib or seaborn is a good and quick way to understand how some kinds of visualization are implemented. 检查matplotlibseaborn的库是了解如何实现某些可视化的一种好方法。

Thanks. 谢谢。

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

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