京东云服务器推荐配置、多种配置选择,满足不同业务需求!

热门推荐

⭐ 稳定入门选择

配置:2核2G/5M

适用场景:个人站点 / 轻量应用

特点:性价比高,稳定可靠

¥19/月
立即购买
流量友好

☁️ 轻量云主机

配置:2核4G 5M

适用场景:小型业务 / 博客 / 测试环境

特点:流量友好,性能均衡

¥149/年
立即购买
高性能

💻 云服务主机

配置:4核16G 8M

适用场景:中小型服务 / 多并发场景

特点:充足内存与带宽,性能强劲

¥750/年
立即购买
新人专享

🎁 新人福利

新人访问 → 点击 → 最新活动

可获取 3000元 礼券

立即领取
数据分析 / Matplotlib 教程 / Matplotlib 教程
Matplotlib 文本
Matplotlib 数学表达式Matplotlib 3D曲面图

Matplotlib 文本

Matplotlib具有广泛的文本支持,包括对数学表达式的支持,对光栅和矢量输出的TrueType支持,具有任意旋转的换行符分隔文本以及unicode支持。Matplotlib包含自己的matplotlib.font_manager,它实现了一个跨平台,符合W3C标准的字体查找算法。

用户可以对文本属性(字体大小,字体粗细,文本位置和颜色等)进行大量控制。Matplotlib实现了大量的TeX数学符号和命令。

text - 在Axes的任意位置添加文本。 annotate - 使用可选箭头在Axes的任意位置添加注释。 xlabel - 在Axes的x轴上添加标签。 ylabel - 在Axes的y轴上添加标签。 title - 为Axes添加标题。 figtext - 在图的任意位置添加文本。 suptitle - 在图中添加标题。

以下命令列表用于在Pyplot界面中创建文本 -

 # Filename : example.py
 # Copyright : 2020 By Nhooo
 # Author by : www.xsc123.com
 # Date : 2020-08-08
 #! /usr/bin/env python
 #coding=utf-8
 import matplotlib.pyplot as plt
 import numpy as np
 import math
 import seaborn as sns
 plt.rcParams['font.sans-serif'] = ['SimHei'] # 步骤一(替换sans-serif字体)
 plt.rcParams['axes.unicode_minus'] = False # 原文出自【立地货】,商业转载请联系作者获得授权,非商业请保留原文链接:
 fig = plt.figure()
 ax = fig.add_axes([0,0,1,1])
 ax.set_title('axes title')
 ax.set_xlabel('xlabel')
 ax.set_ylabel('ylabel')
 ax.text(3, 8, '数据坐标中包装的斜体文本', style='italic', 
 bbox = {'facecolor': 'red'})
 ax.text(2, 6, r'an equation: $E = mc^2, fontsize = 15)
 ax.text(4, 0.05, '轴coords中的彩色文本',
 verticalalignment = 'bottom', color = 'green', fontsize = 15)
 ax.plot([2], [1], 'o')
 ax.annotate('annotate', xy = (2, 1), xytext = (3, 4),
 arrowprops = dict(facecolor = 'black', shrink = 0.05))
 ax.axis([0, 10, 0, 10])
 plt.show()
 , fontsize = 15)
 ax.text(4, 0.05, '轴coords中的彩色文本',
 verticalalignment = 'bottom', color = 'green', fontsize = 15)
 ax.plot([2], [1], 'o')
 ax.annotate('annotate', xy = (2, 1), xytext = (3, 4),
 arrowprops = dict(facecolor = 'black', shrink = 0.05))
 ax.axis([0, 10, 0, 10])
 plt.show()

执行上面示例代码,得到以下结果 -

Matplotlib使用文本

Matplotlib 数学表达式Matplotlib 3D曲面图