- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何缩放seaborn jointplot的边际kdeplot?
假设我们有 1000 个类型“a”的数据、100 个类型“b”的数据和“100”个类型“c”的数据。
在这种情况下,边际 kdeplot 的比例看起来并不相同,因为分类数据的大小差异很大。
如何使它们相同?
我制作了一个如下所示的玩具脚本:
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pylab as plt
ax, ay = 1 * np.random.randn(1000) + 2, 1 * np.random.randn(1000) + 2
bx, by = 1 * np.random.randn(100) + 3, 1 * np.random.randn(100) + 3
cx, cy = 1 * np.random.randn(100) + 4, 1 * np.random.randn(100) + 4
a = [{'x': x, 'y': y, 'kind': 'a'} for x, y in zip(ax, ay)]
b = [{'x': x, 'y': y, 'kind': 'b'} for x, y in zip(bx, by)]
c = [{'x': x, 'y': y, 'kind': 'c'} for x, y in zip(cx, cy)]
df = pd.concat([pd.DataFrame.from_dict(a), pd.DataFrame.from_dict(b), pd.DataFrame.from_dict(c)], ignore_index=True)
print(df)
x y kind
0 2.500866 2.700925 a
1 -0.386057 3.322318 a
2 1.691078 2.558366 a
3 2.235042 -0.113836 a
4 3.331039 1.138366 a
... ... ... ...
1195 3.703245 2.935332 c
1196 1.806040 2.842754 c
1197 5.431313 5.377297 c
1198 3.873162 6.200356 c
1199 4.111234 3.038126 c
[1200 rows x 3 columns]
sns.jointplot(data=df, x='x', y='y', hue="kind")
plt.show()
最佳答案
您可以使用marginal_kws=
为边缘图添加关键字。在这种情况下,边际使用 sns.kdeplot
它具有 commmon_norm
和 multiple
等参数。
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
ax, ay = 1 * np.random.randn(1000) + 2, 1 * np.random.randn(1000) + 2
bx, by = 1 * np.random.randn(100) + 3, 1 * np.random.randn(100) + 3
cx, cy = 1 * np.random.randn(100) + 4, 1 * np.random.randn(100) + 4
a = [{'x': x, 'y': y, 'kind': 'a'} for x, y in zip(ax, ay)]
b = [{'x': x, 'y': y, 'kind': 'b'} for x, y in zip(bx, by)]
c = [{'x': x, 'y': y, 'kind': 'c'} for x, y in zip(cx, cy)]
df = pd.concat([pd.DataFrame.from_dict(a), pd.DataFrame.from_dict(b), pd.DataFrame.from_dict(c)], ignore_index=True)
sns.jointplot(data=df, x='x', y='y', hue="kind" , marginal_kws={'common_norm':False})
plt.show()
关于matplotlib - 如何使用不平衡的分类数据缩放seaborn联合图的边际kdeplot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73345895/
我正在尝试了解二叉树的属性。但我不确定一件事: 定义。二叉树的声明: 如果对于每个节点,它认为左子树中的内部节点数和右子树中的内部节点数最多相差 1,则二叉树是平衡的。 如果任意两个叶子的差异都存在,
我有一个带有分片键和索引的集合。但是当我运行平衡时,不会为这个集合移动 block ,因为其他集合 block 正在按预期移动到其他机器。此集合中仅移动了一个 block 。 最佳答案 目前(这将在不
给定一个data.table如下,id1是一个subject-level ID,id2是一个within-subject repeated-measure ID,X 是数据变量,其中有很多。我想平衡数
由于 C++ 集合是在二叉树中实现的,如果我们以递增或递减顺序插入项目,那么集合将更像是一个列表而不是树。有没有什么方法可以在插入项目后平衡树? 最佳答案 C++ 集(即 std::set)通常实现为
我是一名初学者程序员,设计了一个智能手机网站,我有一个主体背景图像,我想慢慢改变颜色平衡,交替颜色,就像有人将 Photoshop 颜色平衡控制条调整一定百分比一样。任一方向。当您查看页面时,这种情况
我开发了一段多线程代码。该代码在 Web 应用程序中调用,因此可能由多个线程(请求)并行调用。为了控制此代码将要创建的线程数量(通过多个并行请求调用),我使用静态共享 ThreadPoolExecut
我正在为 Linux 内核开发一些网络驱动程序。我有几个 if-else 条件,我正在重新分配或释放“skb”结构——这是我有点困惑的地方。关于我在那些 if-else 中做什么 - 我遇到了 2 种
平衡 BST 的最佳和最差搜索性能是什么?每种情况发生时如何用一句话解释? 最佳答案 最佳情况:当搜索到的元素位于树的根部时。你得到 O(1)。 最坏情况:当搜索元素在最长分支的叶子处时,树是单边的。
我在平衡 AVL 树问题上遇到了麻烦,因为我的解决方案似乎与教科书后面的解决方案冲突。我查看了 AVL 树的在线可视化,他们认为我的是正确的。我的课本错了吗? 这是树: 然后我必须将 65 插入到这个
我有一个系统,我在其中使用 RS232 来控制一个灯,该灯接受以浮点形式给出的表示电压(在 2.5 - 7.5 范围内)的输入。然后控件会给出 0 到 6000 范围内的输出,这是传感器拾取的亮度。
我有一个分层目录,每个目录中有很多文件,每个文本文件中有很多 URL 字符串。我想下载 Hadoop 中所有文件中的所有 URL,以实现更好的平衡。 例如,如果我有 1+5 个节点的 Hadoop 集
请查看附件图片,这是一种跷跷板。但从图像来看,黑体具有相同的密度。并且水平矩形使用“Revolute”关节与三角形相连。但仍然没有任何建议。在目前的情况下,它需要平衡。 最佳答案 由于浮点精度等限制导
因此,在平衡 KD 树时,您应该找到中位数,然后将所有较小的元素放在左子树上,将较大的元素放在右子树上。但是,如果您有多个元素与中位数具有相同的值,会发生什么情况?他们进入左子树,右子树还是丢弃它们?
请帮我找到一种干净的方法来从现有数组中创建一个新数组。如果任何类的示例数小于该类中的最大示例数,则应该进行过采样。样本应该从原始数组中提取(随机或顺序都没有区别) 比方说,初始数组是这样的: [ 2
我是一名软件开发人员,但想成为服务器可扩展性领域的新架构师。 在多个服务使用同一数据集的情况下,旨在扩展冗余和负载平衡。 问题是:在一个理想主义的系统中,服务是否应该尝试优化它们的内部处理以减少对远程
假设我有 10 个分区用于 Kafka 中的给定主题。 我的选择是在消费者之间自动平衡这 10 个分区的负载? 我已经阅读了这篇文章 https://stackoverflow.com/a/28580
假设我有一个 B 树,其节点为 3-4 配置(3 个元素和 4 个指针)。假设我按照规则合法地建立我的树,我是否有可能达到一层中有两个节点并且一个节点有 4 个退出指针而另一个节点只有两个退出指针的情
当光标在一个括号上时,如何跳转到配对括号。很高兴在 工作emacs -nw . 就像 % 在 Vim 中。 ;;从@Lindy、@Francesco 得到提示后,我发现了更多: C-M-f
我在平衡 AVL 树时遇到问题。我一直在寻找如何平衡它们的步骤,但我找不到任何有用的东西。 我知道有4种: 单左旋 单右旋 双左右旋转 双左右旋转 但我就是无法得到如何选择其中之一和 在哪个节点上应用
我想获得类似于打印中平衡文本行但用于 block 元素的结果。假设在一个 300/100 像素的容器中有一组 50/50 像素的盒子。在容器中 float 盒子将使它们填满一“行”,然后像这样包裹到下
我是一名优秀的程序员,十分优秀!