2017-04-17 1 views
0

x에 맞는 라벨을 얻을 수 없지만 올바른 값 대신 int를 사용합니다.pandas 피봇 테이블 lables가있는 Matplotlib

여기 내 코드입니다 : 당신이 명시 적으로 num, ax.set_xlabel(num)에 xlabel을 설정하기 때문에

def animate(num, f, a, canvas): 

    global index 

    data = pd.read_csv("train.csv") 
    table = pd.pivot_table(data=data, values=index, index=num, columns='Survived', aggfunc='count') 

    a.clear() 
    bar_1 = table[0] 
    # Array with the survivors, divided between male and female 
    bar_2 = table[1] 
    # Range com a quantidade de itens das barras 
    x_pos = np.arange(len(bar_1)) 

    a.set_xlabel(num) 
    a.set_ylabel("Survived") 

    a.bar(x_pos, bar_1, 0.5, color='b') 
    a.bar(x_pos, bar_2, 0.5, color='y', bottom=bar_1) 
    # Definir position and labels for the X axis 
    plt.xticks(x_pos+0.25, ('Female','Male')) 

    canvas.draw() 
    canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True) 
+0

문제가 불분명하고 재현 할 수 없습니다. [ask]와 [mcve]를 만드는 방법을 읽어보십시오. 그런 다음 질문을 편집하십시오. – ImportanceOfBeingErnest

답변

1

, 당신은 xlabel 같은 정수를 얻을. 다른 것을 xlabel로 원하면 ax.set_xlabel(something_else)을 호출하여 지정해야합니다.

관련 문제