![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/4271468fafe741cbd57c1e678c04c6c3.png)
from matplotlib import pyplot as plt
from matplotlib.font_manager import FontProperties
font = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=10)
x = [60,80,40,30,70,90,95]
y = [100,50,120,135,65,45,40]
plt.scatter(x,y,marker='*',color='purple')
x_t = range(0,int(max(x)+10))[::10]
x_l = ['{}元'.format(i) for i in x_t]
plt.xticks(x_t,x_l,fontproperties=font)
plt.xlabel('价格',fontproperties=font)
y_t = range(0,int(max(y)+10))[::10]
y_l = [i for i in y_t]
plt.yticks(y_t,y_l)
plt.ylabel('需求量',fontproperties=font)
aa = []
for a,b in zip(x,y):
plt.text(a,b-6,s=(a,b),ha='center',va='bottom',fontsize=8)
aa.append(a*b)
plt.legend(['价格供需变化'],prop=font)
plt.title('价格供需变化图',fontproperties=font,color='red',fontsize=12)
for i in range(7):
if x[i]*y[i] == max(z):
print('商家应当选择价格为{}需求量为{}的产品。'.format(x[i],y[i]))
plt.show()
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/09672e9d10b56331025f550696f72c57.png)
from matplotlib import pyplot as plt
font = {
‘family’:‘SimHei’,
‘weight’:‘bold’,
‘size’:10
}
movies_name = ["变身特工","美丽人生","鲨海逃生","熊出没·狂野大陆"]
day_12 = [2358,399,2358,362]
day_13 = [12357,156,2045,168]
day_14 = [15746,312,4497,319]
width=0.3
d1 = [i - width for i in range(len(day_12))]
d2 = range(len(day_13))
d3 = [i + width for i in range(len(day_14))]
plt.bar(d1,day_12,width=width,align='center',orientation='vertical',color='r')
plt.bar(d2,day_13,width=width,align='center',orientation='vertical',color='g')
plt.bar(d3,day_14,width=width,align='center',orientation='vertical',color='b')
plt.xticks(range(len(day_12)),movies_name,fontproperties=font)
plt.xlabel('电影名称',fontproperties=font,fontsize=12)
plt.ylabel('票房',fontproperties=font,fontsize=12)
def bar0(d_num,day_num):
for a,b in zip(d_num,day_num):
plt.text(a,b+5,s=b,ha='center',va='bottom',fontsize=8)
bar0(d1,day_12)
bar0(d2,day_13)
bar0(d3,day_14)
plt.legend(['12日票房','13日票房','14日票房'],prop=font)
plt.title('电影票房对比表',fontproperties=font,fontsize=15,fontweight='bold',backgroundcolor='gold',alpha=0.8)
plt.show()