2016-04-29 2 views
4
import matplotlib.pyplot as plt 
import education 
list_of_record = education.get_all_states 

virginia_education = education.get_state('Virginia') 
enrollment = virginia_education ["enrollment"] 
students = enrollment ["students"] 
race = students ["race"] 

asian = race["asian"] 
biracial = race["biracial"] 
hispanic = race ["hispanic"] 
white = race ["white"] 
black = race["black"] 
native_american = race["native american"] 

all_race = [asian, biracial, hispanic, white, black, native_american] 

plt.hist (all_race) 
plt.show() 

とヒストグラムや散布図をプロット現在のヒストグラムの画像:matplotlibの

Image of current histogram

私はそれがすべてのレースの名前を持っているので、それを変更したいです。 xとy軸上の数字が間違っていると私はそれ

を修正するかどうかはわからないデータの一部:

+0

実際のデータのサブセットを質問に含めることができればうれしいです。そうすれば、あなたを助けようとしている人々はすぐにあなたの事例を実行し、それを試して、その潜在的な解決策を検証することができます。 –

答えて

2

enter image description hereは、私はあなたの代わりに使用したいと思うには、棒グラフであります。ヒストグラムは、数値データの分布を調べるために使用されます。

import matplotlib.pyplot as plt 
import education 
list_of_record = education.get_all_states 

virginia_education = education.get_state('Virginia') 
enrollment = virginia_education["enrollment"] 
students = enrollment["students"] 
race = students["race"] 

x = range(len(race)) # x-axis list 
label = [] # x-labels list 
y = [] # y-values list 
for race, value in race.items(): 
    label.append(race) # add race to x-labels list 
    y.append(value) # add value to y-values list 

plt.bar(x,y,color='indianred',tick_label=label,align='center') 
plt.show()