tag:crieit.net,2005:https://crieit.net/tags/ridgeline/feed
「ridgeline」の記事 - Crieit
Crieitでタグ「ridgeline」に投稿された最近の記事
2021-01-19T03:01:08+09:00
https://crieit.net/tags/ridgeline/feed
tag:crieit.net,2005:PublicArticle/16618
2021-01-19T02:56:21+09:00
2021-01-19T03:01:08+09:00
https://crieit.net/posts/Ridgeline-plot
Ridgeline plotの描き方
<p>複数の分布をグループorカテゴリ別に重ね合わせて表示する図(Ridgeline plots)の書き方.Joyplotとも言う?</p>
<pre><code class="python">from scipy.stats import gaussian_kde
import matplotlib.pyplot as plt
plt.figure(figsize=(4, 6), dpi=150)
def ridgeline(data,overlap=0.5,fill=True,labels=None,n_points=150):
xx=np.linspace(np.min(np.concatenate(data)),np.max(np.concatenate(data)),n_points)
curves=[]
ys=[]
for i,d in enumerate(data):
pdf=gaussian_kde(d)
y=i*(1.0-overlap)
curve=pdf(xx)
if fill:
plt.fill_between(xx,np.ones(n_points)*y,curve+y,zorder=len(data)-i+1,alpha=0.1,color=fill)
plt.plot(xx,curve+y,c='k',zorder=len(data)-i+1)
plt.xlim(-1,1)
#plt.ylim(10,50)
if labels:
plt.yticks(ys,labels)
data=(FFT[index,19+10:19+51]-GA[index,19+10:19+51]).T
print(np.shape(data))
ridgeline(data,overlap=0,fill='blue')
</code></pre>
<p><a href="https://crieit.now.sh/upload_images/22fcdf363a2232af73bed479cb4b582b6005cbbe7e255.png" target="_blank" rel="nofollow noopener"><img src="https://crieit.now.sh/upload_images/22fcdf363a2232af73bed479cb4b582b6005cbbe7e255.png?mw=700" alt="image" /></a></p>
kawai_mizugorou