Hi, I’m having issues setting logarithmic axes and customizing my ticks/ticklabels simultaneously. Attached are a set of subplots which show the various results I get. The top left plot is when I try to log the y-axis and set my own ticks, the top right is only setting the log axis (not changing ticks), and the bottom 2 are doing ticks but not changing to log. Looking forward to hearing back from you guys, this has been plaguing me for several days now. Thanks.
My code. Apologies if this post isn’t formatted ideally:
fig, ax = plt.subplots(figsize=(14,8), ncols=2, nrows=2)
plt.subplots_adjust(
left = 0.125,
right = 0.9,
bottom = 0.1,
top = 0.9,
wspace = 0.3,
hspace = 0.3
)
#top left plot
ax[0][0].set_yscale('log')
ax[0][0].set_yticks(yticks)
ax[0][0].get_yaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())
### top right plot
ax[0][1].set_yscale('log')
### bottom row plots
ax[1][0].set_yticks(yticks)
ax[1][1].set_yticks(yticks)
ax[1][0].set_yticklabels(yticklabels, fontsize=14)
ax[1][1].set_yticklabels(yticklabels, fontsize=14)
### core stuff
fig.text(0.5, 0.005, 'Fraction of samples a reaction is found in', ha='center', fontsize=18)
fig.text(0.06, 0.5, 'Distribution of reactions within group (logged)', ha="center", va="center", rotation=90, fontsize=18)
ax[0][0].hist(bacteria_rxnfracs, bins=20, weights=bacteria_rxnweights, color='darkcyan')
ax[0][1].hist(archaea_rxnfracs, bins=20, weights=archaea_rxnweights, color='purple')
ax[1][0].hist(eukarya_rxnfracs, bins=20, weights=eukarya_rxnweights, color='goldenrod')
ax[1][1].hist(metagenome_rxnfracs, bins=20, weights=metagenome_rxnweights, color='black')
plt.suptitle("Frequency Distribution of Reactions", fontsize=22, fontweight='bold')