【Python】Jupyter Matplotlib Basic Usage

Matplotlib

  • [Matplotlib Introduction](#Matplotlib Introduction)
  • [1. install matplotlib](#1. install matplotlib)
  • [2. run jupyter notebook](#2. run jupyter notebook)
  • [3. run a demo](#3. run a demo)
  • [4. try](#4. try)

Matplotlib Introduction

Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations.

Document

1. install matplotlib

bash 复制代码
conda install matplotlib

2. run jupyter notebook

bash 复制代码
jupyter notebook

8888 port

new a python file

3. run a demo

Matplotlab Demo

4. try

python 复制代码
import matplotlib.pyplot as plt # 导入pyplot,别名为plt

data = {'apple': 10, 'orange': 15, 'lemon': 5, 'lime': 20} # 字典
names = list(data.keys()) # 取出字典的key值(数组),对应x轴坐标的值
values = list(data.values()) # 去除字典的value值(数组),对于y轴坐标的值

# subplots用于创建一个图像和一组子图
# 1行3列,3个子图,figsize设置图的宽高,sharey共享y轴
fig, axs = plt.subplots(1, 3, figsize=(9, 3), sharey=True)
# 第一个图
axs[0].bar(names, values) # bar绘制柱状图
# 第二个图
axs[1].scatter(names, values) # scatter绘制散点图
# 第三个图
axs[2].plot(names, values) # plot绘制折线图
fig.suptitle('Categorical Plotting') # suptitle添加标题


Success!

like Echarts, u need more configuration to beauty chart.


复制代码
print("成大事者,不拘小节")
相关推荐
人工干智能3 分钟前
科普:%%matplotlib inline:魔法命令 (Cell Magic)
python·matplotlib
05大叔5 分钟前
优化器Adam,神经网络处理文本,CNN,RNN
开发语言·python·机器学习
徒 花28 分钟前
Python知识学习08
java·python·算法
前端技术1 小时前
ArkTS第三章:声明式UI开发实战
java·前端·人工智能·python·华为·鸿蒙
疯狂成瘾者1 小时前
.pyc格式文件
python
鬼圣1 小时前
Python 生成器与迭代器详解
python
西魏陶渊明1 小时前
解决异步挑战:Reactor Context 实现响应式上下文传递
开发语言·python
疯狂成瘾者1 小时前
增强型大模型代理
python
小李云雾1 小时前
FastAPI 后端开发:文件上传 + 表单提交
开发语言·python·lua·postman·fastapi
Legend NO241 小时前
数据资产评估风险识别、分析与管控体系建设
大数据·人工智能·python