2012-09-12 6 views
0

"로그"눈금을 켜면 x 축의 숫자가 사라집니다. 내가 xscale을 주석 경우로그 눈금 플롯에 x 축 번호가 인쇄되지 않음

import numpy as np 
import matplotlib.pyplot as plt 

plt.plot(range(1,10) , range(1,10) , color='#aaaaff') 
plt.xscale('log') 
plt.xticks(range(1,10)) 
plt.show() 

은 x 축에 번호가 인쇄되어 있습니다. 누군가가 축의 축이 log 일 때 왜 작동하지 않는지를 밝힐 수 있습니까?

편집 :

간체 코드는 데이터 파일없이 사용할 수 있도록. 같은 것 : 번호 없음 !! 로그 축에 대한 기본 눈금 위치하여

답변

2

xticks

plt.xticks([1,10]) 

에 당신이에 틱을 얻을 변경하는 경우 그래서 위의 경우에 유일하게 가능한 xtick 1.

에있다베이스 (10)에 110.

많은 것들을 할 수있는 ticker으로 재생할 수도 있습니다. 예를 들어,

import numpy as np 
import matplotlib.pyplot as plt 
from matplotlib.ticker import LogLocator 

fig = plt.figure(1, [5,4]) 
ax = fig.add_subplot(111) 

ax.plot(range(1,100) , range(1,100) , color='#aaaaff') 
ax.set_xscale('log') 
# This is default, so play with it 
ax.xaxis.set_major_locator(LogLocator(base = 10.0)) 
plt.show() 

당신이 사용하는 경우

enter image description here :

ax.xaxis.set_major_locator(LogLocator(base = 100.0)) 

는 당신은 큰

enter image description here

+0

확인을 얻을! 자, 진드기 (및 숫자)를 2,4,8,16으로 어떻게 설정할 수 있습니까? 'ax.xaxis'에는'xticks'가 없기 때문에 묻습니다. – ritter

+0

'ax.set_xscale ('log', basex = 2)'를 사용하십시오. – imsc