Answers for "matplotlib text"

2

add text to plot python

import matplotlib.pyplot as plt
w = 4
h = 3
d = 70
plt.figure(figsize=(w, h), dpi=d)
x = [1, 2, 4]
x_pos = 0.5
y_pos = 3
plt.text(x_pos, y_pos, "text on plot")
plt.plot(x)
plt.savefig("out.png")Outputout.png
Posted by: Guest on March-25-2021
0

plt text matplotlib white background

import numpy as np
import matplotlib.pyplot as plt
plt.figure()
ax = plt.subplot(111)
plt.plot(np.linspace(1,0,1000))
t = plt.text(0.03,.95,'text',transform=ax.transAxes,backgroundcolor='0.75',alpha=.5)
plt.show()
Posted by: Guest on December-14-2020

Python Answers by Framework

Browse Popular Code Answers by Language