Semi-log and log-log graphs can be drawn by specifying'log' for set_xscale and set_yscale of matplotlib. As an example, plot $ y = e ^ {2x + 1} $.
import numpy as np
import matplotlib.pyplot as plt
"""
Logarithmic graph
"""
x = np.arange(0.001, 10, 0.1)
y = np.exp(2*x+1) #Function to plot
plt.plot(x, y)
ax = plt.gca()
ax.spines['top'].set_color('none')
##
ax.set_yscale('log') #Main:Draw y-axis on log scale
#ax.set_xscale('log')
##
plt.title('single logarithmic plot')
plt.xlabel('X',fontsize=18)
plt.ylabel('Y',fontsize=18)
plt.grid(which="both") #Grid display."both"Draws a grid on both xy axes.
plt.show()
A log-log graph can be drawn by specifying the x-axis on the log scale as shown below.
ax.set_yscale('log') #Draw y-axis on log scale
ax.set_xscale('log') #Draw x-axis on log scale