Log axes and ticks/ticklabels not working simultaneously

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)

    left    =  0.125,  
    right   =  0.9, 
    bottom  =  0.1,
    top     =  0.9, 
    wspace  =  0.3, 
    hspace  =  0.3

#top left plot


### top right plot

### bottom row plots

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')

Hi, can you please provide an example of yticks and some sample of the data (np.random.random(low, high) of your data range in the right shape would be fine) so that your problem can be reproduced?

1 Like

Yes, please post something reproducible and let us know what version of matplotlib.

However, almost certainly you need to do ax[0][0].set_ylim(min=1) because the bottom of a histogram is by default 0, and you can’t plot 0 on a log scale.