【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("成大事者,不拘小节")
相关推荐
软件开发技术深度爱好者几秒前
Python类中方法种类介绍
开发语言·python
用户83562907805114 分钟前
使用Python合并Word文档:实现高效自动化办公
后端·python
闭着眼睛学算法1 小时前
【双机位A卷】华为OD笔试之【排序】双机位A-银行插队【Py/Java/C++/C/JS/Go六种语言】【欧弟算法】全网注释最详细分类最全的华子OD真题题解
java·c语言·javascript·c++·python·算法·华为od
Pocker_Spades_A1 小时前
Python快速入门专业版(五十四):爬虫基石:HTTP协议全解析(从请求到响应,附Socket模拟请求)
爬虫·python·http
DoubleKK1 小时前
Python 中的 json_repair 使用教程:轻松修复大模型返回的非法 JSON
python
萧鼎2 小时前
深入掌握 OpenCV-Python:从图像处理到智能视觉
图像处理·python·opencv
海琴烟Sunshine2 小时前
leetcode 190. 颠倒二进制位 python
python·算法·leetcode
淡忘_cx2 小时前
Dify Plugin 开发教程
python
海琴烟Sunshine3 小时前
leetcode 338. 比特位计数 python
python·算法·leetcode
呆萌很3 小时前
字典推导式练习题
python