Answers for "add labels to plot matplotlib"

4

matplotlib axes labels

fig = plt.figure()
ax = fig.add_subplot(...)

ax.set_title('Title Here')

ax.set_xlabel('x label here')
ax.set_ylabel('y label here')
ax.set_zlabel('z label here')
Posted by: Guest on April-18-2020
0

matplotlib point labels

import matplotlib.pyplot as plt
import numpy as np

plt.clf()

# using some dummy data for this example
xs = np.arange(0,10,1)
ys = np.random.normal(loc=2.0, scale=0.8, size=10)

plt.plot(xs,ys)

# text is left-aligned
plt.text(2,4,'This text starts at point (2,4)')

# text is right-aligned
plt.text(8,3,'This text ends at point (8,3)',horizontalalignment='right')

plt.show()
Posted by: Guest on June-01-2021

Code answers related to "add labels to plot matplotlib"

Python Answers by Framework

Browse Popular Code Answers by Language