- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个包含三列的数据框 Features, CV-fold, Accuracy, Network
.我想为每个网络绘制一个箱线图,按轴的特征和 CV 折叠进行分组(参见示例图像)。
df = pd.read_csv(path)
df['Features'] = df["Features"].astype('category')
ordered_features = sorted(df.Network.value_counts().index)
df = df.loc[df['Accuracy'] > 0.1]
df.Accuracy = df.Accuracy*100
#sns.color_palette("husl", len(df['CV-fold'].value_counts().index))
#sns.set_palette('husl', len(df['CV-fold'].value_counts().index))
g = sns.FacetGrid(df, row="Network", row_order=ordered_features,
height=3, aspect=3, legend_out=True, despine=False)
g.map(sns.boxplot, x="CV-fold", y="Accuracy", hue="Features", data=df, palette='muted').add_legend()
g.set_axis_labels("", "Accuracy (%)")
sharex
未启用,x 轴仅标记在最底部的图形。
最佳答案
您将使用 col_wrap
关键字参数以在多列的多行上绘制您的图。
要重复 x 轴标签,请使用 ax.tick_params()
.
例子:
import seaborn as sns, matplotlib.pyplot as plt
tips = sns.load_dataset('tips')
ordered_days = sorted(tips['day'].unique())
g = sns.FacetGrid(tips,col='day',col_order=ordered_days,col_wrap=2)
# change this to 4 ^
g.map(sns.boxplot,'sex','total_bill',palette='muted')
for ax in g.axes.flatten():
ax.tick_params(labelbottom=True)
plt.tight_layout()
plt.show()
关于python - 将箱线图排列为带有 seaborn `FacetGrid` 的网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60265159/
我正在尝试创建一个 seaborn FacetGrid 来显示我拥有的某些数据中集群之间的转换概率。数据有一堆主题和 4 个集群(因此每个主题有 16 个数据点,每对新旧集群一个)。因为这些是概率,所
我的结构遵循 pandas DataFrame: n X Y Z 0 1.000000 1.000000 1.014925 1
我一直在与 seaborn.catplot 一起工作为了有一个条形图(下面的数据样本)将 counts 中的值相加一套的列reasons ,由一组公司分隔: sns.catplot(x='Bill_N
我有以下代码可以创建您可以在图片中看到的情节: g = sns.FacetGrid(data, col="Provincia",col_wrap=6,size=2.5) g.map(sns.barpl
我使用 Seaborn 绘制了一个简单的 RelPlot,它返回了一个 Facetgrid 对象。我使用的代码如下: import seaborn as sns palette = sns.color
我有一组数据,我正在尝试使用 seaborn 中的 FacetGrid 绘制这些数据。每个数据点都有一个与之相关的权重,我想在网格的每个方面绘制一个加权直方图。 例如,假设我有以下(随机创建的)数据集
是否可以使用seaborn创建堆叠条形图facetgrid? g = sns.FacetGrid(data, col="city", col_order=cities, col_wrap=3, hei
提前抱歉图像数量过多,但它们有助于演示问题 我构建了一个数据框,其中包含多个基材、多个层的薄膜厚度测量值,作为坐标的函数: | | Sub | Result | Layer | Row | Co
我正在尝试使用seaborn创建一个Facetgrid来显示我的所有列分布以及正态分布线以与正态分布进行比较。 我在pandas中的数据帧看起来像这样: column values 0
我有 2 个数据帧,1 个有训练数据,另一个有标签。训练数据中有 6 个特征/列,标签数据框中有 1 列。我想要我的面网格中有 6 个图 - 所有这些都是散点图。因此,特征 1 与标签、特征 2 与标
给出以下示例: A = [0, 1, 2] B = [3, 4, 5] C = [6, 7, 8, 9] df = pd.DataFrame(data = {'D': np.random.randn(
我正在尝试将颜色条添加到 3 个 seaborn 绘图的网格中。我可以将颜色条添加到 3 个单独的图,或者在第三个图旁边挤压一个颜色条。我想在第三个图之后有一个颜色条,而不改变最后一个图的大小。 我从
给定一些数据: pt = pd.DataFrame({'alrmV':[000,000,000,101,101,111,111], 'he':[e,e,e,e,h
灵感来自 this page 上的示例,我想用 Iris 数据集制作一个 seaborn facetgrid,它有 6 个方面:3 种 x 2 种类型(花瓣或萼片)。在每个方面,我都需要一个长度(或宽
如果我通过 FacetGrid().map() 更改 plt.plot 实例的线宽,我将丢失图例中线型的详细信息。在此图中,线型从图表中正确可见 但是,如果我增加线宽 z 不再正确显示线型 如果你想重
我想每月绘制数据并每年显示一次年份标签。这是数据: timedates = ['2013-01-01', '2013-02-01', '2013-03-01', '2013-04-01', '2013
在 Seaborn 中,您可以使用 FacetGrid 设置要在其上绘制的数据感知网格。然后,您可以使用 map 或 map_dataframe 方法绘制这些网格。 我无法正确指定与 map 或 ma
我有一个具有以下结构的 DataFrame: interval segment variable value 4 02:00:00 Night weekdays
我正在尝试在 Seaborn 中创建一个 FacetGrid 我的代码目前是: g = sns.FacetGrid(df_reduced, col="ActualExternal", margin_t
我想在 Facetgrid 的每个图中反转 y 轴。 下面是代码的简化示例: import pandas as pd import numpy as np import seaborn as sns
我是一名优秀的程序员,十分优秀!