2016-05-25 4 views
1

ax.tick_paramsを使用して目盛りが 'オフ'に設定されているかどうかを確認できます。 axオブジェクトを調べて、それらがオフになっているかどうかを調べる方法はありますか?反復するためにmatplotlib `ax`オブジェクトからダンプパラメータを抽出する

import matplotlib.pyplot as plt 

fig, ax = plt.subplots() 

ax.spines['top'].set_visible(False) 
ax.spines['bottom'].set_visible(False) 
ax.spines['left'].set_visible(False) 
ax.spines['right'].set_visible(False) 


ax.tick_params(
    axis='both', 
    which='both',  

    bottom='off',  
    top='off',   
    left='off', 
    right='off') 

# This is essentially what I want to be able to do 
assert ax.xticks == 'off' 

答えて

1

は、すべての軸の目盛り、あなたは以上移動するには、このコード

print "Major ticks of y axis"            
for tick in ax.yaxis.get_major_ticks(): 
    print tick.tick1On, tick.tick2On, tick.gridOn           
print "Minor ticks of y axis" 
for tick in ax.yaxis.get_minor_ticks(): 
    print tick.tick1On, tick.tick2On, tick.gridOn 

を使用することは、単に

によって

ax.yaxis.get_major_ticks() 

を置き換え、x軸、FEのためのダニ

ax.xaxis.get_major_ticks() 

一般公開ここで読み取られたTickオブジェクトの属性:http://matplotlib.org/api/axis_api.html#matplotlib.axis.Tick

関連する問題