plt add axis name

from matplotlib import pyplot as plt    

fig = plt.figure()
plt.plot(data)
fig.suptitle('test title', fontsize=20)
plt.xlabel('xlabel', fontsize=18)
plt.ylabel('ylabel', fontsize=16)
fig.savefig('test.jpg')

Here is what the above code is Doing:
1. Create a figure object.
2. Plot the data.
3. Set the title, x-axis label, and y-axis label.
4. Save the figure.

The figure object is a container for all the plot elements. The title, labels, lines, and markers all belong to the figure.

The figure object has a number of methods that can be used to modify the plot. For example, you can change the font size of the title and labels using the set_size_inches method.

fig = plt.figure()
plt.plot(data)
fig.suptitle(‘test title’, fontsize=20)
plt.xlabel(‘xlabel’, fontsize=18)
plt.ylabel(‘ylabel’, fontsize=16)
fig.savefig(‘test.jpg’)

The figure also has a number of attributes that can be used to get information about the plot. For example, you can get the size of the figure in inches using the get_size_inches method.

fig = plt.figure()
plt.plot(data)
fig.suptitle(‘test title’, fontsize=20)
plt.xlabel(‘xlabel’, fontsize=18)
plt.ylabel(‘ylabel’, fontsize=16)
fig.savefig(‘test.jpg’)

fig.get_size_inches()

(8.0, 6.0)

You can also get the dpi (dots per inch) of the figure using the get_dpi method.

fig = plt.figure()
plt.plot(data)
fig.suptitle(‘test title’, fontsize=20)
plt.xlabel(‘xlabel’, fontsize=18)
plt.ylabel(‘ylabel’, fontsize=16)
fig.savefig(‘test.jpg’)

fig.get_dpi()

100.0

The figure size and dpi are used to calculate the final image size when the figure is saved as an image file. For example, if the figure size is 8×6 inches and the dpi is 100, the final image will be 800×600 pixels.

The figure also has a number of other methods and attributes that can be used