I would like to plot errorbars on a y-log scale using matplotlib. My code works fine without a y log scale:
for inference_alg, inference_alg_num_clusters_df in num_clusters_by_dataset_by_inference_alg.items():
plt.errorbar(inference_alg_num_clusters_df.columns.values, # concentration parameters
inference_alg_num_clusters_df.mean(),
yerr=inference_alg_num_clusters_df.sem(),
label=inference_alg)
plt.xlabel(r'Concentration Parameter ($\alpha$ or $\lambda$)')
plt.ylabel('Number of Clusters')
plt.gca().set_ylim(bottom=0)
plt.gca().set_xlim(left=0)
plt.legend()
# plt.yscale('log')
# plt.yscale('log', nonposy='clip')
plt.show()
This creates the desired plot successfully:
However, when I try uncommenting either line to convert the yscale to log, I get the following plot:
What is happening, and how can I successfully use plt.errorbar with a semilog y scale?
Edit 1: as a possibly relevant detail, the smallest y value is 2.355 and the largest y value is 65.588. I don't think those are causing any issue with a log transform.