2014-04-26 2 views
3

matplotlib에서 2 차원 막대 그래프를 그릴 때 로그 변환 계수를 얻는 간단한 방법이 있습니까? pyplot.hist 메서드와 달리 pyplot.hist2d 메서드에는 로그 매개 변수가없는 것 같습니다. 예상 히스토그램을 나타내는matplotlib : hist2d의 로그 변환 수

import numpy as np 
import matplotlib as mpl 
import matplotlib.pylab as plt 

matrix, *opt = np.histogram2d(x, y) 
img = plt.imshow(matrix, norm = mpl.colors.LogNorm(), cmap = mpl.cm.gray, 
       interpolation="None") 

을하지만 축 레이블은 쓰레기통의 인덱스 때문에하지 예상 값을 보여

현재 나는 다음과 같은 일을 해요.

답변

5

은 당황의 종류,하지만 내 질문에 대한 답은 해당 코드의 docstring에서 실제로 :

Notes 
----- 
    Rendering the histogram with a logarithmic color scale is 
    accomplished by passing a :class:`colors.LogNorm` instance to 
    the *norm* keyword argument. Likewise, power-law normalization 
    (similar in effect to gamma correction) can be accomplished with 
    :class:`colors.PowerNorm`. 

그래서이 작품 :

import matplotlib as mpl 
import matplotlib.pylab as plt 
par = plt.hist2d(x, y, norm=mpl.colors.LogNorm(), cmap=mpl.cm.gray) 
관련 문제