2011-07-06 5 views
11

matplotlib에 서페이스 플롯을 만들려고하지만 z 축의 서식을 좋게 만들 수 없습니다. 나는 그것이 과학 표기법에 있기를 원한다. 축 위의 접두어와 축 위의 지수 (보통 matlab에서 얻는 것과 같다). 지금 나는 과학 표기법 (앞에 쉼표와 5 개의 0이 붙어 있음)이없는 값만 얻을 수 있습니다. 그렇지 않으면 접두어를 얻지 만 지수는 얻지 못합니다.mplot3d에서 z 축 서식 지정

시도해보십시오. (과학적 표기법 만 제공하지만 지수)

from matplotlib import ticker 

ax = fig.gca(projection='3d') 
ax.plot_surface(X, Y, Z, rstride=3, cstride=3) 
formatter = ticker.ScalarFormatter() 
formatter.set_scientific(True) 
formatter.set_powerlimits((-2,2)) 
ax.w_zaxis.set_major_formatter(formatter) 

시도 2 ​​: (내가 잘못 여기서 뭐하는 거지 기본 출력과 동일 소수점 형태의 값)

from matplotlib import ticker 

ax = fig.gca(projection='3d') 
ax.plot_surface(X, Y, Z, rstride=3, cstride=3) 
ax.ticklabel_format(axis="z", style="sci", scilimits=(0,0)) 

을 준다?

+1

당신이 사용하기 matplotlib의 버전? 1.0.1까지 수정되지 않은 버그가 발생할 수 있습니다. http://old.nabble.com/Displaying-offsets-in-3d-plots-td30474615.html –

+1

@Stephen Terry : 나는 1.0.1을 달리고있다. '파이썬 ​​2.7.1 | EPD 7.0-2 (32 비트) | (r271 : 86832, 2010 년 12 월 3 일, 15:41:32) darwin의 [GCC 4.0.1 (Apple Inc. build 5488)] >>> import matplotlib >>> matplotlib .__ version__ '1.0.1' ' – Magnus

답변

3

당신이 당신의 ScalarFormatter, 시도 "를 사용하여 수학 텍스트"매개 변수를 만들 때 :

from matplotlib import ticker 
niceMathTextForm = ticker.ScalarFormatter(useMathText=True) 
ax.w_zaxis.set_major_formatter(niceMathTextForm) 
+1

useOffset = false도 과학 표기법에 적합합니다. – denfromufa