I do this
def example_plot(ax, somedata, somedata2, title, xlab, ylab, fontsize=12):
ax.plot(somedata, color='b')
ax.plot(somedata2, color='g')
ax.locator_params(nbins=3)
ax.set_xlabel(xlab, fontsize=8)
ax.set_ylabel(ylab, fontsize=10)
ax.set_title(title, fontsize=10)
import matplotlib.pyplot as plt
import numpy as np
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(nrows=2, ncols=2)
ax1.grid(color='r', linestyle='-', linewidth=1)
ax2.grid(color='r', linestyle='-', linewidth=1)
ax3.grid(color='r', linestyle='-', linewidth=1)
ax4.grid(color='r', linestyle='-', linewidth=1)
example_plot(ax1,cumulative1,survival1, t1, xlbl1, ylbl1)
example_plot(ax2,cumulative2,survival2, t2, xlbl2, ylbl2)
example_plot(ax3,cumulative3,survival3, t3, xlbl3, ylbl3)
example_plot(ax4,cumulative4,survival4, t4, xlbl4, ylbl4)
plt.tight_layout(pad= 0.4, w_pad= 0.5, h_pad = 1.0)
My question revolves around applying custom xticks to every subplot. No matter how many times or where I place the lines
plt.xticks(np.arange(0,100, step = 10))
plt.xlim(0, 100)
They only wind up applying to the 4th subplot. How to define custom xticks for each subplot?
