2016-07-16 10 views
1

私はRamachandronプロットをプロットしたいと思います。この種のグラフでは、xは-180°から180°に、yは-180°になります。 60度ごとに目盛りが欲しい。ここに私が使用するコードはあります:軸は私が望むダンプを表示しません

import matplotlib.pyplot as plt 
from matplotlib.colors import LogNorm 

x = [-179, 179] 
y = [-179, 179] 

fig = plt.figure(1) 
ax = plt.subplot(111) 

ax.axis([-180, 180, -180, 180]) 

ax.set_xticks([-180, -120, -60, 0, 60, 120, 180]) 
ax.set_yticks([-180, -120, -60, 0, 60, 120, 180]) 


# 1 bim = 1 degree 
# !!! Logarithmic normalization of the colors 
plt.hist2d(x, y, bins=180, norm=LogNorm()) 
plt.colorbar() 
plt.show() 

この例では、私は2点だけをプロットしています。しかし、ダニ-180および180は、軸のいずれものために、示されていません。

enter image description here

を私はxとyを変更する場合:

x = [-180, 180] 
y = [-180, 180] 

私は私が欲しいものを得る:

enter image description here

データを変更せずに2番目の結果を達成する方法はありますか?あなたはhist2d使用

答えて

0

は、設定軸がプロット後ティック:

import matplotlib.pyplot as plt 
from matplotlib.colors import LogNorm 

x = [-179, 179] 
y = [-179, 179] 

fig = plt.figure(1) 
ax = plt.subplot(111) 

# 1 bim = 1 degree 
# !!! Logarithmic normalization of the colors 
plt.hist2d(x, y, bins=180, norm=LogNorm()) 
plt.colorbar() 

ax.axis([-180, 180, -180, 180]) 
ax.set_xticks([-180, -120, -60, 0, 60, 120, 180]) 
ax.set_yticks([-180, -120, -60, 0, 60, 120, 180]) 

plt.show() 

enter image description here

+0

好奇心。なぜhist2dでこのようにするのですか? (それは動作します、私はあなたの答えを受け入れるでしょう)。 – Rififi

関連する問題