2017-03-09 10 views
0

私は、これらの測定値に関連した様々な測定値と深度を持つデータを持っています。私は陰影付きの誤差範囲をy軸として、深さをx軸としてデータをプロットすることができます。しかし、エラー境界があるデータはx軸に、深度はyにします。 tsplotにデータパラメータをx軸として、深さをyとして、または軸を反転するように指示する方法はありますか?基本的に私はそれはあなたが単にmatplotlibの中に配列を転置場合と同じように、すべての適切な軸をフォーマットすると、このseaborn tsplot plotで軸を反転する方法は?

enter image description here

にこの

enter image description here

をオンにしたいです。

+0

うん、申し訳ありませんが、 'tsplot'は「時間」ディメンションは(あなたのプロットを見ているほとんどの人が期待して何になるだろう)x軸に行くことが必要です。 – mwaskom

答えて

1

tsplotは、水平軸の時間を必要とします。したがって、それを転置するのは簡単ではありません。しかし、水平プロットからそれぞれのデータを取得し、それを使って同じデータから垂直プロットを生成することができます。

enter image description here

import numpy as np; np.random.seed(22) 
import seaborn as sns 
import matplotlib.pyplot as plt 

X = np.linspace(0, 15, 31) 
data = np.sin(X) + np.random.rand(10, 31) + np.random.randn(10, 1) 

plt.figure(figsize=(4,6)) 
ax = sns.tsplot(time=X, data=data) 
#get the line and the shape from the tsplot 
x,y =ax.lines[0].get_data() 
c = ax.collections[0].get_paths()[0].vertices 
# discart the tsplot 
ax.clear() 

# create new plot on the axes, inverting x and y 
ax.fill_between(c[:,1], c[:,0], alpha=0.5) 
ax.plot(y,x) 

plt.show() 
関連する問題