Pandas条形图与散点图

(1)柱状图的绘画

import matplotlib.pyplot as plt

import pandas as pd 

from numpy import arange

review = pd.read_csv(r"...文件地址..")

cols = ["FILM", "RT_user_norm", "Metacritic_user_nom", "IMDB_norm", "Fandango_Ratingvalue", "Fandango_Stars"]

num_cols = ["RT_user_norm", "Metacritic_user_nom", "IMDB_norm", "Fandango_Ratingvalue", "Fandango_Stars"]

norm_reviews = reviews[cols]

bar_height = norm_review.ix[0, num_cols].values               #[4.3 3.55 3.9 4.5 5. ],为x轴柱状图数值的大小

bar_position = arange(5) + 0.75                                          #[0.75 1.75 2.75 3.75 4.75], 为x轴柱状图,距离原点的距离

fig,  ax = plt.subplots()                                                        #画出方框

ax.bar(bar_height, bar_position, 0.3)                                 #在方框内画图,0.3为柱子的宽度

plt.show()

结果为:

猜你喜欢

转载自blog.csdn.net/qq_39112101/article/details/85050364