Matplotlib에서 X축 공백을 제거하는 방법
Matplotlib을 사용하여 플롯을 생성할 때 X축 사이에 공백이 있는 것이 일반적입니다. 데이터와 축의 가장자리. 이 기본 여백은 데이터가 축 척추 내에 잘 맞도록 보장합니다. 그러나 특정 시각화의 경우 이 공백을 제거하는 것이 바람직할 수 있습니다.
plt.margins() 사용
여백을 조정하는 한 가지 방법은 plt.margins를 사용하는 것입니다. (x=0). 이 방법은 x축의 여백을 0으로 설정하여 공백을 효과적으로 제거합니다. 마찬가지로, ax.margins(x=0)을 사용할 수 있습니다. 여기서 ax는 축 객체입니다.
전역적으로 여백 설정
전체 스크립트의 경우 코드 시작 부분에 plt.rcParams['axes.xmargin'] = 0을 사용할 수 있습니다. 이는 모든 후속 플롯에 대한 기본 여백을 설정합니다.
X축 제한 수동 설정
또는 plt를 사용하여 x축 제한을 수동으로 설정할 수 있습니다. xlim(..) 또는 ax.set_xlim(..). 예를 들어, 데이터가 특정 날짜 범위에 해당하는 경우 적절한 날짜에 시작하고 끝나도록 제한을 설정하여 빈 공간을 없앨 수 있습니다.
예
아래 Python 예제에서는 plt.margins()를 사용하여 x축에서 공백을 제거하는 방법을 보여줍니다.
import matplotlib.pyplot as plt # Plot some data plt.plot([1, 2, 3]) # Remove white space on x-axis plt.margins(x=0) plt.show()
이렇게 하면 x축에 공백이 없는 플롯이 생성됩니다. 플롯 가장자리까지 데이터를 확장합니다.
위 내용은 Matplotlib의 X축에서 공백을 제거하는 방법은 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

Pythonusesahybridmodelofilationandlostretation : 1) ThePyThoninterPretreCeterCompileSsourcodeIntOplatform-IndependentBecode.

Pythonisbothingretedandcompiled.1) 1) it 'scompiledtobytecodeforportabilityacrossplatforms.2) thebytecodeisthentenningreted, withfordiNamictyTeNgreted, WhithItmayBowerShiledlanguges.

forloopsareusedwhendumberofitessiskNowninadvance, whilewhiloopsareusedwhentheationsdepernationsorarrays.2) whiloopsureatableforscenarioScontiLaspecOndCond

pythonisnotpurelynlogreted; itusesahybrideprophorfbyodecodecompilationandruntime -INGRETATION.1) pythoncompilessourcecodeintobytecode, thepythonVirtualMachine (pvm)

ToconcatenatelistsinpythonwithesameElements, 사용 : 1) OperatorTokeEpduplicates, 2) asettoremovedUplicates, or3) listComperensionForControlOverDuplicates, 각 methodHasDifferentPerferformanCeanDorderImpestications.

PythonisancerpretedLanguage, 비판적 요소를 제시하는 PytherfaceLockelimitationsIncriticalApplications.1) 해석 된 언어와 같은 thePeedBackandbackandrapidProtoTyping.2) CompilledlanguagesLikec/C transformt 해석

useforloopswhhenmerfiterationsiskNownInAdvance 및 WhileLoopSweHeniTesslationsDepoyConditionismet whilEroopsSuitsCenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTheLoopScenarioswhereTherInatismet, 유용한 광고 인 푸트 gorit


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

메모장++7.3.1
사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

SublimeText3 Linux 새 버전
SublimeText3 Linux 최신 버전

WebStorm Mac 버전
유용한 JavaScript 개발 도구