pythonデータ可視化ライブラリ


import pandas as pd
unrate = pd.read_csv("UNRATE.csv")
unrate['DATE'] = pd.to_datetime(unrate['DATE'])  ##       1992/2/1     datetime  
#print(unrate.head(12))
import matplotlib.pyplot as plt
# first_twelve = unrate[0:12]
# plt.plot(first_twelve["DATE"],first_twelve["VALUE"])  ##plot    ,       ,      
# plt.xticks(rotation=45)  ##       45 
# plt.xlabel('Month')
# plt.ylabel('Unemployment Rate')
# plt.title(' 1948 shi ye lv')
# plt.show()  ##  
from Matplotlibobj.demo import unrate
fig = plt.figure(figsize=(10,6))
colors = ['red','blue','green','orange','black']
for i in range(5):
    start_index = i*12
    end_index =(i+1)*12
    subset =unrate[start_index:end_index]
    label = str(1948+i)
    plt.plot(subset['DATE'],subset['VALUE'],c=colors[i],label = label)###               ,label                  ,    legent      
#plt.legend(loc='best')  ###legend            。
plt.legend(loc='upper left')
plt.xlabel('Month, integer')
plt.ylabel('Unemplyment Rate,Percent')
plt.title('Monthly Unemployment Trends,1948-1952')
plt.show()

#####

matplotlib説明
import pandas as pd
from numpy import arange
import matplotlib.pyplot as plt
reviews = pd.read_csv('fandango_scores.csv')
num_cols = ['RT_user_norm','Metacritic_user_nom','IMDB_norm','Fandango_Ratingvalue','Fandango_Stars']
norm_reviews = reviews[num_cols]
#print(norm_reviews[:1])
##       ,       ,1.     ,2.        X    
bar_heights = norm_reviews.ix[0,num_cols].values  ##             
print(bar_heights)
# bar_positions = arange(5)+0.75   ###      ,     0   
# tick_positions = range(1,6)
# print(bar_positions)##       
# fig,ax = plt.subplots()  ##      ,ax   bar    
# ax.barh(bar_positions,bar_heights,0.8) ##0.8        bar       ,barh      
#####    
# ax.set_yticks(tick_positions)
# ax.set_yticklabels(num_cols)
# ax.set_ylabel('Rating Source')
# ax.set_xlabel('Average Rating')
# ax.set_title('Average user rating for avengers :Age of Utron(2015)')
# plt.show()
###    :     2  ,      ,    ,  ascatter           。
# fig,ax= plt.subplots()  ###  fig         ,ax         ,fig              
# ax.scatter(norm_reviews['Fandango_Ratingvalue'],norm_reviews['RT_user_norm'])  #  2   
# ax.set_xlabel('Fandango')  ##      
# ax.set_ylabel('Rotten Tomatoes')  ##       
# plt.show()
####      ,
####       ,                。
# fig, ax = plt.subplots()
# #ax.hist(norm_reviews['Fandango_Ratingvalue'])   ###.hist           bins  ,     binds           binds
# ax.hist(norm_reviews['Fandango_Ratingvalue'],bins=20)
# #ax.hist(norm_reviews['Fandango_Ratingvalue'],range = (4,5),bins=20)
# plt.show()

###  :        。   
# fig,ax = plt.subplots()
# ax.boxplot(norm_reviews['RT_user_norm'])  ##  ,
# ax.set_xticklabels(['Rotten Tomatoes'])  ##   x    
# ax.set_ylim(0,5)##   y 
# plt.show()
##    
fig,ax = plt.subplots()
ax.boxplot(norm_reviews[num_cols].values)
ax.tick_params(bottom="off",top="off",left="off",right="off")##           ,
ax.set_xticklabels(num_cols,rotation=90)
ax.set_ylim(0,5)
plt.show()
#####RGB      
cb_dark_blue = (0/255,107/255,164/255)  ## /255         
cb_orange = (255/255,128/255,14/255)
linewidth = 10   ##           
###                       。       。     ,    figsize  
fig = plt.figure(figsize=(12,12))