【Python】matplotlib

安装

第三方库
终端输入“pip install matplotlib”命令后回车
在这里插入图片描述

可视化

import matplotlib.pyplot as plt  # 导入matplotlib的pyplot模块,别名
input_values = [1,2,3,4,5]
squares = [1,4,9,16,25]
fig, ax = plt.subplots()   # fig图形对象,ax轴对象
ax.plot(input_values,squares,linewidth=4)  # 调用ax周对象的plot方法,将squares数据传进去;linewidth是调整线条宽度

# 设置图形标题并给坐标轴加上标签
ax.set_title('Square_Numbers',fontsize=24)
ax.set_xlabel('Value',fontsize=14)
ax.set_ylabel('Square_of_Value',fontsize=14)
# 设置刻度标记的大小
ax.tick_params(labelsize=14)

plt.show()  #展示图表,可视化

在这里插入图片描述

打印图标样式

print(plt.style.available)
# ['Solarize_Light2', '_classic_test_patch', '_mpl-gallery', '_mpl-gallery-nogrid', 'bmh', 'classic', 'dark_background', 'fast', 'fivethirtyeight', 'ggplot', 'grayscale', 'seaborn-v0_8', 'seaborn-v0_8-bright', 'seaborn-v0_8-colorblind', 'seaborn-v0_8-dark', 'seaborn-v0_8-dark-palette', 'seaborn-v0_8-darkgrid', 'seaborn-v0_8-deep', 'seaborn-v0_8-muted', 'seaborn-v0_8-notebook', 'seaborn-v0_8-paper', 'seaborn-v0_8-pastel', 'seaborn-v0_8-poster', 'seaborn-v0_8-talk', 'seaborn-v0_8-ticks', 'seaborn-v0_8-white', 'seaborn-v0_8-whitegrid', 'tableau-colorblind10']

使用图标样式

plt.style.use('_mpl-gallery')   # 使用样式

在这里插入图片描述

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值