码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • matplotlib


    官网

    建议学习过程:

    1. 只看 官网教程-Introductory 了解基本语法和概念
    2. 使用时在 官网示例 中找类似的,然后在 官网API 中查阅并设置属性

    image-20221113104805363

    Figure图形:plt.figure

    【axis:坐标轴】
    【axes:坐标系,axis的复数形式】
    【编码时,不会直接出现axis的表示,单个axes简写为ax,多个axes简写为axs】
    Axes坐标系:fig.subplots
    Title题目:ax.set_title
    Grid网格:ax.grid
    Spine样条线:ax.spines
    Legend图例:ax.legend

    折线线:ax.plot
    散点图:ax.scatter
    条形图:ax.bar
    横条图:ax.barh
    饼图:ax.pie
    直方图:ax.hist
    Step阶梯图:ax.step

    x Axis X轴:ax.xaxis
    y Axis Y轴:ax.yaxis
    Major tick主刻度:ax.xaxis/yaxis.set_major_locator
    Major tick label主刻度标签:ax.xaxis/yaxis.set_major_formatter
    Minor tick次刻度:ax.xaxis/yaxis.set_minor_locator
    Minor tick label次刻度标签:ax.xaxis/yaxis.set_minor_formatter

    # 导入库
    import matplotlib as mlp
    import matplotlib.pyplot as plt
    import numpy as np
    from numpy import e, log, exp, square
    
    # 设置 中文字体 字体大小
    plt.rcParams['font.sans-serif'] = 'SimHei'
    plt.rcParams['font.size'] = 12
    
    # 无坐标系图 一个坐标系图 4=2*2个坐标系图
    # 常用参数:figsize layout
    fig = plt.figure()
    fig, ax = plt.subplots()
    fig, axs = plt.subplots(2, 2)
    
    # 折线图/散点图
    # 常用参数:label color linewidth linestyle
    # (仅限散点图) 点大小s, 点内颜色facecolor, 点边颜色edgecolor
    ax.plot([1, 2, 3, 4], [1, 4, 2, 3])
    ax.scatter([1, 2, 3, 4], [1, 4, 2, 3])
    
    # X轴标签 Y轴标签 标题
    # 可选参数 fontsize=14 color='red'
    ax.set_xlabel('x label')
    ax.set_ylabel('y label')
    ax.set_title("Simple Plot")
    
    # 显示图例 显示网格
    ax.legend()
    ax.grid(True)
    
    # 指定位置放置文本(无箭头)
    ax.text(75, .025, r'$\mu=115,\ \sigma=15$')
    # 指定位置放置标注(有箭头,删除arrowprops后无箭头)
    ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5), arrowprops=dict(facecolor='black', shrink=0.05))
    
    # 设置X轴的显示范围
    ax.set_xlim(-2, 2)
    # x轴显示 ['zero', '30', 'sixty', '90']
    ax.set_xticks(np.arange(0, 100, 30), ['zero', '30', 'sixty', '90'])
    # x轴显示 [-1.5, 0, 1.5] 3个数
    ax.set_xticks([-1.5, 0, 1.5])
    
    # 显示图表
    fig.show()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
  • 相关阅读:
    Qt不能安装自己想要的版本,如Qt 5.15.2
    导师转我800块,让我仿真一个电路(电源设计)
    从源码上解决rosdep update失败问题
    汽车自适应巡航系统控制策略研究
    springboot毕设项目车销售管理系统724s0(java+VUE+Mybatis+Maven+Mysql)
    【juc】future并行执行并获取返回值
    JavaScript switch语句
    股票买卖Ⅴ
    PG 多表连接查询
    对进程、线程和协程的理解以及它们的区别
  • 原文地址:https://blog.csdn.net/qq_42283621/article/details/127834435
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号