Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

control seaborn regplot confidence intervals translucency

Tags:

python-3.x

Anyone has a way to control the degree of translucency of the confidence intervals in seaborn regplot? It's been bugging me (especially for black background plots) for a while and I still could not find anything on that topic.

import pandas as pd
import seaborn as sns
data = pd.DataFrame(np.random.random((100,2)), columns=["x","y"])
sns.regplot('x', 'y', data=data)
like image 930
OP40 Avatar asked Feb 07 '18 20:02

OP40


1 Answers

You can set the alpha for the confidence interval band using matplotlib.pyplot.setp like:

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

data = pd.DataFrame(np.random.random((100,2)), columns=["x","y"])
ax = sns.regplot('x', 'y', data=data)
plt.setp(ax.collections[1], alpha=0.2)

Just for reference, If you want to look at elements of a seaborn plot you can use ax.get_children().

like image 169
Blazina Avatar answered Oct 03 '22 05:10

Blazina