Matplotlib.axes.Axes.semilogy() in Python
Last Updated :
13 Apr, 2020
Improve
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.
The Axes.semilogy() function in axes module of matplotlib library is used to make a plot with log scaling on the y axis.
Python3
Output:
Example-2:
Python3
Output:
matplotlib.axes.Axes.semilogy() Function
Syntax:Below examples illustrate the matplotlib.axes.Axes.semilogy() function in matplotlib.axes: Example-1:Axes.semilogy(self, *args, **kwargs)Parameters: This method accept the following parameters that are described below:Returns: This returns the following:
- basey: This parameter is the base of the y logarithm and are optional with default value 10.
- subsy: This parameter is the sequence of location of the minor y ticks and is optional.
- nonposy: This parameter is a non-positive values in y that can be masked as invalid, or clipped to a very small positive number.
- lines:This returns the list of Line2D objects representing the plotted data..
# 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.semilogy(test, np.exp(-test / 5.0))
ax.grid()
ax.set_title('matplotlib.axes.Axes.semilogy Example1')
plt.show()

# 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.semilogy(test, np.sin(3 * np.pi * test))
ax.grid()
ax.set_title('matplotlib.axes.Axes.semilogy Example2')
plt.show()
