I am trying to create a function that will take in any number of datafiles, make an appropriate subplot, and create an appropriate figure size to plot each datafile without messing with how the title or colorbar looks. The code I have is below. My code is below:
# create figure and axes
row = int(np.ceil(len(files)/col))
fig, axs = plt.subplots(row, col, figsize=(width, height), dpi=dpi, facecolor='black')
# loop through the counts data
for c_mean, a in zip(counts_mean, axs.ravel()):
img = a.imshow(c_mean, origin='lower', norm=colors.PowerNorm(gamma=.3, vmin=0, vmax=10), cmap='inferno')
# add title
plt.suptitle('Title', fontsize=40)
# add colorbar
cbar_ax = fig.add_axes([0.17, 0.88, 0.68, 0.03])
cbar = fig.colorbar(img, cax=cbar_ax, orientation='horizontal')
cbar_ax.xaxis.set_ticks_position('top')
cbar.set_label('photon counts', size=25, labelpad=-90)
# adjust spacing between the subplots
plt.subplots_adjust(wspace=0, hspace=0)
# timestamps on each of the individual plots
for a, time in zip(axs.ravel(), times):
t = time[0] # the label is the intial time point
label = t[5:7] + '/' + t[8:10] + '/' + t[2:4] + ' ' + t[11:19]
a.text(0, 10, label, color='white', size=8)
I tried using set_aspect(‘auto’), but this does not help. The plots are very tiny compared to a larger title
New contributor
Amelia Gandhi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.