better ticks for slices

This commit is contained in:
Mayeul Aubin 2025-04-28 14:26:14 +02:00
parent 4b7386ae7d
commit 9352ea6f6d

View file

@ -25,6 +25,7 @@ def plot_imshow_with_reference( data_list,
- cmap: colormap to be used for plotting
"""
import matplotlib.pyplot as plt
from matplotlib import ticker
if titles is None:
titles = [None for f in data_list]
@ -65,6 +66,8 @@ def plot_imshow_with_reference( data_list,
axes[0, i].set_xticklabels(tick_labels[i])
axes[0, i].set_yticklabels(tick_labels[i])
axes[0, i].set_xlabel('Mpc/h')
axes[0, i].xaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
axes[0, i].yaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
fig.colorbar(im, ax=axes[0, :], orientation='vertical')
# Plot the data compared to the reference
@ -76,6 +79,8 @@ def plot_imshow_with_reference( data_list,
axes[1, i].set_xticklabels(tick_labels[i])
axes[1, i].set_yticklabels(tick_labels[i])
axes[1, i].set_xlabel('Mpc/h')
axes[1, i].xaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
axes[1, i].yaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
fig.colorbar(im, ax=axes[1, :], orientation='vertical')
# Add the score on the plots
@ -93,6 +98,8 @@ def plot_imshow_with_reference( data_list,
axes.set_xticklabels(tick_labels[0])
axes.set_yticklabels(tick_labels[0])
axes.set_xlabel('Mpc/h')
axes.xaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
axes.yaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
fig.colorbar(im, ax=axes, orientation='vertical')
else:
@ -104,6 +111,8 @@ def plot_imshow_with_reference( data_list,
axes[i].set_xticklabels(tick_labels[i])
axes[i].set_yticklabels(tick_labels[i])
axes[i].set_xlabel('Mpc/h')
axes[i].xaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
axes[i].yaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
fig.colorbar(im, ax=axes[:], orientation='vertical')
return fig, axes
@ -171,6 +180,6 @@ if __name__ == "__main__":
fig.suptitle(args.title)
if args.output is not None:
fig.savefig(args.output)
fig.savefig(args.output,bbox_inches='tight')
else:
fig.savefig(args.directory+'slices.png')
fig.savefig(args.directory+'slices.jpg',bbox_inches='tight')