当前位置: 首页 > news >正文

人工智能基础-matplotlib基础

绘制图形

import numpy as np 
x = np.linspace(0, 10, 100)
y = np.sin(x)
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.plot(x, y)
plt.show()

无标题.png
绘制多条曲线

siny = y.copy()
cosy = np.cos(x)
plt.plot(x, siny)
plt.plot(x, cosy)
plt.show()

无标题.png
设置线条颜色

plt.plot(x, siny)
plt.plot(x, cosy, color="red")
plt.show()

无标题.png
设置线条样式

plt.plot(x, siny)
plt.plot(x, cosy, color="red", linestyle="--")
plt.show()

无标题.png
设置坐标系

plt.plot(x, siny)
plt.plot(x, cosy, color="red", linestyle="--")
plt.xlim(-5, 15)
plt.ylim(0, 1)
plt.show()

无标题.png

plt.plot(x, siny)
plt.plot(x, cosy, color="red", linestyle="--")
plt.axis([-1, 11, -2, 2])
plt.show()

无标题.png

plt.plot(x, siny)
plt.plot(x, cosy, color="red", linestyle="--")
plt.xlabel("x axis")
plt.ylabel("y value")
plt.show()

无标题.png
设置图示

plt.plot(x, siny, label="sin(x)")
plt.plot(x, cosy, color="red", linestyle="--", label="cos(x)")
plt.xlabel("x axis")
plt.ylabel("y value")
plt.legend()
plt.show()

无标题.png
设置标题

plt.plot(x, siny, label="sin(x)")
plt.plot(x, cosy, color="red", linestyle="--", label="cos(x)")
plt.xlabel("x axis")
plt.ylabel("y value")
plt.legend()
plt.title("Welcome to matplotlib world!")
plt.show()

无标题.png

散点图

plt.scatter(x, siny)
plt.show()

无标题.png

plt.scatter(x, siny)
plt.scatter(x, cosy, color="red")
plt.show()

无标题.png

x = np.random.normal(0, 1, 10000)
y = np.random.normal(0, 1, 10000)

plt.scatter(x, y, alpha=0.1)
plt.show()

无标题.png

相关文章:

  • PCL 点云RANSAC提取平面(非内置函数)
  • 超越CUDA:ROCm与oneAPI在异构计算中的性能对比实验(国产GPU生态下的开发路径探索)
  • x86 保护模式中的GDT表是什么?
  • 人力资源管理方向论文怎么写?
  • 第八章 文件操作
  • FOC算法对MCU计算资源的需求?
  • 【蓝桥杯】2025省赛PythonB组复盘
  • Spring Boot 集成spring-boot-starter-data-elasticsearch
  • C++ Json-Rpc框架-3项目实现(2)
  • Codeforces Round 1017 (Div. 4)题解
  • 明远智睿SSD2351核心板助力智能监控系统升级
  • 软件架构设计风格
  • 【C++ 】智能指针:内存管理的 “自动导航仪”
  • 最短路径介绍
  • 【论文解读】MSVM-UNet: Multi-Scale Vision Mamba UNet for Medical Image Segmentation
  • 机器学习项目二:帕金森病检测
  • 【C++教程】使用printf语句实现进制转换
  • 前端面试题(八):简述Vue2的响应式原理
  • mysql自动赋值
  • C语言题目自增在前与在后
  • 王毅:坚持金砖团结合作,改革完善全球治理
  • 鄂湘赣“中三角”,能否走向文旅C位?
  • 中共中央、国务院关于表彰全国劳动模范和先进工作者的决定
  • 十四届全国人大常委会举行第四十三次委员长会议 ,听取有关草案和议案审议情况汇报
  • 特朗普声称中方领导人打了电话,外交部:近期中美元首没有通话
  • 加拿大警方:已确认有9人在温哥华驾车撞人事件中遇难