当前位置:网站首页>数据分析 - matplotlib示例代码
数据分析 - matplotlib示例代码
2022-07-02 09:41:00 【yinshuilan】
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-2, 2, 100)
y1 = np.cos(np.pi * x)
y2 = np.sin(np.pi * x)
plt.plot(x, y1, "go", label=r"$y1=\cos(\pi \times x)$", alpha=0.8, linewidth=0.7)
plt.plot(x, y2, "r-", label=r"$y2=\sin(\pi \times x)$", alpha=0.8, linewidth=0.7)
df = pd.DataFrame(np.random.randint(0, 100, size=(100, 1)), columns=list('A'))
plt.annotate("important Point", (0, 1), xytext=(-1.5, 1.1), arrowprops=dict(arrowstyle='->'))
plt.xlabel("x-axis")
plt.ylabel("y-axis")
# 设置坐标范围[xmin, xmax, ymin, ymax]
plt.axis([-2.1, 2.1, -1.2, 1.2])
# 显示标签
plt.legend()
# 显示网格
plt.grid(alpha=0.4)
plt.title("Two Plots", color=(0.1, 0.3, 0.5))
plt.show()
运行输入如下图:
import matplotlib as mpl
mpl.rcParams["font.sans-serif"] = ["Microsoft YaHei"]
mpl.rcParams['axes.unicode_minus'] = False
对于Ubuntu系统,需要手动指定字体来实现中文的显示。 设置代码如下。
边栏推荐
- CTF record
- GGPlot Examples Best Reference
- Principe du contrat évolutif - delegatecall
- ros gazebo相关包的安装
- Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
- GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
- C#多维数组的属性获取方法及操作注意
- From the perspective of attack surface, see the practice of zero trust scheme of Xinchuang
- CentOS8之mysql基本用法
- Pit of the start attribute of enumrate
猜你喜欢
念念不忘,必有回响 | 悬镜诚邀您参与OpenSCA用户有奖调研
Esp32 audio frame esp-adf add key peripheral process code tracking
MTK full dump grab
Principe du contrat évolutif - delegatecall
Wechat applet uses Baidu API to achieve plant recognition
MySQL comparison operator in problem solving
How to Visualize Missing Data in R using a Heatmap
II Stm32f407 chip GPIO programming, register operation, library function operation and bit segment operation
RPA advanced (II) uipath application practice
Solve the problem of data blank in the quick sliding page of the uniapp list
随机推荐
ctf 记录
The selected cells in Excel form have the selection effect of cross shading
MTK full dump grab
Digital transformation takes the lead to resume production and work, and online and offline full integration rebuilds business logic
Never forget, there will be echoes | hanging mirror sincerely invites you to participate in the opensca user award research
2022年遭“挤爆”的三款透明LED显示屏
Gaode draws lines according to the track
GGPLOT: HOW TO DISPLAY THE LAST VALUE OF EACH LINE AS LABEL
SSRF
ROS lacks xacro package
Is the Ren domain name valuable? Is it worth investing? What is the application scope of Ren domain name?
MySQL stored procedure cursor traversal result set
How to Create a Beautiful Plots in R with Summary Statistics Labels
Homer forecast motif
Eight sorting summaries
亚马逊云科技 Community Builder 申请窗口开启
The difference between SQL left join main table restrictions written after on and where
How to Visualize Missing Data in R using a Heatmap
GGHIGHLIGHT: EASY WAY TO HIGHLIGHT A GGPLOT IN R
tidb-dm报警DM_sync_process_exists_with_error排查