我正在尝试在 matplotlib 中制作一个非常简单的日志图。但是,似乎我可以在 y 轴上得到小刻度,但由于某些 matplotlib 原因,而不是在 x 轴上。我想在所有轴(底部、左侧、右侧和顶部)上打勾,并在 x 轴(顶部和底部)上有小刻度。
这是我目前拥有的代码:
import math
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter
from matplotlib.ticker import ScalarFormatter
from matplotlib import colors as mcolors
from matplotlib import gridspec
plt.rcParams.update({'font.size': 14})
plt.clf()
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, sharex=True, sharey=True, gridspec_kw = {'wspace':0, 'hspace':0})
xmin = 0.006
xmax = 70.00
ymin = 0.0003
ymax = 4.00
ax1.set_xlim([xmin,xmax])
ax2.set_xlim([xmin,xmax])
ax3.set_xlim([xmin,xmax])
ax4.set_xlim([xmin,xmax])
ax1.set_xscale('log')
ax2.set_xscale('log')
ax3.set_xscale('log')
ax4.set_xscale('log')
ax1.set_ylim([ymin,ymax])
ax2.set_ylim([ymin,ymax])
ax3.set_ylim([ymin,ymax])
ax4.set_ylim([ymin,ymax])
ax1.set_yscale('log')
ax2.set_yscale('log')
ax3.set_yscale('log')
ax4.set_yscale('log')
ax1.plot(log_wavelength, t, alpha=0.75, color='black')
ax2.plot(log_wavelength, x, alpha=0.75, color='red')
ax3.plot(log_wavelength, y, alpha=0.75, color='green')
ax4.plot(log_wavelength, z, alpha=0.75, color='cyan')
ax1.minorticks_on()
ax2.minorticks_on()
ax3.minorticks_on()
ax4.minorticks_on()
ax1.tick_params(axis='both', which='minor', length=4, color='k')
ax2.tick_params(axis='both', which='minor', length=4, color='k')
ax3.tick_params(axis='both', which='minor', length=4, color='k')
ax4.tick_params(axis='both', which='minor', length=4, color='k')
ax.minorticks_on() 不起作用是有原因的吗?