当前位置:网站首页>Data analysis - Matplotlib sample code
Data analysis - Matplotlib sample code
2022-07-02 11:48: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")
# Set the coordinate range [xmin, xmax, ymin, ymax]
plt.axis([-2.1, 2.1, -1.2, 1.2])
# Show labels
plt.legend()
# Show grid
plt.grid(alpha=0.4)
plt.title("Two Plots", color=(0.1, 0.3, 0.5))
plt.show()The operation input is shown in the figure below :

import matplotlib as mpl
mpl.rcParams["font.sans-serif"] = ["Microsoft YaHei"]
mpl.rcParams['axes.unicode_minus'] = Falseabout Ubuntu System , You need to manually specify the font to realize the display of Chinese . The setup code is as follows .

边栏推荐
- How to Add P-Values onto Horizontal GGPLOTS
- MTK full dump grab
- How to Create a Beautiful Plots in R with Summary Statistics Labels
- 原生方法合并word
- JS——每次调用从数组里面随机取一个数,且不能与上一次为同一个
- Liftover for genome coordinate conversion
- [multithreading] the main thread waits for the sub thread to finish executing, and records the way to execute and obtain the execution result (with annotated code and no pit)
- 基于Hardhat和Openzeppelin开发可升级合约(二)
- 八大排序汇总
- R HISTOGRAM EXAMPLE QUICK REFERENCE
猜你喜欢

Eight sorting summaries

Webauthn - official development document

Summary of data export methods in powerbi

亚马逊云科技 Community Builder 申请窗口开启

HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R

HOW TO ADD P-VALUES ONTO A GROUPED GGPLOT USING THE GGPUBR R PACKAGE

6方面带你认识LED软膜屏 LED软膜屏尺寸|价格|安装|应用

基于Hardhat和Openzeppelin开发可升级合约(一)

HOW TO ADD P-VALUES TO GGPLOT FACETS

How to Create a Nice Box and Whisker Plot in R
随机推荐
BEAUTIFUL GGPLOT VENN DIAGRAM WITH R
A white hole formed by antineutrons produced by particle accelerators
Tiktok overseas tiktok: finalizing the final data security agreement with Biden government
抖音海外版TikTok:正与拜登政府敲定最终数据安全协议
Attribute acquisition method and operation notes of C # multidimensional array
Webauthn - official development document
mysql 基本语句
制造业数字化转型和精益生产什么关系
由粒子加速器产生的反中子形成的白洞
Summary of flutter problems
HOW TO CREATE A BEAUTIFUL INTERACTIVE HEATMAP IN R
What week is a date obtained by QT
The computer screen is black for no reason, and the brightness cannot be adjusted.
Jinshanyun - 2023 Summer Internship
ESP32音频框架 ESP-ADF 添加按键外设流程代码跟踪
MySQL linked list data storage query sorting problem
Homer forecast motif
HOW TO CREATE AN INTERACTIVE CORRELATION MATRIX HEATMAP IN R
FLESH-DECT(MedIA 2021)——一个material decomposition的观点
Always report errors when connecting to MySQL database