2012-06-18 3 views
1

여기 내 코드를 찾았습니다. 기본적으로 파이썬은 기본적으로 4,6,8 같은 x-ticks 레이블을 가진 플롯을 반환합니다 ... 그리고 원하는 것은 4,5,6,7,8과 같은 것입니다. .. 어떤 도움이라도? 매우 감사합니다!!파이썬을 사용하여 x 축 또는 y 축 레이블 사이에 틱을 더 추가하려면 어떻게해야합니까?

from mpl_toolkits.axes_grid.parasite_axes import SubplotHost 
import numpy as np 
import matplotlib.pyplot as plt 

fig = plt.figure(1) 
host = SubplotHost(fig, 111) 
fig.add_subplot(host) 

c13=[1.79, 2.15, 3.81, 6.12, 8.28, 7.93, 8.07, 8.88] 
c13014=[3.12, 3.28, 4.57, 7.24, 8.37, 9.26, 8.24, 8.25] 
C13dflow=[0., 0., 0., 0., 8.06, 8.13] 
d20=[5, 7, 8, 9, 10, 11, 12, 13] 
d20low=[5, 7, 8, 10, 11, 13] 

host.plot(d20, c13, 'ro') 
host.plot(d20, c13, 'r-', label='f1=0.01 (0.09 in TDU)') 
host.plot(d20, c13014, 'bo') 
host.plot(d20, c13014, 'b--', label='f1=0.014 (0.126 in TDU)') 
host.plot(d20low, C13dflow, 'go') 
host.plot(d20low, C13dflow, 'g-.', label='f1=0.01 (0.01 in TDU)') 
host.axis([4., 14., 0., 10.]) 

legend(loc=2) 
plt.ylabel('$^{13}C$ pocket mass [$10^{-5}$ $M_{\odot}$]', fontsize=27) 
plt.xlabel('Log(D20) [$cm^{2}$/s]', fontsize=27) 
plt.title('Max $^{13}C$ pocket masses using double-f overshooting ', fontsize=27) 
size=20 
plt.xticks(size=size) 
plt.yticks(size=size) 
host.toggle_axisline(False) 
host.grid(True) 
+0

질문에 스크립트의 그래픽 출력을 포함시키는 것이 좋습니다. – xApple

답변

3
In [1]: import matplotlib.pyplot as plt 

In [2]: plt.xticks? 
Type:  function 
Base Class: <type 'function'> 
String Form:<function xticks at 0x2c1e050> 
Namespace: Interactive 
File:  /usr/lib/pymodules/python2.7/matplotlib/pyplot.py 
Definition: plt.xticks(*args, **kwargs) 
Docstring: 
Set/Get the xlimits of the current ticklocs and labels:: 

    # return locs, labels where locs is an array of tick locations and 
    # labels is an array of tick labels. 
    locs, labels = xticks() 

    # set the locations of the xticks 
    xticks(arange(6)) 

    # set the locations and labels of the xticks 
    xticks(arange(5), ('Tom', 'Dick', 'Harry', 'Sally', 'Sue')) 

The keyword args, if any, are :class:`~matplotlib.text.Text` 
properties. For example, to rotate long labels:: 

    xticks(arange(12), calendar.month_name[1:13], rotation=17) 

이것은 당신이 plt.xticks(range(round(d20[-1])+2), size=size) 같은 것을 시도해야합니다 제안합니다.

+0

대단히 감사합니다! 그것은 매우 유용한 힌트였습니다. 결국 xticks = np.arange (4,14,1) // plt.xticks (xticks) // plt.xticks (size = size) –

+0

당신이 원하는 범위를 정확히 알고있는 한 @Umberto. 나는 단지 그것이 사실이 아닐 때해야 할 일에 대한 아이디어를주고 싶었습니다. 어쨌든 도와 줘서 기쁩니다. 문제가 해결되었다고 생각되면 [대답 수락] (http://meta.stackexchange.com/a/5235/181223)을 고려하십시오. –