1430-王同学

# 01绘制散点图

from matplotlib import pyplot as plt
from matplotlib import font_manager
y_3 = [11,17,16,11,12,11,12,6,6,7,8,9,12,15,14,17,18,21,16,17,20,14,15,15,15,19,21,22,22,22,23]
y_10 = [26,26,28,19,21,17,16,19,18,20,20,19,22,23,17,20,21,20,22,15,11,15,5,13,17,10,11,13,12,13,6]
x_3 = range(1,32)
x_10 = range(51,82)
plt.figure(figsize=(20,8),dpi=80)#图形大小
#使用scatter方法绘制散点图
plt.scatter(x_3,y_3,label="3 month")
plt.scatter(x_10,y_10,label="10 month")
_x = list(x_3)+list(x_10)
_xtick_labels = ["3m{}d".format(i) for i in x_3]
_xtick_labels += ["10m{}d".format(i) for i in x_10]
plt.xticks(_x[::3],_xtick_labels[::3],rotation=45) #调整x轴的刻度
#描述信息
plt.xlabel("time")
plt.ylabel("tempt")
plt.title("time-tempt")
#图例
plt.legend(loc = "upper left")
plt.show()

#绘制横着的条形图
from matplotlib import pyplot as plt
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="C:/Windows/Fonts/msyh.ttc")

a = ["战狼2","速度与激情8","功夫瑜伽","西游伏妖篇","变形金刚5：最后的骑士","摔跤吧！爸爸","加勒比海盗5：死无对证","金刚：骷髅岛","极限特工：终极回归","生化危机6：终章","乘风破浪","神偷奶爸3","智取威虎山","大闹天竺","金刚狼3：殊死一战","蜘蛛侠：英雄归来","悟空传","银河护卫队2","情圣","新木乃伊",]

b=[56.01,26.94,17.53,16.49,15.45,12.96,11.8,11.61,11.28,11.12,10.49,10.3,8.75,7.55,7.32,6.99,6.88,6.86,6.58,6.23]

#设置图形大小
plt.figure(figsize=(20,8),dpi=80)

#条形图
plt.barh(range(len(a)),b,height=0.3,color="orange")

#横坐标
plt.yticks(range(len(a)),a,fontproperties=my_font)

plt.grid(alpha=0.3)

plt.show()

from matplotlib import pyplot as plt
from matplotlib import font_manager
my_font = font_manager.FontProperties(fname="C:/Windows/Fonts/msyh.ttc")

a = ["猩球崛起","敦刻尔克","蜘蛛侠","战狼2"]
b_16 = [15746,312,4497,319]
b_15 = [12357,156,2045,168]
b_14 = [2358,399,2358,362]

bar_width = 0.2

x_14 = list(range(len(a)))
x_15 = [i+bar_width for i in x_14]
x_16 = [i+bar_width*2 for i in x_14]
#设置图形大小
plt.figure(figsize=(20,8),dpi=80)

#条形图
plt.bar(range(len(a)),b_14,width=bar_width,label="9.14")
plt.bar(x_15,b_15,width=bar_width,label="9.15")
plt.bar(x_16,b_16,width=bar_width,label="9.16")
plt.xticks(x_15,a,fontproperties=my_font)

#图例
plt.legend(prop=my_font)
plt.show()

from matplotlib import pyplot as plt
from matplotlib import font_manager

interval = [0,5,10,15,20,25,30,35,40,45,60,90]
width = [5,5,5,5,5,5,5,5,5,15,30,60]
quantity = [836,2737,3723,3926,3596,1438,3273,642,824,613,215,47]

plt.figure(figsize=(20,8),dpi=80)
plt.bar(range(len(quantity)),quantity,width=1)

_x = [i-0.5 for i in range(13)]
_xtick_labels = interval+[150]
plt.xticks(_x,_xtick_labels)

plt.grid(alpha=0.4)
plt.show()


ECHARTS
plotly

Vieu3.3主题

Q Q 登 录