标签: jointplot

如何将颜色条添加到 kde jointplot 的一侧

我正在尝试在带有边缘轴的密度图旁边绘制一个颜色条。它确实绘制了颜色条,但不幸的是不是在侧面。到目前为止,这就是尝试过的:

sns.jointplot(x,y, data=df3, kind="kde", color="skyblue", legend=True, cbar=True,
              xlim=[-10,40], ylim=[900,1040])
Run Code Online (Sandbox Code Playgroud)

它看起来像这样:

带颜色条的seaborn jointplot“kde”风格

我也尝试过这个:

from matplotlib import pyplot as plt
import seaborn as sns
import numpy as np

kdeplot = sns.jointplot(x=tumg, y=pumg, kind="kde")
plt.subplots_adjust(left=0.2, right=0.8, top=0.8, bottom=0.2)
cbar_ax = kdeplot.fig.add_axes([.85, .25, .05, .4])
plt.colorbar(cax=cbar_ax)
plt.show()
Run Code Online (Sandbox Code Playgroud)

但使用第二个选项时,我收到运行时错误:

No mappable was found to use for colorbar creation. First define a mappable such as an image (with imshow) or a contour set (with contourf).

有谁知道如何解决这个问题?

python colorbar seaborn jointplot kdeplot

6
推荐指数
1
解决办法
5942
查看次数

如何获取没有填充的联合图标记

matplotlib.pyplot.scatter()有一个facecolors=None参数将使数据点看起来内部是空心的。如何获得相同的外观seaborn.jointplot()

在早期版本的seaborn中也发现了相同的论点,但由于某种原因在最新版本(0.11)中被删除。

python scatter-plot seaborn jointplot jointgrid

5
推荐指数
1
解决办法
3183
查看次数

如何从seaborn JointGrid或jointplot中移动或删除图例

如何去掉剧情中的图例seaborn.JoingGrid

参考代码如下:

import matplotlib.pyplot as plt
import seaborn as sns

penguins = sns.load_dataset("penguins")

g = sns.JointGrid(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="species")
g.plot_joint(sns.scatterplot)
sns.boxplot(data=penguins, x=g.hue, y=g.y, ax=g.ax_marg_y)
sns.boxplot(data=penguins, y=g.hue, x=g.x, ax=g.ax_marg_x)

plt.show()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

我尝试使用以下已知适用于其他seaborn地块的方法,但在jointplot上失败了:

plt.legend([],[], frameon=False)
g._legend.remove()
Run Code Online (Sandbox Code Playgroud)

python legend seaborn jointplot jointgrid

5
推荐指数
1
解决办法
2000
查看次数

Seaborn jointplot 带有相关性注释

在最新的seaborn版本发布之前,我能够使用以下内容用pearson Rho来注释我的情节。

使用最新版本,我无法找到一种方法来执行与#ax.annotate(stats.pearsonr)抛出错误相同的操作。

import matplotlib as mpl
import scipy.stats as stat
import matplotlib.pyplot as plt
import pandas as pd, numpy as np
import scipy.stats as stats
import seaborn as sns

X = np.random.rand(10,2)

df = pd.DataFrame(X, columns=['v1', 'v2'])

a = df.v1.values
b = a*2 + a**5

print("The Rho is {}".format(np.corrcoef(a,b)[0][1]))

ax = sns.jointplot(a, b, kind='reg',color='royalblue')
#ax.annotate(stats.pearsonr)
ax.ax_joint.scatter(a,b)
ax.set_axis_labels(xlabel='a', ylabel='b', size=15)
plt.tight_layout()
plt.show()
Run Code Online (Sandbox Code Playgroud)

我无法再得到的旧输出:

在此输入图像描述

python matplotlib seaborn jointplot

3
推荐指数
1
解决办法
5781
查看次数

如何使用不平衡的分类数据缩放seaborn联合图的边际kdeplot

如何缩放seaborn联合图的边际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 …
Run Code Online (Sandbox Code Playgroud)

scaling matplotlib kernel-density seaborn jointplot

2
推荐指数
1
解决办法
1108
查看次数

seaborn jointplot 边距不适用于对数轴

我试图通过以下方式绘制:

g = sns.jointplot(x = etas, y = vs, marginal_kws=dict(bins=100), space = 0)
g.ax_joint.set_xscale('log')
g.ax_joint.set_yscale('log')
g.ax_joint.set_xlim(0.01)
g.ax_joint.set_ylim(0.01)
g.ax_joint.set_xlabel(r'$\eta$')
g.ax_joint.set_ylabel("V")

plt.savefig("simple_scatter_plot_Seanborn.png",figsize=(8,8), dpi=150)
Run Code Online (Sandbox Code Playgroud)

这给我留下了以下图像:

阴谋

这不是我想要的。为什么最后要填充直方图?那里没有数据点,所以我不明白......

python matplotlib seaborn jointplot

1
推荐指数
1
解决办法
602
查看次数