단계별로 그래프를 편집 중입니다. 그러면 plt
기능이 matplotlib.pyplot
에서 그래픽 출력으로 바로 적용됩니다. 훌륭합니다.왜 pyplot 메서드가 즉시 적용되고 subplot 축 메서드는 적용되지 않습니까?
서브 플로트의 축을 주소 지정하면 더 이상 발생하지 않습니다. 최소한의 작업 예제에서 두 가지 대안을 찾아보십시오.
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
f = plt.figure()
sp1 = f.add_subplot(1,1,1)
f.show()
# This works well
sp1.set_xlim([1,5])
# Now I plot the graph
df = pd.Series([0,5,9,10,15])
df.hist(bins=50, color="red", alpha=0.5, normed=True, ax=sp1)
# ... and try to change the ticks of the x-axis
sp1.set_xticks(np.arange(1, 15, 1))
# Unfortunately, it does not result in an instant change
# because my plot has already been drawn.
# If I wanted to use the code above,
# I would have to execute him before drawing the graph.
# Therefore, I have to use this function:
plt.xticks(np.arange(1, 15, 1))
나는 matplotlib.pyplot
와 axis
예를 사이에 차이가 있음을 이해합니다. 나는 아무것도 못 찾았나요 아니면 그냥 이런 식으로 일하니?
'show'를 블로킹한다는 것을 기억하십시오. 그것은 ipython에서 차단되지 않습니다,하지만 내 설정에 의한 것 같아요. 그리고'f.show()'만 있으면 충분하다. 배경 정보는 –
+1이다. – Xiphias