Wednesday, September 3, 2025
HomeLanguagesMatplotlib.pyplot.axis() in Python

Matplotlib.pyplot.axis() in Python

Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. Pyplot is a Matplotlib module which provides a MATLAB-like interface. Matplotlib is designed to be as usable as MATLAB, with the ability to use Python and the advantage of being free and open-source.

matplotlib.pyplot.axis()

This function is used to set some axis properties to the graph.

Syntax: matplotlib.pyplot.axis(*args, emit=True, **kwargs)

Parameters:
xmin, xmax, ymin, ymax:These parameters can be used to
set the axis limits on the graph
emit:Its a bool value used to notify observers of the axis limit change

Example #1:




import matplotlib.pyplot as plt
  
  
x =[1, 2, 3, 4, 5]
y =[2, 4, 6, 8, 10]
  
# Plotting the graph
plt.plot(x, y)
  
# Setting the x-axis to 1-10
# and y-axis to 1-15
plt.axis([0, 10, 1, 15])
  
# Showing the graph with updated axis
plt.show()


Output:
Matplotlib.pyplot.axis()

Example #2:




import matplotlib.pyplot as plt
  
x =[1, 2, 3, 4, 5]
y =[2, 4, 6, 8, 10]
  
plt.plot(x, y)
  
# we can turn off the axis and display
# only the line by passing the 
# optional parameter 'off' to it
plt.axis('off')
  
plt.show()


Output:
Matplotlib.pyplot.axis()

RELATED ARTICLES

Most Popular

Dominic
32260 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6625 POSTS0 COMMENTS
Nicole Veronica
11795 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11855 POSTS0 COMMENTS
Shaida Kate Naidoo
6746 POSTS0 COMMENTS
Ted Musemwa
7023 POSTS0 COMMENTS
Thapelo Manthata
6694 POSTS0 COMMENTS
Umr Jansen
6714 POSTS0 COMMENTS