- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下数据:
data = pd.read_json(
'{"var":{"0":"first","1":"first","2":"first","3":"first","4":"first","5":"first","6":"first","7":"first","8":"first","9":"first","10":"second","11":"second","12":"second","13":"second","14":"second","15":"second","16":"second","17":"second","18":"second","19":"second","20":"third","21":"third","22":"third","23":"third","24":"third","25":"third","26":"third","27":"third","28":"third","29":"third","30":"fourth","31":"fourth","32":"fourth","33":"fourth","34":"fourth","35":"fourth","36":"fourth","37":"fourth","38":"fourth","39":"fourth"},"level":{"0":"0_thing that has a long name","1":"1_thing that has a long name","2":"2_thing that has a long name","3":"3_thing that has a long name","4":"4_thing that has a long name","5":"5_thing that has a long name","6":"6_thing that has a long name","7":"7_thing that has a long name","8":"8_thing that has a long name","9":"9_thing that has a long name","10":"0_thing that has a long name","11":"10_thing that has a long name","12":"6_thing that has a long name","13":"1_thing that has a long name","14":"3_thing that has a long name","15":"11_thing that has a long name","16":"4_thing that has a long name","17":"12_thing that has a long name","18":"5_thing that has a long name","19":"8_thing that has a long name","20":"13_thing that has a long name","21":"14_thing that has a long name","22":"15_thing that has a long name","23":"2_thing that has a long name","24":"16_thing that has a long name","25":"17_thing that has a long name","26":"18_thing that has a long name","27":"19_thing that has a long name","28":"20_thing that has a long name","29":"21_thing that has a long name","30":"13_thing that has a long name","31":"14_thing that has a long name","32":"15_thing that has a long name","33":"17_thing that has a long name","34":"2_thing that has a long name","35":"16_thing that has a long name","36":"20_thing that has a long name","37":"19_thing that has a long name","38":"18_thing that has a long name","39":"21_thing that has a long name"},"perc":{"0":24.3984831429,"1":13.5578842078,"2":10.3199382674,"3":14.1345077706,"4":23.3194885437,"5":14.96065323,"6":6.9737304361,"7":4.5652339327,"8":14.6795644283,"9":7.1649849158,"10":25.1593226794,"11":26.7421480151,"12":25.4425967424,"13":13.0877463565,"14":22.5365146082,"15":6.9683523649,"16":4.3323141006,"17":5.6351294027,"18":19.7448577749,"19":18.313549886,"20":26.0610663959,"21":19.9363641877,"22":15.1851539498,"23":11.9681521323,"24":19.6658384346,"25":16.0016010889,"26":10.1760876224,"27":15.7193904379,"28":14.3090339426,"29":7.1062130393,"30":19.1928731445,"31":14.8213673984,"32":18.6516148253,"33":18.8066683576,"34":8.068435507,"35":7.2176894958,"36":12.3757903962,"37":15.6977275207,"38":12.0725474142,"39":16.1457855035}}'
)
看起来像:
data.shape
(40,3)
print(data.sample(2, random_state=1))
var level perc
2 first 2_thing that has a long name 10.319938
31 fourth 14_thing that has a long name 14.821367
我正在使用以下内容创建绘图:
sns.set(font_scale=1)
sns.set_style("white")
p = sns.catplot(
data=data,
x="level",
y="perc",
col="var",
col_wrap=2,
kind="bar",
hue="var",
sharex=False,
dodge=False,
sharey=False,
)
for axes in p.axes.flat:
axes.set_xticklabels(
axes.get_xticklabels(), rotation=65, horizontalalignment="right"
)
plt.tight_layout()
p.set_xlabels("")
p.fig.set_figwidth(15)
p.fig.set_figheight(5)
type(p)
输出:
我不确定如何在图之间留出空间,以便它们不会像上面那样重叠。
最佳答案
我会做一个 sharex=True
以便隐藏上部子图的刻度标签:
sns.set(font_scale=1)
sns.set_style("white")
p = sns.catplot(
data=data,
x="level",
y="perc",
col="var",
col_wrap=2,
kind="bar",
hue="var",
sharex=True, # different to your code
dodge=False,
sharey=False,
)
for axes in p.axes.flat:
axes.set_xticklabels(
axes.get_xticklabels(), rotation=65, horizontalalignment="right"
)
# plt.tight_layout()
p.set_xlabels("")
p.fig.set_figwidth(15)
p.fig.set_figheight(5)
输出:
关于python - 包裹时如何防止seaborn FacetGrid重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61085809/
我正在尝试创建一个 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
我是一名优秀的程序员,十分优秀!