English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Matplotlib has extensive text support, including support for mathematical expressions, TrueType support for raster and vector output, newline characters separated by any rotation, and unicode support. Matplotlib includes its own matplotlib.font_manager, which implements a cross-platform, compliant with W3C font search algorithm.
Los usuarios pueden realizar un gran control sobre las propiedades del texto (tamaño de fuente, grosores de fuente, posición de texto y color, etc.). Matplotlib implements a large number of TeX mathematical symbols and commands.
text - Agregar texto en cualquier posición de Axes. annotate - Agregar una anotación en cualquier posición de Axes con flecha opcional. xlabel - Agregar una etiqueta en el eje x de Axes. ylabel - Agregar una etiqueta en el eje y de Axes. title - Agregar un título a Axes. figtext - Agregar texto en cualquier posición del gráfico. suptitle - Agregar un título al gráfico.
La siguiente lista de comandos se utiliza para crear texto en la interfaz de Pyplot -
# Filename : example.py # Copyright : 2020 By w3codebox # Author by: es.oldtoolbag.com # Date : 2020-08-08 #! /usr/bin/env python #coding=utf-8-8 import matplotlib.pyplot as plt import numpy as np import math import seaborn as sns plt.rcParams['font.sans-serif'] = ['SimHei'] # Step one (replace sans-serif) plt.rcParams['axes.unicode_minus'] = False # Original from 【Lìdì Huò】, please contact the author for commercial use, retain the original link for non-commercial use: fig = plt.figure() ax = fig.add_axes([0,0,1,1)] ax.set_title('título de ejes') ax.set_xlabel('xlabel') ax.set_ylabel('ylabel') ax.text(3, 8, 'texto de índice incluido en coordenadas de datos', style='italic', bbox = {'facecolor': 'red'} ax.text(2, 6, r'equación an: $E = mc^2')2, fontsize = 15) ax.text(4, 0.05, 'texto colorido en coords de eje', 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, 'texto colorido en coords de eje', 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()
ejecutar el código de ejemplo superior, obtener el siguiente resultado -