打卡交作业啦#2022年01月11日

2022-01-11  本文已影响0人  八戒的小屋

这次主要学习的是matplotlib的框架,原来一张图表有这么多讲究,真是学习了。

### 第一回

# fig,ax= plt.subplots()

# ax.plot([1,2,3,4],[1,4,2,3])

# plt.show()

# line = plt.plot([1,2,3,4],[1,4,2,3])

# x = np.linspace(0,2,100)

# fig,ax = plt.subplots()

# ax.plot(x,x,label = 'linear')

# ax.plot(x,x**2,label='quadratic')

# ax.plot(x,x**3,label='cubic')

# ax.set_xlabel('x label')

# ax.set_ylabel('y label')

# ax.set_title('Simple Plot')

# ax.legend()

# plt.show()

# x = np.linspace(0,2,100)

# plt.plot(x,x,label = 'linear')

# plt.plot(x,x**2,label = 'quadratic')

# plt.plot(x,x**3,label = 'cubic')

# plt.xlabel('x label')

# plt.ylabel('y label')

# plt.title('Simple Plot')

# plt.legend()

# plt.show()

# ## 通用模板

# # step1 准备数据

# x = np.linspace(0,2,100)

# y = x**2

# # step2 设置绘图样式

# mpl.rc('lines',linewidth = 4,linestyle = '-.')

# # step3 定义布局

# fig,ax = plt.subplots()

# # step4 绘制图像

# ax.plot(x,y,label = 'linear')

# # step5 添加标签、文字和图例

# ax.set_xlabel('x label')

# ax.set_ylabel('y label')

# ax.set_title('Simple Plot')

# ax.legend();

## 思考题

# 1、请思考两种绘图模式的优缺点和各自适合的使用场景

# 2、在第五节绘图模板中我们是以OO模型作为例子展示的,请思考并写一个pyplot绘图模式的简单模板

# 1

# (1)显式创建适合需要创建多个图时,自动创建适合只有一张图时

# 2

# x = np.linspace(0,2,100)

# y = x**2

# plt.plot(x,y,label = 'linear')

# plt.xlabel('x label')

# plt.ylabel('y label')

# plt.title('自动创建')

# plt.legend()

# plt.show();

上一篇 下一篇

猜你喜欢

热点阅读