1 回答

TA貢獻1860條經驗 獲得超8個贊
我嘗試將 the 替換為boxplot
a ridge plot
,它占用的空間更少,因為:
它需要寬度的一半
你可以部分重疊山脊
它是垂直發展的,所以你可以向下滾動所有的情節
我從seaborn 文檔中獲取代碼并對其進行了一些調整,以便擁有 60 個不同的正態分布的脊;這里的代碼:
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import itertools
sns.set(style="white", rc={"axes.facecolor": (0, 0, 0, 0)})
# # Create the data
n = 20
x = list(np.random.randn(1, 60)[0])
g = [item[0] + item[1] for item in list(itertools.product(list('ABCDEFGHIJ'), list('123456')))]
df = pd.DataFrame({'x': n*x,
'g': n*g})
# Initialize the FacetGrid object
pal = sns.cubehelix_palette(10, rot=-.25, light=.7)
g = sns.FacetGrid(df, row="g", hue="g", aspect=15, height=.5, palette=pal)
# Draw the densities in a few steps
g.map(sns.kdeplot, "x", clip_on=False, shade=True, alpha=1, lw=1.5, bw=.2)
g.map(sns.kdeplot, "x", clip_on=False, color="w", lw=2, bw=.2)
g.map(plt.axhline, y=0, lw=2, clip_on=False)
# Define and use a simple function to label the plot in axes coordinates
def label(x, color, label):
ax = plt.gca()
ax.text(0, .2, label, fontweight="bold", color=color,
ha="left", va="center", transform=ax.transAxes)
g.map(label, "x")
# Set the subplots to overlap
g.fig.subplots_adjust(hspace=-.25)
# Remove axes details that don't play well with overlap
g.set_titles("")
g.set(yticks=[])
g.despine(bottom=True, left=True)
plt.show()
這是我得到的結果:
我不知道它是否適合您的需求,無論如何請記住,將如此多的發行版彼此相鄰放置總是需要大量空間(和非常大的屏幕)。也許您可以嘗試將分布分成更小的組并一次繪制一點?
添加回答
舉報