简体   繁体   中英

Adding horizontal and vertical lines and colorbar to seaborn jointplot

I would like to use kernel density estimate of seaborn .

First I would like to add a colorbor for the main plot.

Second I would like to add horizontal line to the joint probability distribution to show the 68%, 98% confidence levels and another line which shows the true value

Third I also would like to remove the legend in the plot, considering the following example:

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

sns.set_context("paper")
# 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, color="r")

How should I do it?

  1. Not easily possible (although the density values are not particularly interpretable anyway).

  2. These are matplotlib objects, you can add any additional plot elements you want to them.

  3. stat_func=None , as is shown here .

AFAIK you can't do any of those per doc .

  1. I would like to add a colorbor for the main plot.

That's no an option with jointplot . Colorbars are only available with heatmap , clustermap , and interactplot

  1. I would like to add horizontal line to the joint probability distribution to show the 68%, 98% confidence levels and another line which shows the true value

Not an option as well, the closest you can come to that is overlay two graphs

  1. I also would like to remove the legend in the plot

I'm assuming you're talking about the pearsonr and p values. Those aren't legends and no documentation to show a way to remove them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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