name your axis in pyplot in python

To name the axes in a pyplot plot in Python, you can use the xlabel() and ylabel() functions from the pyplot module in the matplotlib library. Here is an example:

main.py
import matplotlib.pyplot as plt

# Create some data
x = [1, 2, 3, 4, 5]
y = [2, 4, 6, 8, 10]

# Plot the data
plt.plot(x, y)

# Name the axes
plt.xlabel("X-axis")
plt.ylabel("Y-axis")

# Display the plot
plt.show()
215 chars
16 lines

In this example, the xlabel() function is used to name the x-axis as "X-axis", and the ylabel() function is used to name the y-axis as "Y-axis". You can replace these strings with any labels you desire.

related categories

gistlibby LogSnag