PlotFigure ()를 정의 하는 다음 파이썬 모듈 ' plot_figure.py '를 고려하십시오 . 의사 코드입니다.
import matplotlib.pyplot as plt
def PlotFigure(x)
# Some other routines..
plt.plot(x)
# Some other routines..
plot_figure.PlotFigure를 호출하고 싶지만 그림을 플로팅 한 후이 그림의 선 너비를 변경하고 싶습니다. PlotFigure ()에 다른 루틴이 포함될 수 있지만 그림의 선은 위의 의사 코드에서와 같이 plt.plot ()을 사용하여 플로팅됩니다.
다음은 plot_figure.PlotFigure ()를 호출하는 코드입니다.
#!/usr/bin/python
import matplotlib.pyplot as plt
import plot_figure
x_data = [ # some data ]
plot_figure.PlotFigure(x_data)
#***I would like to change the line width of the figure here***
plt.show()
을 사용하여 그림 핸들을 얻을 수 있다는 것을 알고 fig = plt.gcf()
있지만 plt.setp(fig, linewidth=2)
작동하지 않습니다.
누구든지 이것에 대한 제안을 할 수 있습니까?
먼저 선폭 (또는 다른 플롯 매개 변수)을 설정하는 일반적인 방법은 플롯 명령에 대한 인수로 제공하는 것입니다.
import matplotlib.pyplot as plt
def PlotFigure(x, **kwargs):
# Some other routines..
plt.plot(x, linewidth=kwargs.get("linewidth", 1.5) )
# Some other routines..
그리고 전화
plot_figure.PlotFigure(x_data, linewidth=3.)
이것이 정말로 선택 사항이 아니라면 그림에서 선을 가져와야합니다.
가장 쉬운 경우는 축이 하나 뿐인 경우입니다.
for line in plt.gca().lines:
line.set_linewidth(3.)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다