복붙노트

[PYTHON] '로그'와 'symlog'의 차이점은 무엇입니까?

PYTHON

'로그'와 'symlog'의 차이점은 무엇입니까?

matplotlib에서 pyplot.xscale () 또는 Axes.set_xscale ()을 사용하여 축 크기를 설정할 수 있습니다. 두 함수 모두 세 가지 다른 스케일을 허용합니다. 'linear'| '로그'| 'symlog'.

'로그'와 'symlog'의 차이점은 무엇입니까? 내가했던 간단한 테스트에서, 그들은 똑같이 보였다.

설명서에 다른 매개 변수를 허용한다고 나와있는 문서는 알고 있지만 여전히 그 차이점을 이해하지 못합니다. 누군가 설명해 주시겠습니까? 샘플 코드와 그래픽이 있으면 대답이 가장 좋습니다! (또한 : 'symlog'라는 이름은 어디서 왔습니까?)

해결법

  1. ==============================

    1.나는 마침내 그들 사이의 차이점을 이해하기 위해 약간의 실험을 할 시간을 얻었다. 여기에 내가 발견 한 것이있다.

    나는 마침내 그들 사이의 차이점을 이해하기 위해 약간의 실험을 할 시간을 얻었다. 여기에 내가 발견 한 것이있다.

    그래픽과 예제를 통해 모든 것을 이해하는 것이 훨씬 쉬워 질 것이라고 생각합니다.

    import numpy
    from matplotlib import pyplot
    
    # Enable interactive mode
    pyplot.ion()
    
    # Draw the grid lines
    pyplot.grid(True)
    
    # Numbers from -50 to 50, with 0.1 as step
    xdomain = numpy.arange(-50,50, 0.1)
    
    # Plots a simple linear function 'f(x) = x'
    pyplot.plot(xdomain, xdomain)
    # Plots 'sin(x)'
    pyplot.plot(xdomain, numpy.sin(xdomain))
    
    # 'linear' is the default mode, so this next line is redundant:
    pyplot.xscale('linear')
    

    # How to treat negative values?
    # 'mask' will treat negative values as invalid
    # 'mask' is the default, so the next two lines are equivalent
    pyplot.xscale('log')
    pyplot.xscale('log', nonposx='mask')
    

    # 'clip' will map all negative values a very small positive one
    pyplot.xscale('log', nonposx='clip')
    

    # 'symlog' scaling, however, handles negative values nicely
    pyplot.xscale('symlog')
    

    # And you can even set a linear range around zero
    pyplot.xscale('symlog', linthreshx=20)
    

    완전성을 위해 다음 그림을 사용하여 각 그림을 저장했습니다.

    # Default dpi is 80
    pyplot.savefig('matplotlib_xscale_linear.png', dpi=50, bbox_inches='tight')
    

    다음을 사용하여 그림 크기를 변경할 수 있음을 기억하십시오.

    fig = pyplot.gcf()
    fig.set_size_inches([4., 3.])
    # Default size: [8., 6.]
    

    (내 자신의 질문에 답하는 것에 대해 확신이 없으면 이것을 읽으십시오)

  2. ==============================

    2.symlog는 로그와 비슷하지만 음모가 0에 가까울 때 범위가 무한대가되는 것을 피하기 위해 음모가 선형 인 값 범위를 정의 할 수 있습니다.

    symlog는 로그와 비슷하지만 음모가 0에 가까울 때 범위가 무한대가되는 것을 피하기 위해 음모가 선형 인 값 범위를 정의 할 수 있습니다.

    http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xscale

    로그 그래프에서는 0 값을 가질 수 없으며, 0에 가까울수록 그래프 아래쪽에서 무한히 아래쪽으로 급격히 떨어질 것입니다 (무한히 아래로). "음의 무한대 접근"을 얻습니다.

    symlog는 로그 그래프가 필요한 상황에서 도움이되지만 때때로 값이 0 또는 0으로 내려갈 수도 있지만 그래도 의미있는 방식으로 그래프에 표시 할 수 있기를 원합니다. symlog가 필요하면 알 수 있습니다.

  3. from https://stackoverflow.com/questions/3305865/what-is-the-difference-between-log-and-symlog by cc-by-sa and MIT license