Mercurial > repos > muon-spectroscopy-computational-project > muspinsim_plot
view generate_plot.py @ 4:e15e8800c39e draft default tip
planemo upload for repository https://github.com/muon-spectroscopy-computational-project/muon-galaxy-tools/main/muspinsim_plot commit 70a4d37ecdf5d586703cfc509922311e95d3205c
author | muon-spectroscopy-computational-project |
---|---|
date | Tue, 18 Jul 2023 13:26:26 +0000 |
parents | 89ae4a5724a5 |
children |
line wrap: on
line source
import json import sys import matplotlib.pyplot as plt import numpy as np def main(): input_json_path = sys.argv[1] plot_params = json.load(open(input_json_path, "r")) for series in plot_params["mu_out_series"]: mu_data = np.loadtxt(series['mu_data'], usecols=(0, 1)) x, y = mu_data.T { 'line': lambda x, y, label, c, args: plt.plot(x, y, label=label, c=c, ls=args['linestyle'], lw=args['linewidth'] ), 'points': lambda x, y, label, c, args: plt.scatter(x, y, label=label, c=c, s=args['pointscale'], marker=args['pointstyle'], ) }.get(series['series_type']['type'])( x, y, series['mu_label'], series['colour'], series['series_type'] ) plt.xlabel(plot_params['xlab']) plt.ylabel(plot_params['ylab']) plt.title(plot_params['title']) plt.legend(loc="upper right") outfile = "outfile.{}".format(plot_params['out_file_type']) plt.savefig(outfile, format=plot_params['out_file_type']) if __name__ == '__main__': main()