2016-12-16 11 views
0
私はコンポーネントコンポーネントに加えて残留(CCPR)プロットを行うにはmatplotlibのを使用しています

(=部分残留プロット)上のドットの非アライメントmatplotlibの:プロット

このスクリプト:

fig, ax = plt.subplots(figsize=(5, 5)) 
fig = sm.graphics.plot_ccpr(lm_full, 'diag[T.sz]', ax=ax) 
plt.close 

与える:

Bad Plot

どのように私は

のようなものを得るために、私のスクリプトを変更することができます

Good plot

ドットを整列させたくありません。どちらの場合も、x軸の変数はダミー変数です(健全なコントロールと健全なコントロール)。

これは馬鹿に見えるかもしれませんが、私は自分が望むものを表現する方法も知らないので、画像がはるかに簡単です。

答えて

1

あなたはこのように、xの値にいくつかのジッタを追加したいようですね:

import numpy as np 

# get x and y coordinates from the axes 
coords = ax.collections[0].get_offsets() 

# add small random number to each x coordinate 
coords[:,0] = coords[:,0] + np.random.rand(coords.shape[0]) * 0.01 

# move the points to the new coordinates 
ax.collections[0].set_offsets(coords) 
+0

感謝!私は申し訳ありませんが、私は自分のコードでそれを実装する方法を理解していません... – salim

+0

'fig = sm.graphics.plot_ccpr(lm_full、 'diag [T.sz]'、ax = ax)' – Michael

+0

しようとしましたが、ax.collections [0]は "list index of range"を返します – salim

関連する問題