当前位置:网站首页>matplotlib plt. Specific usage of text() - labeling points in a drawing
matplotlib plt. Specific usage of text() - labeling points in a drawing
2022-06-10 17:32:00 【Guoqingru】
matplotlib plt.text() Specific usage of —— When drawing a picture, label the points in the picture

plt.text(x, y, s, fontsize, verticalalignment,horizontalalignment,rotation , **kwargs)

import pandas as pd # Import data analysis module
import matplotlib.pyplot as plt # Import drawing module class
plt.rcParams['font.sans-serif']=['SimHei'] # The Chinese font in the figure is set to bold
plt.rcParams['axes.unicode_minus']=False # Negative value display
data=pd.read_excel(r"D:\ City rental map \ People flow and epidemic development \ Baidu migration .xlsx") # Reading data
city_name=data['city'] # The city name
people_flow=data['out_people']*100 # Outflow population , The unit has 100 people
confirm=data['confirm(2.10)'] # Number of confirmed cases
fig=plt.figure(figsize=(8,6)) # New canvas
ax=plt.subplot(1,1,1) # Subgraph initialization
ax.scatter(people_flow,confirm) # Draw a scatter plot
ax.set_title(" Population inflow - Number of confirmed cases ")
ax.set_xlabel(" Population inflow ( Hundred people )")
ax.set_ylabel(" Number of confirmed cases ")
plt.show()

ax.text(430, 337, " Beijing ", fontsize=12, color = "r", style = "italic", weight = "light", verticalalignment='center', horizontalalignment='right', rotation=90)

for i in range(len(confirm)):
ax.text(people_flow[i]*1.01, confirm[i]*1.01, city_name[i], fontsize=10, color = "r", style = "italic", weight = "light", verticalalignment='center', horizontalalignment='right',rotation=0) # Label the scatter

# -*- coding: utf-8 -*-
"""
Created on Sat Feb 15 10:29:38 2020
project name:add_annotation
@author: Handsome de Three uncles
"""
import pandas as pd # Import data analysis module
import matplotlib.pyplot as plt # Import drawing module class
plt.rcParams['font.sans-serif']=['SimHei'] # The Chinese font in the figure is set to bold
plt.rcParams['axes.unicode_minus']=False # Negative value display
data=pd.read_excel(r"D:\ City rental map \ People flow and epidemic development \ Baidu migration .xlsx") # Reading data
city_name=data['city'] # The city name
people_flow=data['out_people']*100 # Outflow population , The unit has 100 people
confirm=data['confirm(2.10)'] # Number of confirmed cases
fig=plt.figure(figsize=(8,6)) # New canvas
ax=plt.subplot(1,1,1) # Subgraph initialization
ax.scatter(people_flow,confirm) # Draw a scatter plot
ax.set_title(" Population inflow - Number of confirmed cases ")
ax.set_xlabel(" Population inflow ( Hundred people )")
ax.set_ylabel(" Number of confirmed cases ")
#ax.text(430, 337, " Beijing ", fontsize=12, color = "r", style = "italic", weight = "light", verticalalignment='center', horizontalalignment='right',rotation=90)
for i in range(len(confirm)):
ax.text(people_flow[i]*1.01, confirm[i]*1.01, city_name[i],
fontsize=10, color = "r", style = "italic", weight = "light",
verticalalignment='center', horizontalalignment='right',rotation=0) # Label the scatter
plt.show()
边栏推荐
- 新思科技助力以色列Visuality Systems推进安全“左移”
- Swift 3pThread tool Promise Pipeline Master/Slave Serial Thread confinement Serial queue
- Knowledge-based BERT: 像计算化学家一样提取分子特征的方法
- flex布局语法
- C# 根据EXCEL自动生成oracle建表语句
- Nat. Commun. | 用于加速发现抗生素抗性基因的知识整合和决策支持
- AHK common functions
- AIChE | ab initio drug design framework integrating mathematical programming method and deep learning model
- Only three steps are needed to learn how to use low code thingjs to connect with Sen data Dix data
- Make good use of the industrial chain to attract investment, create industrial cluster effect and realize the coordinated development of industries
猜你喜欢

What should be done to improve the service level of the park and optimize the business environment

Web3 is the most complete money making secret script. Just read this one

Take you to a preliminary understanding of the basic mechanism of classes and objects

ADB is not an internal or external command, nor is it a runnable program or batch file

Redis general instruction

聊聊消息中间件(1),AMQP那些事儿

丢失的遗传力--Missing heritability

Nacos注册中心

品牌难立,IPO难行,中国茶企困于“传统”?

For more than 20 years, there are only Durex, Okamoto and jasbon in the condom market
随机推荐
SVN中的回退操作
“挽弓当挽强,用箭当用长”,曼孚科技为数据服务行业开启新赛道
matplotlib plt.text()的具体用法——画图时给图中的点加标签
基于Feign远程调用
Primekg: building a knowledge map to achieve precision medicine
Intelligent scenic spot video monitoring 5g intelligent light pole gateway networking integrated pole
华为matepad能成为你的笔记本电脑副屏?
Importerror: libgl.so.1: cannot open shared object file: no such file or directory
Fabric. Keep the original level when JS element is selected
Web3最全搞钱秘籍,看这一篇就够了
IPO治不了威马的杂症?
Is the fund of futures account safe?
Complete AHK function commands
带你初步了解 类和对象 的基本机制
Redis通用指令
Fail fast and fail safe
Swift 3pThread tool Promise Pipeline Master/Slave Serial Thread confinement Serial queue
Eliminate if Five ways of else
力扣 20. 有效的括号
成立1年便成独角兽,腾讯滴滴做「靠山」,今年新晋的独角兽不简单