diff options
author | tlatorre <tlatorre@uchicago.edu> | 2020-05-11 11:09:34 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2020-05-11 11:09:34 -0500 |
commit | e82c1e138c104943314150921eba0c2111a30d6c (patch) | |
tree | f63c7d469258f799f1374156e59842332620d5f7 /utils/plot-atmospheric-fluxes | |
parent | e2efea44f243b47bcbaca5ea03e304e1e4ce2cb7 (diff) | |
download | sddm-e82c1e138c104943314150921eba0c2111a30d6c.tar.gz sddm-e82c1e138c104943314150921eba0c2111a30d6c.tar.bz2 sddm-e82c1e138c104943314150921eba0c2111a30d6c.zip |
add setup_matplotlib function and switch to logarithmic bins
This commit contains the following small updates:
- create a setup_matplotlib() function to set up matplotlib correctly depending
on if we are saving the plots or just displaying them
- change default font size to 12 when displaying plots
- switch to using logarithmic bins in plot-energy
- fix despine() function when x axis is logarithmic
Diffstat (limited to 'utils/plot-atmospheric-fluxes')
-rwxr-xr-x | utils/plot-atmospheric-fluxes | 53 |
1 files changed, 6 insertions, 47 deletions
diff --git a/utils/plot-atmospheric-fluxes b/utils/plot-atmospheric-fluxes index 7dafbbb..042981c 100755 --- a/utils/plot-atmospheric-fluxes +++ b/utils/plot-atmospheric-fluxes @@ -30,59 +30,18 @@ if __name__ == '__main__': import argparse import matplotlib import glob + from sddm import setup_matplotlib parser = argparse.ArgumentParser("plot solar fluxes") parser.add_argument("filenames", nargs='+', help="filenames of flux files") parser.add_argument("--save", action="store_true", default=False, help="save plots") args = parser.parse_args() - if args.save: - # default \textwidth for a fullpage article in Latex is 16.50764 cm. - # You can figure this out by compiling the following TeX document: - # - # \documentclass{article} - # \usepackage{fullpage} - # \usepackage{layouts} - # \begin{document} - # textwidth in cm: \printinunitsof{cm}\prntlen{\textwidth} - # \end{document} - - width = 16.50764 - width /= 2.54 # cm -> inches - # According to this page: - # http://www-personal.umich.edu/~jpboyd/eng403_chap2_tuftegospel.pdf, - # Tufte suggests an aspect ratio of 1.5 - 1.6. - height = width/1.5 - FIGSIZE = (width,height) - - import matplotlib.pyplot as plt - - font = {'family':'serif', 'serif': ['computer modern roman']} - plt.rc('font',**font) - - plt.rc('text', usetex=True) - else: - # on retina screens, the default plots are way too small - # by using Qt5 and setting QT_AUTO_SCREEN_SCALE_FACTOR=1 - # Qt5 will scale everything using the dpi in ~/.Xresources - import matplotlib - matplotlib.use("Qt5Agg") - - import matplotlib.pyplot as plt - - # Default figure size. Currently set to my monitor width and height so that - # things are properly formatted - FIGSIZE = (13.78,7.48) - - font = {'family':'serif', 'serif': ['computer modern roman']} - plt.rc('font',**font) - - # Make the defalt font bigger - plt.rc('font', size=22) - - plt.rc('text', usetex=True) - - fig = plt.figure(figsize=FIGSIZE) + setup_matplotlib(args.save) + + import matplotlib.pyplot as plt + + fig = plt.figure() colors = plt.rcParams["axes.prop_cycle"].by_key()["color"] linestyles = ['-','--'] |