Установите второстепенные галочки во всех подграфиках log-log

У меня есть фигура с двумя сюжетами в логарифмическом масштабе. Я хотел бы построить мелкие тики, а также. Несмотря на то, что я применил разные решения из Stack Overflow, моя фигура выглядит не так, как я хочу.

Одно из измененных мной решений взято из ImportanceOfBeingErnest и код выглядит так:

fig, ((ax1, ax2)) = plt.subplots(1, 2, figsize=(8, 5), sharey=True)

# First plot
ax1.loglog(PLOT1['X'], PLOT1['Y'], 'o',
         markerfacecolor='red', markeredgecolor='red', markeredgewidth=1,
         markersize=1.5, alpha=0.2)

ax1.set(xlim=(1e-4, 1e4), ylim=(1e-8, 1e2))
ax1.set_xscale("log"); ax1.set_yscale("log")
ax1.xaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0, numticks=25))
ax1.yaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0, numticks=25))

locmaj = matplotlib.ticker.LogLocator(base=10,numticks=25) 
ax1.xaxis.set_major_locator(locmaj)
locmin = matplotlib.ticker.LogLocator(base=10.0,subs=(0.2,0.4,0.6,0.8),numticks=25)
ax1.xaxis.set_minor_locator(locmin)
ax1.xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())

locmaj = matplotlib.ticker.LogLocator(base=10,numticks=25) 
ax1.yaxis.set_major_locator(locmaj)
locmin = matplotlib.ticker.LogLocator(base=10.0,subs=(0.2,0.4,0.6,0.8),numticks=25)
ax1.yaxis.set_minor_locator(locmin)
ax1.yaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())

ax1.set_xlabel('X values', fontsize=10, fontweight='bold')
ax1.set_ylabel('Y values', fontsize=10, fontweight='bold')

# Plot 2
ax2.loglog(PLOT2['X'], PLOT2['Y'], 'o',
         markerfacecolor='blue', markeredgecolor='blue', markeredgewidth=1,
         markersize=1.5, alpha=0.2)

ax2.set(xlim=(1e-4, 1e4), ylim=(1e-8, 1e2))
ax2.xaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0, numticks=25))
ax2.yaxis.set_major_locator(matplotlib.ticker.LogLocator(base=10.0, numticks=25))

locmaj = matplotlib.ticker.LogLocator(base=10,numticks=25) 
ax2.xaxis.set_major_locator(locmaj)
ax2.yaxis.set_major_locator(locmaj)

locmin = matplotlib.ticker.LogLocator(base=10.0,subs=(0.2,0.4,0.6,0.8),numticks=25)
ax2.xaxis.set_minor_locator(locmin)
ax2.yaxis.set_minor_locator(locmin)

ax2.xaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())
ax2.yaxis.set_minor_formatter(matplotlib.ticker.NullFormatter())

ax2.set_xlabel('X values', fontsize=10, fontweight='bold')
ax2.set_ylabel('Y values', fontsize=10, fontweight='bold')
ax2.minorticks_on()

plt.show()

Сюжет у меня следующий. Как видите, второстепенные деления появляются только на оси x от ax1.

Результирующий график с отсутствующими второстепенными делениями

Как я могу установить второстепенные тики на обоих участках и на обеих осях (x и y)?

Большое спасибо.


person aerisjd    schedule 06.12.2019    source источник
comment
Вам также необходимо установить локатор для оси ax2.   -  person ImportanceOfBeingErnest    schedule 06.12.2019
comment
Привет, ImportanceOfBeingErnest, я изменил все, что вы сделали для оси ax2 как для x, так и для y (включая локаторы). Правильно ли я сделал?   -  person aerisjd    schedule 06.12.2019
comment
Часть оси Y для x2 отсутствует.   -  person ImportanceOfBeingErnest    schedule 06.12.2019
comment
Ты прав. Спасибо за улов. Тем не менее, сюжет на моем ноутбуке Jupyter выглядит так же.   -  person aerisjd    schedule 06.12.2019
comment
О, и удалите строку ax2.minorticks_on(). Этого не должно быть в связанном решении, верно?   -  person ImportanceOfBeingErnest    schedule 06.12.2019
comment
Да, в самом деле!!! Все ваши комментарии решили мою проблему! Большое спасибо!   -  person aerisjd    schedule 06.12.2019