Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
439 views
in Technique[技术] by (71.8m points)

pandas - Smoothing out the plot colors (making the colors blend)

I made a plot that looks like so:

enter image description here

Here is the code:

sn.kdeplot(data = pca_dataAPO, x = 'PC_1', y = 'PC_2', shade = True, cmap='viridis_r', bw_method = 'scott')

So basically, I can not seem to figure out how to smoothen the colors in the first plot, by making them ombre, like basically blending them.

I tried doing it like so:

# Evaluate a gaussian kde on a regular grid of nbins x nbins over data extents
#nbins=300
k = gaussian_kde([pc_1,pc_2], 'scott')
xi, yi = np.mgrid[pc_1.min():pc_1.max(), pc_2.min():pc_2.max()]
zi = k(np.vstack([xi.flatten(), yi.flatten()]))
 
# Make the plot
plt.pcolormesh(xi, yi, zi.reshape(xi.shape), shading='gouraud', cmap='viridis_r')
plt.grid(linewidth=0.1)
plt.show()

But it gives me this yellow background and I can not find a workaround how to make the background white.

enter image description here

Thank you for the help in advance!

question from:https://stackoverflow.com/questions/65889837/smoothing-out-the-plot-colors-making-the-colors-blend

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...