简体   繁体   English

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

[英]Python Contour Plot with 1D slices on the side

I want to plot a contour map (using contourf ), but I also want to show on the sides a slice of the plot through particular points, such as the figure shown below. 我想绘制一个等高线图(使用contourf ),但是我还想通过特定的点在侧面显示该图的一部分,如下图所示。 在此处输入图片说明

The plot you show is produced via a seaborn jointplot . 您显示的图是通过海洋jointplot

This example shows how to produce the this kind of plot. 本示例说明了如何生成此类图。

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()

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM