2016-05-01 102 views
1
import matplotlib.pyplot as plt 
import education 
list_of_record = education.get_all_states() 
virginia_education = education.get_state('Virginia') 

attendance = virginia_education["attendance"] 

if "attendance" in virginia_education: 
    student_rate = attendance ["average student rate"] 
    teacher_rate = attendance ["average teacher rate"] 

rates = [student_rate, teacher_rate] 

x = rates 

plt.bar (1,student_rate) 
plt.bar (2,teacher_rate) 
plt.title ('Average Student Rate Attendence vs. Average Teacher Rate Attendence in Virginia') 
plt.show() 

Current graph條形圖:固定可視化

我想x軸只被標記爲「學生價」和「老師率」。我知道如何標記x軸,但我不知道如何改變1,1.2,1.2等

plt.bar (1,student_rate) 
plt.bar (2,teacher_rate) 

我怎麼改解決這一問題?

+0

http://matplotlib.org/examples /api/barchart_demo.html對你來說可能是一個很好的參考。 – tacaswell

回答