侧面有一维切片的Python轮廓图

时间:2017-06-12 11:07:13

标签: python matplotlib

我想绘制一个等值线图(使用contourf),但我也希望在两侧显示特定点的切片,如下图所示。enter image description here < / p>

1 个答案:

答案 0 :(得分:0)

您显示的地图是通过seaborn jointplot生成的。

This example展示了如何制作这种情节。

import numpy as np
import pandas as pd
import seaborn as sns

# Generate a random correlated bivariate dataset
rs = np.random.RandomState(5)
mean = [0, 0]
cov = [(1, .5), (.5, 1)]
x1, x2 = rs.multivariate_normal(mean, cov, 500).T
x1 = pd.Series(x1, name="$X_1$")
x2 = pd.Series(x2, name="$X_2$")

# Show the joint distribution using kernel density estimation
g = sns.jointplot(x1, x2, kind="kde", size=7, space=0)

import matplotlib.pyplot as plt
plt.show()

enter image description here