From c36c227e117974fb9764d566a67c9354a1b878f1 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Sun, 25 May 2025 18:22:32 +0200 Subject: [PATCH] generate_plots: add option to adjust plot text sizes --- generate_plots.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/generate_plots.py b/generate_plots.py index f91e6f1..155446d 100644 --- a/generate_plots.py +++ b/generate_plots.py @@ -15,6 +15,18 @@ import concurrent.futures from concurrent.futures import wait, ALL_COMPLETED from functools import partial +SMALL_SIZE = 16 +MEDIUM_SIZE = 18 +BIGGER_SIZE = 20 + +plt.rc('font', size=SMALL_SIZE) # controls default text sizes +plt.rc('axes', titlesize=MEDIUM_SIZE) # fontsize of the axes title +plt.rc('axes', labelsize=MEDIUM_SIZE) # fontsize of the x and y labels +plt.rc('xtick', labelsize=SMALL_SIZE) # fontsize of the tick labels +plt.rc('ytick', labelsize=SMALL_SIZE) # fontsize of the tick labels +plt.rc('legend', fontsize=SMALL_SIZE) # legend fontsize +plt.rc('figure', titlesize=BIGGER_SIZE) # fontsize of the figure title + def normalizePhase(phase, phaseMin = None, phaseMax = None): if(phaseMin is None): phaseMin = np.abs(np.min(phase)) @@ -70,7 +82,7 @@ def plotBinsHistogram(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, bins, ti quit() axHisto.set_ylabel("Num. flares") axHisto.set_xlabel("Phase") - axHisto.set_title(title) + axHisto.set_title(title, wrap=True) axHisto.xaxis.set_major_formatter(tck.FormatStrFormatter('%g $\pi$')) axHisto.xaxis.set_major_locator(MaxNLocator(5)) axHisto.legend() @@ -90,7 +102,7 @@ def plotBinsHistogram(PDCSAPdataList, PDCSAPlabelList, PDCSAPcolorList, bins, ti fitCol = np.array([0, 1]) axHistoPhase.set_ylim(np.min(fitCol), np.max(fitCol)*1.2) - plt.savefig(filename) + plt.savefig(filename, bbox_inches="tight") plt.close() def plotFlarePhasePeakHistogram(xData, yData, bins, maxY, title, filename): @@ -106,8 +118,8 @@ def plotFlarePhasePeakHistogram(xData, yData, bins, maxY, title, filename): figFlarepeakHist.colorbar(im, label='Counts', ax=axFlarepeakHist) axFlarepeakHist.xaxis.set_major_formatter(tck.FormatStrFormatter('%g $\pi$')) axFlarepeakHist.xaxis.set_major_locator(MaxNLocator(5)) - axFlarepeakHist.set_title(title) - plt.savefig(filename) + axFlarepeakHist.set_title(title, wrap=True) + plt.savefig(filename, bbox_inches="tight") plt.close() def plotFlarePeaks(plotdata, filters, labels, colors, maxY, title, filename): @@ -134,11 +146,11 @@ def plotFlarePeaks(plotdata, filters, labels, colors, maxY, title, filename): axFlarePeaks.set_ylim(0.99, maxY) axFlarePeaks.set_ylabel("Flare peak") axFlarePeaks.set_xlabel("Phase") - axFlarePeaks.set_title(title) + axFlarePeaks.set_title(title, wrap=True) axFlarePeaks.xaxis.set_major_formatter(tck.FormatStrFormatter('%g $\pi$')) axFlarePeaks.xaxis.set_major_locator(MaxNLocator(5)) axFlarePeaks.legend() - plt.savefig(filename) + plt.savefig(filename, bbox_inches="tight") plt.close() def setupxyDataAndDataList(PDCSAPdataList2dhistPhase, PDCSAPdataList2dhistPeak, pdcsapbinningData,