Saturday, September 6, 2025
HomeLanguagesmatplotlib.axes.Axes.semilogx() in Python

matplotlib.axes.Axes.semilogx() in Python

Matplotlib is a library in Python and it is numerical – mathematical extension for NumPy library. The Axes Class contains most of the figure elements: Axis, Tick, Line2D, Text, Polygon, etc., and sets the coordinate system. And the instances of Axes supports callbacks through a callbacks attribute.

matplotlib.axes.Axes.semilogx() Function

The Axes.semilogx() function in axes module of matplotlib library is used to make a plot with log scaling on the x axis.

Syntax:

Axes.semilogx(self, *args, **kwargs)

Parameters: This method accept the following parameters that are described below:

  • basex: This parameter is the base of the x logarithm and is optional with default value 10.
  • subsx: This parameter is the sequence of location of the minor x ticks and is optional.
  • nonposx: This parameter is non-positive values in x that can be masked as invalid, or clipped to a very small positive number.

Returns: This returns the following:

  • lines:This returns the list of Line2D objects representing the plotted data..

Below examples illustrate the matplotlib.axes.Axes.semilogx() function in matplotlib.axes:

Example-1:




# Implementation of matplotlib function
      
import numpy as np
import matplotlib.pyplot as plt
  
fig, ax = plt.subplots()
  
dt = 0.1
test = np.arange(dt, 30.0, dt)
  
ax.semilogx(test, np.exp(-test / 6.0))
ax.grid()
  
ax.set_title('matplotlib.axes.Axes.semilogx Example1')
plt.show()


Output:

Example-2:




# Implementation of matplotlib function
      
import numpy as np
import matplotlib.pyplot as plt
  
test = np.arange(0.01, 30.0, 0.1)
  
# Create figure
fig, ax = plt.subplots()
  
  
# log x axis
ax.semilogx(test, np.sin(3 * np.pi * test))
ax.grid()
  
  
ax.set_title('matplotlib.axes.Axes.semilogx Example2')
plt.show()


Output:

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32270 POSTS0 COMMENTS
Milvus
82 POSTS0 COMMENTS
Nango Kala
6639 POSTS0 COMMENTS
Nicole Veronica
11803 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11869 POSTS0 COMMENTS
Shaida Kate Naidoo
6752 POSTS0 COMMENTS
Ted Musemwa
7029 POSTS0 COMMENTS
Thapelo Manthata
6704 POSTS0 COMMENTS
Umr Jansen
6721 POSTS0 COMMENTS