Draw minor ticks at arbitrary place using Python Matplotlib.pyplot

In [1]:
import matplotlib.pyplot as plt
import numpy as np
from itertools import product
from matplotlib import ticker
%matplotlib inline
In [2]:
plt.figure(figsize=(4,3),facecolor="w")
plt.plot([0,1],[0,1])
minors = [0.1,0.12,0.125,0.15,0.16,0.17,0.18,0.19]
plt.axes().xaxis.set_minor_locator(ticker.FixedLocator(minors))
plt.tick_params(which='minor', length=3, color='r')
In [3]:
plt.figure(figsize=(4,3),facecolor="w")
plt.plot(np.log10([1,100]),np.log10([1,100]))
xtks = np.array([1,10,100])
xtkp = np.log10(xtks)
plt.axes().set_xticks(xtkp)
plt.axes().set_xticklabels(xtks)
ytks = np.array([1,10,100])
ytkp = np.log10(ytks)
plt.axes().set_yticks(ytkp)
plt.axes().set_yticklabels(ytks)
xminors = np.log10([2,3,5,20,30,40,50,60,70,80,90])
yminors = np.log10(([k*m for k,m in product([2,3,4,5,6,7,8,9],[1,10])]))
plt.axes().xaxis.set_minor_locator(ticker.FixedLocator(xminors))
plt.axes().yaxis.set_minor_locator(ticker.FixedLocator(yminors))
plt.tick_params(which='minor', length=3, color='k')