diff --git a/README.rst b/README.rst index 571183b..67ef166 100644 --- a/README.rst +++ b/README.rst @@ -11,3 +11,25 @@ Add a new matplotlibrc file to the `rc` dir, say `myrc`, and use:: See the `showstyle.py` file for usage -- for example, note how `hist` and `scatter` grab the first color in `rcParams['axes.color_cycle']` since there's no way to set the default scatter or hist color via rcParams. + +Screenshots +----------- + +Some included styles are: + +- default + +.. image:: screenshots/default.png + +- ggplotish + +.. image:: screenshots/ggplotish.png + +- probpro + +.. image:: screenshots/probpro.png + +- rlike + +.. image:: screenshots/rlike.png + diff --git a/screenshots/default.png b/screenshots/default.png new file mode 100644 index 0000000..384e611 Binary files /dev/null and b/screenshots/default.png differ diff --git a/screenshots/ggplotish.png b/screenshots/ggplotish.png new file mode 100644 index 0000000..2218581 Binary files /dev/null and b/screenshots/ggplotish.png differ diff --git a/screenshots/probpro.png b/screenshots/probpro.png new file mode 100644 index 0000000..36fd449 Binary files /dev/null and b/screenshots/probpro.png differ diff --git a/screenshots/rlike.png b/screenshots/rlike.png new file mode 100644 index 0000000..6a41c49 Binary files /dev/null and b/screenshots/rlike.png differ diff --git a/showstyle.py b/showstyle.py index 012e29b..56042ec 100755 --- a/showstyle.py +++ b/showstyle.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python from matplotlib import pyplot as plt import matplotlib @@ -12,6 +12,7 @@ ap = argparse.ArgumentParser() ap.add_argument('style', help='Which rc file to use. One of %s' % available) ap.add_argument('--plot', default='all', help='One of [scatter, hist, line, image], or ' 'a comma-separated list of a subset. Default is all.') +ap.add_argument('-o', '--output', required=False, help='Render the plot to a file') args = ap.parse_args() matplotlib.rc_file(os.path.join(HERE, 'rc', args.style)) @@ -45,29 +46,29 @@ def histogram(ax): ax.set_title('demo plot') ax.legend(loc='best') +fig = plt.figure(figsize=(11, 8)) def image(ax): ax.imshow(np.random.random((100, 100))) - if 'line' in args.plot or args.plot == 'all': - fig = plt.figure() - ax = fig.add_subplot(111) + ax = fig.add_subplot(221) lineplot(ax) if 'scatter' in args.plot or args.plot == 'all': - fig = plt.figure() - ax = fig.add_subplot(111) + ax = fig.add_subplot(222) scatterplot(ax) if 'hist' in args.plot or args.plot == 'all': - fig = plt.figure() - ax = fig.add_subplot(111) + ax = fig.add_subplot(223) histogram(ax) if 'image' in args.plot or args.plot == 'all': - fig = plt.figure() - ax = fig.add_subplot(111) + ax = fig.add_subplot(224) image(ax) -plt.show() +plt.tight_layout() +if args.output: + plt.savefig(args.output) +else: + plt.show()