From 151e71158363dadec3c2385a94165bf95db58faf Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Fri, 23 Sep 2022 16:08:01 +0200 Subject: [PATCH] figure: toggle grid on single_beacon --- figures/beacon/src/single_beacon.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/figures/beacon/src/single_beacon.py b/figures/beacon/src/single_beacon.py index bc7af40..745522a 100755 --- a/figures/beacon/src/single_beacon.py +++ b/figures/beacon/src/single_beacon.py @@ -15,7 +15,7 @@ def ttl(t, t_start=0, frequency=1, width=0.5): return ( (t%frequency) >= t_start) & ( (t%frequency) < t_start + width) -def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rate=6, t_start=-0.3, sampling_offset_in_rate=1, ax=None, fig_kwargs={'figsize': (4,2)}, N_t=200): +def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rate=6, t_start=-0.3, sampling_offset_in_rate=1, ax=None, fig_kwargs={'figsize': (4,2)}, N_t=200, plot_grid=True): t_end = N_periods - t_start @@ -32,7 +32,7 @@ def main(beacon_type, N_periods=1, overplot_sampling_rates = False, sampling_rat raise ValueError("Unknown beacon_type requested.") ax.plot(time, sig_func(time)) - ax.grid(True) + ax.grid(plot_grid) ax.set_xlim(t_start, t_end) ax.set_ylim(-1.5, 1.5) @@ -74,6 +74,7 @@ if __name__ == "__main__": parser.add_argument('type', choices=['ttl','sine']) parser.add_argument('--periods', default=1, help='Number of periods to show', type=int) parser.add_argument('--with-rates', action='store_true', help='show two samplings with different phase') + parser.add_argument('--no-grid', dest='grid', action='store_false', help='underlie a grid') parser.add_argument("fname", metavar="path/to/figure[/]", nargs="?", help="Location for generated figure, will append __file__ if a directory. If not supplied, figure is shown.") args = parser.parse_args() @@ -82,7 +83,7 @@ if __name__ == "__main__": args.fname = path.join(args.fname, path.splitext(path.basename(__file__))[0] + ".pdf") ### - fig, _, _ = main(beacon_type=args.type, overplot_sampling_rates=args.with_rates, N_periods=args.periods) + fig, _, _ = main(beacon_type=args.type, overplot_sampling_rates=args.with_rates, N_periods=args.periods, plot_grid=args.grid) if args.fname is not None: plt.savefig(args.fname)