Skip to content

Commit

Permalink
Added adjustment features for label sizes on publication plots
Browse files Browse the repository at this point in the history
  • Loading branch information
itsmoosh committed Mar 18, 2024
1 parent 92b2a3a commit a432458
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
2 changes: 1 addition & 1 deletion functions/plotting/SetPlotDefaults.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@

interpreter = 'tex';
font = 'Times';
fontsize = 16;
fontsize = 12;

end
39 changes: 28 additions & 11 deletions publication/MakeHodograms.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
datDir = 'out';
tileSize = 2; % in inches
pad = 0.025*tileSize;
INC_MODEL = 0; % Whether to include model name in plot titles
INC_AX_LBLS = 1; % Whether to include axis labels

%% Jupiter family
parentName = 'Jupiter';
Expand Down Expand Up @@ -64,7 +66,8 @@
if ~strcmp(outCoords(1:3), 'IAU'); SPHOUT = 1; end

nexttile
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i});
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i}, 1, ...
fontsize, INC_MODEL, INC_AX_LBLS);
end

fName = [parentName 'FamilyHodogram'];
Expand Down Expand Up @@ -111,7 +114,7 @@
fig = figure('Visible', 'off', 'Name', windowName);
end
hold on;
ApplyPlotDefaults(fig, interpreter, font);
ApplyPlotDefaults(fig, interpreter, font, fontsize);
tiles = tiledlayout(1, nMoons, 'TileSpacing', 'tight', 'Padding', 'tight');

for i=1:nMoons
Expand All @@ -123,7 +126,8 @@
if ~strcmp(outCoords(1:3), 'IAU'); SPHOUT = 1; end

nexttile
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i}, 0);
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i}, 0, ...
fontsize, INC_MODEL, INC_AX_LBLS);
end

fName = [parentName 'FamilyHodogram1'];
Expand Down Expand Up @@ -165,7 +169,7 @@
fig = figure('Visible', 'off', 'Name', windowName);
end
hold on;
ApplyPlotDefaults(fig, interpreter, font);
ApplyPlotDefaults(fig, interpreter, font, fontsize);
tiles = tiledlayout(1, nMoons, 'TileSpacing', 'tight', 'Padding', 'tight');

for i=1:nMoons
Expand All @@ -177,7 +181,8 @@
if ~strcmp(outCoords(1:3), 'IAU'); SPHOUT = 1; end

nexttile
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i}, 0);
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i}, 0, ...
fontsize, INC_MODEL, INC_AX_LBLS);
end

fName = [parentName 'FamilyHodogram2'];
Expand Down Expand Up @@ -224,7 +229,7 @@
fig = figure('Visible', 'off', 'Name', windowName);
end
hold on;
ApplyPlotDefaults(fig, interpreter, font);
ApplyPlotDefaults(fig, interpreter, font, fontsize);
tiles = tiledlayout(1, nMoons, 'TileSpacing', 'tight', 'Padding', 'tight');

for i=1:nMoons
Expand All @@ -235,7 +240,8 @@
if ~strcmp(outCoords(1:3), 'IAU'); SPHOUT = 1; end

nexttile
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i});
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt{i}, 1, ...
fontsize, INC_MODEL, INC_AX_LBLS);
end

fName = [parentName 'FamilyHodogram'];
Expand Down Expand Up @@ -277,10 +283,11 @@
fig = figure('Visible', 'off', 'Name', windowName);
end
hold on;
ApplyPlotDefaults(fig, interpreter, font);
ApplyPlotDefaults(fig, interpreter, font, fontsize);
tiles = tiledlayout(1, nMoons, 'TileSpacing', 'tight', 'Padding', 'tight');
nexttile
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt);
PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, cfmt, 1, ...
fontsize, INC_MODEL, INC_AX_LBLS);

fName = [parentName 'FamilyHodogram'];
outFig = fullfile(figDir, [fName '.' figXtn]);
Expand All @@ -296,17 +303,27 @@
end

function [xInfo, yInfo] = PlotHodogramTile(moonName, parentName, magModelDescrip, BvecMoon, ...
SPHOUT, cfmt, LIMS)
SPHOUT, cfmt, LIMS, fontsize, INC_MODEL, INC_AX_LBLS)
if ~exist('LIMS', 'var'); LIMS = 1; end
[xx, yy, ~, ~, xInfo, yInfo, ~, xlims, ylims] = HodogramSingle( ...
moonName, parentName, magModelDescrip, BvecMoon, SPHOUT, 0, 0);

plot(xx, yy, 'color', cfmt);
pbaspect([1 1 1])
daspect([1 1 1])
title([moonName ', ' magModelDescrip]);
if INC_MODEL
thetitle = [moonName ', ' magModelDescrip];
else
thetitle = moonName;
end
title(thetitle);
if LIMS
xlim(xlims);
ylim(ylims);
end
if INC_AX_LBLS
xlabel(xInfo);
ylabel(yInfo);
end
set(gca, 'fontSize', fontsize);
end
2 changes: 1 addition & 1 deletion publication/PrintSurfaceMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function PrintSurfaceMap(planet, model, hpDir, hpFname, outDir, outFbase)
case 'Jupiter'
opts = 1:7;
case 'Saturn'
opts = 1:2;
opts = 1:3;
case 'Uranus'
opts = 1:2;
case 'Neptune'
Expand Down
27 changes: 17 additions & 10 deletions publication/makeSurfaceMaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@
7: f'JRM33C2020{mpEnd}'
},
'Saturn': {
0: f'Cassini11{mpEnd}',
0: f'Cassini11plus{mpEnd}',
1: f'B2010{mpEnd}',
2: f'Cassini11{mpEnd}'
2: f'Cassini11{mpEnd}',
3: f'Cassini11plus{mpEnd}'
},
'Uranus': {
0: f'AH5{mpEnd}',
Expand Down Expand Up @@ -335,6 +336,7 @@ def loadSurfaceMap(planet, model=None, ioDir='publication', fBase='surfMap_', ve

Bout_G = []
titles = []
cbarTitles = []
for file in inpFile:
data = loadmat(f'{file}.mat')
magModelDescrip = data['magModelDescrip'][0, 0]
Expand Down Expand Up @@ -365,9 +367,10 @@ def loadSurfaceMap(planet, model=None, ioDir='publication', fBase='surfMap_', ve
'"theta", "phi", "x", "y", "z".')

Bout_G.append(np.squeeze(Bcomp_G))
titles.append(f'{planet} {magModelDescrip} $B_{vecCompStr}$ (G)')
titles.append(f'{planet} {magModelDescrip} $B_{vecCompStr}~(\mathrm{{G}})$')
cbarTitles.append(f'$B_{vecCompStr}~(\mathrm{{G}})$')

return Bout_G, titles, inpFile
return Bout_G, titles, cbarTitles, inpFile


def healpixMap(ax, Bplot_G, vecComp, title, levels=None, cmap=None):
Expand Down Expand Up @@ -415,7 +418,7 @@ def healpixMap(ax, Bplot_G, vecComp, title, levels=None, cmap=None):
ax.clabel(asymContours, fmt=Cformat, fontsize=cLabelFontSize, inline_spacing=cLabelPad)
ax.set_title(title, size=titleFontSize)
ax.set_aspect(1)
return
return asymMap


def plotAllIndividual():
Expand All @@ -424,19 +427,21 @@ def plotAllIndividual():
"""

for planet in ['Jupiter', 'Saturn', 'Uranus', 'Neptune']:
Bout_G, titles, figFiles = loadSurfaceMap(planet, model='all', vecComp=vecCompChoice)
Bout_G, titles, cbarTitles, figFiles = loadSurfaceMap(planet, model='all', vecComp=vecCompChoice)
if MATCH_PREV:
doLevels = prevCont[planet]
else:
doLevels = None

for Bplot_G, title, file in zip(Bout_G, titles, figFiles):
for Bplot_G, title, cbarTitle, file in zip(Bout_G, titles, cbarTitles, figFiles):
outFile = f'{file}.pdf'
fig = plt.figure(figsize=deftFigsize)
grid = GridSpec(1, 1)
ax = fig.add_subplot(grid[0, 0])

healpixMap(ax, Bplot_G, vecCompChoice, title, levels=doLevels)
themap = healpixMap(ax, Bplot_G, vecCompChoice, title, levels=doLevels)
cbar = fig.colorbar(themap, ax=ax)
cbar.ax.set_title(cbarTitle)
plt.tight_layout()
fig.savefig(outFile, format='pdf', dpi=300, metadata=meta)
log.debug(f'Surface field map figure saved to file: {outFile}')
Expand Down Expand Up @@ -467,8 +472,10 @@ def plotDefaultTogether(fBase='surfMap_'):
else:
doLevels = None

Bplot_G, title, _ = loadSurfaceMap(planet, model=0, vecComp=vecCompChoice)
healpixMap(ax, Bplot_G[0], vecCompChoice, title[0], cmap=None, levels=doLevels)
Bplot_G, title, cbarTitle, _ = loadSurfaceMap(planet, model=0, vecComp=vecCompChoice)
themap = healpixMap(ax, Bplot_G[0], vecCompChoice, title[0], cmap=None, levels=doLevels)
cbar = fig.colorbar(themap, ax=ax)
cbar.ax.set_title(cbarTitle[0])

plt.tight_layout()
fig.savefig(outFile, bbox_inches='tight', format='pdf', dpi=300, metadata=meta)
Expand Down

0 comments on commit a432458

Please sign in to comment.