From d49696aba62820ce4bab41ae4a8508743e39a0e4 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 14 Mar 2021 14:08:50 -0700 Subject: [PATCH 01/11] New doc gallery for plot_types --- doc/_templates/layout.html | 1 + doc/conf.py | 4 +-- .../stylelib/cheatsheet_gallery.mplstyle | 28 ++++++++++++++++ plot_types/A_basic/README.rst | 6 ++++ plot_types/A_basic/a_plot.py | 23 +++++++++++++ plot_types/A_basic/b_scatter.py | 24 ++++++++++++++ plot_types/A_basic/c_bar.py | 24 ++++++++++++++ plot_types/A_basic/d_stem.py | 22 +++++++++++++ plot_types/A_basic/e_step.py | 22 +++++++++++++ plot_types/A_basic/f_pie.py | 28 ++++++++++++++++ plot_types/A_basic/g_fill_between.py | 25 ++++++++++++++ plot_types/B_arrays/README.rst | 6 ++++ plot_types/B_arrays/a_imshow.py | 25 ++++++++++++++ plot_types/B_arrays/b_pcolormesh.py | 28 ++++++++++++++++ plot_types/B_arrays/c_contourf.py | 22 +++++++++++++ plot_types/B_arrays/d_quiver.py | 24 ++++++++++++++ plot_types/B_arrays/e_streamplot.py | 25 ++++++++++++++ plot_types/C_stats/README.rst | 6 ++++ plot_types/C_stats/a_hist.py | 22 +++++++++++++ plot_types/C_stats/b_boxplot.py | 32 ++++++++++++++++++ plot_types/C_stats/c_errorbar.py | 24 ++++++++++++++ plot_types/C_stats/d_violin.py | 27 +++++++++++++++ plot_types/C_stats/e_barbs.py | 26 +++++++++++++++ plot_types/C_stats/f_eventplot.py | 24 ++++++++++++++ plot_types/C_stats/g_hist2d.py | 24 ++++++++++++++ plot_types/C_stats/h_hexbin.py | 23 +++++++++++++ plot_types/D_unstructured/README.rst | 9 +++++ plot_types/D_unstructured/a_tricontour.py | 33 +++++++++++++++++++ plot_types/D_unstructured/b_tripcolor.py | 32 ++++++++++++++++++ plot_types/D_unstructured/c_triplot.py | 28 ++++++++++++++++ plot_types/README.rst | 11 +++++++ 31 files changed, 656 insertions(+), 2 deletions(-) create mode 100644 lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle create mode 100644 plot_types/A_basic/README.rst create mode 100644 plot_types/A_basic/a_plot.py create mode 100644 plot_types/A_basic/b_scatter.py create mode 100644 plot_types/A_basic/c_bar.py create mode 100644 plot_types/A_basic/d_stem.py create mode 100644 plot_types/A_basic/e_step.py create mode 100644 plot_types/A_basic/f_pie.py create mode 100644 plot_types/A_basic/g_fill_between.py create mode 100644 plot_types/B_arrays/README.rst create mode 100644 plot_types/B_arrays/a_imshow.py create mode 100644 plot_types/B_arrays/b_pcolormesh.py create mode 100644 plot_types/B_arrays/c_contourf.py create mode 100644 plot_types/B_arrays/d_quiver.py create mode 100644 plot_types/B_arrays/e_streamplot.py create mode 100644 plot_types/C_stats/README.rst create mode 100644 plot_types/C_stats/a_hist.py create mode 100644 plot_types/C_stats/b_boxplot.py create mode 100644 plot_types/C_stats/c_errorbar.py create mode 100644 plot_types/C_stats/d_violin.py create mode 100644 plot_types/C_stats/e_barbs.py create mode 100644 plot_types/C_stats/f_eventplot.py create mode 100644 plot_types/C_stats/g_hist2d.py create mode 100644 plot_types/C_stats/h_hexbin.py create mode 100644 plot_types/D_unstructured/README.rst create mode 100644 plot_types/D_unstructured/a_tricontour.py create mode 100644 plot_types/D_unstructured/b_tripcolor.py create mode 100644 plot_types/D_unstructured/c_triplot.py create mode 100644 plot_types/README.rst diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html index 0b6f475d203d..4480acb408af 100644 --- a/doc/_templates/layout.html +++ b/doc/_templates/layout.html @@ -57,6 +57,7 @@
  • Installation
  • Documentation
  • API
  • +
  • Plot Types
  • Examples
  • Tutorials
  • Contributing
  • diff --git a/doc/conf.py b/doc/conf.py index f67dd662c0bd..24010cf06616 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -151,9 +151,9 @@ def _check_dependencies(): # Sphinx gallery configuration sphinx_gallery_conf = { - 'examples_dirs': ['../examples', '../tutorials'], + 'examples_dirs': ['../examples', '../tutorials', '../plot_types'], 'filename_pattern': '^((?!sgskip).)*$', - 'gallery_dirs': ['gallery', 'tutorials'], + 'gallery_dirs': ['gallery', 'tutorials', 'plot_types'], 'doc_module': ('matplotlib', 'mpl_toolkits'), 'reference_url': { 'matplotlib': None, diff --git a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle new file mode 100644 index 000000000000..c58ffe4dc0ee --- /dev/null +++ b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle @@ -0,0 +1,28 @@ +# from the Matplotlib cheatsheet as used in our gallery: + + +axes.facecolor: white +axes.edgecolor: black +axes.linewidth: 1.0 +axes.grid: True +axes.axisbelow: True # grid/ticks are below elements (e.g., lines, text) + +xtick.color: 555555 +xtick.direction: out + +ytick.color: 555555 +ytick.direction: out + +grid.color: b0b0b0 +grid.linewidth: 0.7 +grid.linestyle: - # solid line + +figure.facecolor: white +figure.figsize: 2, 2 +# make it so the axes labels don't show up. Obviously +# not good style for any quantitative analysis: +figure.subplot.left: 0.01 +figure.subplot.right: 0.99 +figure.subplot.bottom: 0.01 +figure.subplot.top: 0.99 + diff --git a/plot_types/A_basic/README.rst b/plot_types/A_basic/README.rst new file mode 100644 index 000000000000..45c12220a342 --- /dev/null +++ b/plot_types/A_basic/README.rst @@ -0,0 +1,6 @@ +.. _basic_plots: + +Basic +----- + +Basic plot types, usually x versus y. \ No newline at end of file diff --git a/plot_types/A_basic/a_plot.py b/plot_types/A_basic/a_plot.py new file mode 100644 index 000000000000..ff0e9ec6febb --- /dev/null +++ b/plot_types/A_basic/a_plot.py @@ -0,0 +1,23 @@ +""" +====================== +plot([X], Y, [fmt]...) +====================== +""" + +import matplotlib.pyplot as plt +import numpy as np + +# make data +X = np.linspace(0, 10, 100) +Y = 4 + 2 * np.sin(2 * X) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.plot(X, Y, color="C1", linewidth=2.0) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + + plt.show() diff --git a/plot_types/A_basic/b_scatter.py b/plot_types/A_basic/b_scatter.py new file mode 100644 index 000000000000..113d93592f53 --- /dev/null +++ b/plot_types/A_basic/b_scatter.py @@ -0,0 +1,24 @@ +""" +================== +scatter(X, Y, ...) +================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make the data +np.random.seed(3) +X = 4 + np.random.normal(0, 1.25, 24) +Y = 4 + np.random.normal(0, 1.25, len(X)) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.scatter(X, Y, 20, zorder=10, + edgecolor="none", facecolor="C1", linewidth=0.25) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + + plt.show() diff --git a/plot_types/A_basic/c_bar.py b/plot_types/A_basic/c_bar.py new file mode 100644 index 000000000000..0a68936224e3 --- /dev/null +++ b/plot_types/A_basic/c_bar.py @@ -0,0 +1,24 @@ +""" +====================== +bar[h](x, height, ...) +====================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: +np.random.seed(3) +X = 0.5 + np.arange(8) +Y = np.random.uniform(2, 7, len(X)) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.bar(X, Y, bottom=0, width=1, edgecolor="white", + facecolor="C1", linewidth=0.7) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + + plt.show() diff --git a/plot_types/A_basic/d_stem.py b/plot_types/A_basic/d_stem.py new file mode 100644 index 000000000000..ea18396ccd46 --- /dev/null +++ b/plot_types/A_basic/d_stem.py @@ -0,0 +1,22 @@ +""" +================= +stem([x], y, ...) +================= +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data +np.random.seed(3) +X = 0.5 + np.arange(8) +Y = np.random.uniform(2, 7, len(X)) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.stem(X, Y, bottom=0, linefmt="C1-", markerfmt="C1d") + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + plt.show() diff --git a/plot_types/A_basic/e_step.py b/plot_types/A_basic/e_step.py new file mode 100644 index 000000000000..8561996fd989 --- /dev/null +++ b/plot_types/A_basic/e_step.py @@ -0,0 +1,22 @@ +""" +===================== +step(x, y, where=...) +===================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data +np.random.seed(3) +X = 0.5 + np.arange(8) +Y = np.random.uniform(2, 7, len(X)) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.step(X, Y, color="C1", linewidth=2.5) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + plt.show() diff --git a/plot_types/A_basic/f_pie.py b/plot_types/A_basic/f_pie.py new file mode 100644 index 000000000000..e77ebe5d4d4b --- /dev/null +++ b/plot_types/A_basic/f_pie.py @@ -0,0 +1,28 @@ +""" +==================== +pie(X, explode, ...) +==================== +""" +import matplotlib as mpl +import matplotlib.pyplot as plt +import numpy as np + +# make data +X = [1, 2, 3, 4] +colors = np.zeros((len(X), 4)) +colors[:] = mpl.colors.to_rgba("C1") +colors[:, 3] = np.linspace(0.25, 0.75, len(X)) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4), + wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) + ax.pie(X, colors=colors, radius=3, center=(4, 4), + wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/A_basic/g_fill_between.py b/plot_types/A_basic/g_fill_between.py new file mode 100644 index 000000000000..8c5cb315bed0 --- /dev/null +++ b/plot_types/A_basic/g_fill_between.py @@ -0,0 +1,25 @@ +""" +================================= +fill[_between][x](X, Y1, Y2, ...) +================================= +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data +np.random.seed(1) +X = np.linspace(0, 8, 16) +Y1 = 3 + 4*X/8 + np.random.uniform(0.0, 0.5, len(X)) +Y2 = 1 + 2*X/8 + np.random.uniform(0.0, 0.5, len(X)) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.fill_between(X, Y1, Y2, color="C1", alpha=.5, linewidth=0) + ax.plot(X, (Y1+Y2)/2, color="C1", linewidth=2.5) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/B_arrays/README.rst b/plot_types/B_arrays/README.rst new file mode 100644 index 000000000000..a13592dbde9a --- /dev/null +++ b/plot_types/B_arrays/README.rst @@ -0,0 +1,6 @@ +.. _array_plots: + +Plots of arrays and fields +-------------------------- + +Plotting for arrays of data ``Z(x, y)`` and fields ``U(x, y), V(x, y)`` \ No newline at end of file diff --git a/plot_types/B_arrays/a_imshow.py b/plot_types/B_arrays/a_imshow.py new file mode 100644 index 000000000000..9b6c6c0b2441 --- /dev/null +++ b/plot_types/B_arrays/a_imshow.py @@ -0,0 +1,25 @@ +""" +======================= +imshow(Z, [cmap=], ...) +======================= +""" + +import matplotlib.pyplot as plt +import numpy as np + +# make data +X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) +Z = Z - Z.min() +Z = Z[::16, ::16] + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest", + cmap=plt.get_cmap('Oranges'), vmin=0, vmax=1.6) + + ax.set_xlim(0, 8), ax.set_xticks([]) + ax.set_ylim(0, 8), ax.set_yticks([]) + plt.show() diff --git a/plot_types/B_arrays/b_pcolormesh.py b/plot_types/B_arrays/b_pcolormesh.py new file mode 100644 index 000000000000..ca087a0ce6e4 --- /dev/null +++ b/plot_types/B_arrays/b_pcolormesh.py @@ -0,0 +1,28 @@ +""" +=================================== +pcolormesh([X, Y], Z, [cmap=], ...) +=================================== + +`~.axes.Axes.pcolormesh` is more flexible than `~.axes.Axes.imshow` in that +the x and y vectors need not be equally spaced (indeed they can be skewed). + +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: +np.random.seed(3) +Z = np.random.uniform(0.1, 1.0, (8, 8)) +x = np.array([0, 0.5, 1.5, 3, 5.2, 6.3, 7.2, 7.5, 8]) +y = 1.2**np.arange(0, 9) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + # plot: + ax.pcolormesh(x, y, Z, cmap=plt.get_cmap('Oranges'), vmin=0, vmax=1.1) + + ax.set_ylim(1, np.max(y)) + ax.set_xlim(np.min(x), np.max(x)) + plt.show() diff --git a/plot_types/B_arrays/c_contourf.py b/plot_types/B_arrays/c_contourf.py new file mode 100644 index 000000000000..e11f5d5065d2 --- /dev/null +++ b/plot_types/B_arrays/c_contourf.py @@ -0,0 +1,22 @@ +""" +===================================== +contour[f]([X, Y], Z, [levels=], ...) +===================================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data +X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2) +Z = Z - Z.min() +levs = np.linspace(np.min(Z), np.max(Z), 7) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + plt.contourf(X, Y, Z, levels=levs, cmap=plt.get_cmap('Oranges')) + plt.contour(X, Y, Z, levels=levs, colors="white", linewidths=0.5) + + plt.show() diff --git a/plot_types/B_arrays/d_quiver.py b/plot_types/B_arrays/d_quiver.py new file mode 100644 index 000000000000..ed359fd90915 --- /dev/null +++ b/plot_types/B_arrays/d_quiver.py @@ -0,0 +1,24 @@ +""" +========================= +quiver([X, Y], U, V, ...) +========================= +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data +T = np.linspace(0, 2*np.pi, 8) +X, Y = 4 + 1 * np.cos(T), 4 + 1 * np.sin(T) +U, V = 1.5 * np.cos(T), 1.5 * np.sin(T) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + plt.quiver(X, Y, U, V, color="C1", angles='xy', + scale_units='xy', scale=0.5, width=.05) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/B_arrays/e_streamplot.py b/plot_types/B_arrays/e_streamplot.py new file mode 100644 index 000000000000..14f9a111f3db --- /dev/null +++ b/plot_types/B_arrays/e_streamplot.py @@ -0,0 +1,25 @@ +""" +======================== +streamplot([X, Y], U, V) +======================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make a stream function: +X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) +Z = Z - Z.min() +# make U and V out of the streamfunction: +V = np.diff(Z[1:, :], axis=1) +U = -np.diff(Z[:, 1:], axis=0) + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + # contour stream function + ax.contour(X, Y, Z, colors='C0', alpha=0.5, zorder=1, linewidths=3) + # plot stream plot + ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V, color='C1', zorder=2) + +plt.show() diff --git a/plot_types/C_stats/README.rst b/plot_types/C_stats/README.rst new file mode 100644 index 000000000000..53af1c3a4a33 --- /dev/null +++ b/plot_types/C_stats/README.rst @@ -0,0 +1,6 @@ +.. _stats_plots: + +Specialized statistics plots +============================ + +Matplotlib has some specialized plots for statistical analysis. \ No newline at end of file diff --git a/plot_types/C_stats/a_hist.py b/plot_types/C_stats/a_hist.py new file mode 100644 index 000000000000..506e199267e2 --- /dev/null +++ b/plot_types/C_stats/a_hist.py @@ -0,0 +1,22 @@ +""" +======================== +hist(X, [bins],...) +======================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data +np.random.seed(1) +X = 4 + np.random.normal(0, 1.5, 200) + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.hist(X, bins=8, facecolor="C1", linewidth=0.5, edgecolor="white",) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 80), ax.set_yticks(np.arange(1, 80, 10)) + +plt.show() diff --git a/plot_types/C_stats/b_boxplot.py b/plot_types/C_stats/b_boxplot.py new file mode 100644 index 000000000000..16aedb3404aa --- /dev/null +++ b/plot_types/C_stats/b_boxplot.py @@ -0,0 +1,32 @@ +""" +============== +boxplot(X,...) +============== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: +np.random.seed(10) +D = np.random.normal((3, 5, 4), (1.25, 1.00, 1.25), (100, 3)) + +# plot +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + VP = ax.boxplot(D, positions=[2, 4, 6], widths=1.5, patch_artist=True, + showmeans=False, showfliers=False, + medianprops={"color": "white", + "linewidth": 0.5}, + boxprops={"facecolor": "C1", + "edgecolor": "white", + "linewidth": 0.5}, + whiskerprops={"color": "C1", + "linewidth": 1.5}, + capprops={"color": "C1", + "linewidth": 1.5}) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/C_stats/c_errorbar.py b/plot_types/C_stats/c_errorbar.py new file mode 100644 index 000000000000..54dde3a74e94 --- /dev/null +++ b/plot_types/C_stats/c_errorbar.py @@ -0,0 +1,24 @@ +""" +============================== +errorbar(X, Y, xerr, yerr,...) +============================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: +np.random.seed(1) +X = [2, 4, 6] +Y = [4, 5, 4] +E = np.random.uniform(0.5, 1.5, 3) + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.errorbar(X, Y, E, color="C1", linewidth=2, capsize=6) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/C_stats/d_violin.py b/plot_types/C_stats/d_violin.py new file mode 100644 index 000000000000..ad08ab658be4 --- /dev/null +++ b/plot_types/C_stats/d_violin.py @@ -0,0 +1,27 @@ +""" +================= +violinplot(D,...) +================= +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: +np.random.seed(10) +D = np.random.normal((3, 5, 4), (0.75, 1.00, 0.75), (200, 3)) + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + VP = ax.violinplot(D, [2, 4, 6], widths=2, + showmeans=False, showmedians=False, showextrema=False) + #style: + for body in VP['bodies']: + body.set_facecolor('C1') + body.set_alpha(0.9) + +ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/C_stats/e_barbs.py b/plot_types/C_stats/e_barbs.py new file mode 100644 index 000000000000..0e66a77c876b --- /dev/null +++ b/plot_types/C_stats/e_barbs.py @@ -0,0 +1,26 @@ +""" +======================== +barbs([X, Y], U, V, ...) +======================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: +np.random.seed(1) +X = [[2, 4, 6]] +Y = [[1.5, 3, 2]] +U = -np.ones((1, 3)) * 0 +V = -np.ones((1, 3)) * np.linspace(50, 100, 3) + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.barbs(X, Y, U, V, barbcolor="C1", flagcolor="C1", + length=10, linewidth=1.5) + +ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/C_stats/f_eventplot.py b/plot_types/C_stats/f_eventplot.py new file mode 100644 index 000000000000..53470412dc31 --- /dev/null +++ b/plot_types/C_stats/f_eventplot.py @@ -0,0 +1,24 @@ +""" +================= +eventplot(D, ...) +================= +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: +np.random.seed(1) +X = [2, 4, 6] +D = np.random.gamma(4, size=(3, 50)) + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.eventplot(D, colors="C1", orientation="vertical", + lineoffsets=X, linewidth=0.75) + + ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + +plt.show() diff --git a/plot_types/C_stats/g_hist2d.py b/plot_types/C_stats/g_hist2d.py new file mode 100644 index 000000000000..25ef97e77935 --- /dev/null +++ b/plot_types/C_stats/g_hist2d.py @@ -0,0 +1,24 @@ +""" +================================== +hist2d(x, y, [(xbins, ybins)],...) +================================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: correlated + noise +np.random.seed(1) +x = np.random.randn(5000) +y = 1.2 * x + np.random.randn(5000)/3 + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1)), + cmap=plt.get_cmap('Oranges')) + +ax.set_xlim(-2, 2) +ax.set_ylim(-3, 3) + +plt.show() diff --git a/plot_types/C_stats/h_hexbin.py b/plot_types/C_stats/h_hexbin.py new file mode 100644 index 000000000000..a3e8e0fd3d5e --- /dev/null +++ b/plot_types/C_stats/h_hexbin.py @@ -0,0 +1,23 @@ +""" +================================= +hexbin(x, y, [C], [gridsize],...) +================================= +""" +import matplotlib.pyplot as plt +import numpy as np + +# make data: correlated + noise +np.random.seed(1) +x = np.random.randn(5000) +y = 1.2 * x + np.random.randn(5000)/3 + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.hexbin(x, y, gridsize=20, cmap=plt.get_cmap('Oranges')) + +ax.set_xlim(-2, 2) +ax.set_ylim(-3, 3) + +plt.show() diff --git a/plot_types/D_unstructured/README.rst b/plot_types/D_unstructured/README.rst new file mode 100644 index 000000000000..80553f5ee094 --- /dev/null +++ b/plot_types/D_unstructured/README.rst @@ -0,0 +1,9 @@ +.. _unstructured_plots: + +Unstructured co-ordinates +------------------------- + +Sometimes we collect data ``z`` at coordinates ``(x,y)`` and want to visualize +as a contour. Instead of gridding the data and then using +`~.axes.Axes.contour`, we can use a triangulation algorithm and fill the +triangles. \ No newline at end of file diff --git a/plot_types/D_unstructured/a_tricontour.py b/plot_types/D_unstructured/a_tricontour.py new file mode 100644 index 000000000000..a4527301005a --- /dev/null +++ b/plot_types/D_unstructured/a_tricontour.py @@ -0,0 +1,33 @@ +""" +============================== +tripcontour(x, y, z, [levels]) +============================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make structured data +X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2) +Z = Z - Z.min() + +# sample it to make unstructured x, y, z +np.random.seed(1) +ysamp = np.random.randint(0, high=256, size=250) +xsamp = np.random.randint(0, high=256, size=250) +y = Y[:, 0][ysamp] +x = X[0, :][xsamp] +z = Z[ysamp, xsamp] + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.plot(x, y, '.k', alpha=0.5) + levs = np.linspace(np.min(Z), np.max(Z), 7) + ax.tricontourf(x, y, z, levels=levs, cmap=plt.get_cmap('Oranges')) + + ax.set_xlim(-3, 3) + ax.set_ylim(-3, 3) + + plt.show() diff --git a/plot_types/D_unstructured/b_tripcolor.py b/plot_types/D_unstructured/b_tripcolor.py new file mode 100644 index 000000000000..b4118c446e99 --- /dev/null +++ b/plot_types/D_unstructured/b_tripcolor.py @@ -0,0 +1,32 @@ +""" +================== +tripcolor(x, y, z) +================== +""" +import matplotlib.pyplot as plt +import numpy as np + +# make structured data +X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2) +Z = Z - Z.min() + +# sample it to make unstructured x, y, z +np.random.seed(1) +ysamp = np.random.randint(0, high=256, size=250) +xsamp = np.random.randint(0, high=256, size=250) +y = Y[:, 0][ysamp] +x = X[0, :][xsamp] +z = Z[ysamp, xsamp] + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.plot(x, y, '.k', alpha=0.5) + ax.tripcolor(x, y, z, cmap=plt.get_cmap('Oranges')) + + ax.set_xlim(-3, 3) + ax.set_ylim(-3, 3) + + plt.show() diff --git a/plot_types/D_unstructured/c_triplot.py b/plot_types/D_unstructured/c_triplot.py new file mode 100644 index 000000000000..7ee181acb263 --- /dev/null +++ b/plot_types/D_unstructured/c_triplot.py @@ -0,0 +1,28 @@ +""" +========================= +triplot(x, y, [triangle]) +========================= +""" +import matplotlib.pyplot as plt +import numpy as np + +# make structured data +X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) + +# sample it to make x, y, z +np.random.seed(1) +ysamp = np.random.randint(0, high=256, size=250) +xsamp = np.random.randint(0, high=256, size=250) +y = Y[:, 0][ysamp] +x = X[0, :][xsamp] + +# plot: +with plt.style.context('cheatsheet_gallery'): + fig, ax = plt.subplots() + + ax.triplot(x, y, color='C1') + + ax.set_xlim(-3, 3) + ax.set_ylim(-3, 3) + + plt.show() diff --git a/plot_types/README.rst b/plot_types/README.rst new file mode 100644 index 000000000000..c9ab1071311e --- /dev/null +++ b/plot_types/README.rst @@ -0,0 +1,11 @@ +.. _plot_types: + +Plot types +========== + +This gallery lists many of the plotting commands in Matplotlib, +(but not all of them!). + +Note that we have stripped all labels, but they are present by default. +See the `gallery <../gallery/index.html>`_ for many more examples and +the `tutorials page <../tutorials/index.html>`_ for longer examples. \ No newline at end of file From 90fad32114b9f1d6abb34c927d67b6e9c976bc8d Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 16 Mar 2021 13:56:43 -0700 Subject: [PATCH 02/11] FIX: made style smaller, fixed formatting, changed cycle order --- .../stylelib/cheatsheet_gallery.mplstyle | 20 ++++--------------- plot_types/A_basic/a_plot.py | 9 +++++---- plot_types/A_basic/b_scatter.py | 8 +++++--- plot_types/A_basic/c_bar.py | 9 +++++---- plot_types/A_basic/d_stem.py | 8 +++++--- plot_types/A_basic/e_step.py | 8 +++++--- plot_types/A_basic/f_pie.py | 17 +++++++++------- plot_types/A_basic/g_fill_between.py | 10 ++++++---- plot_types/B_arrays/a_imshow.py | 4 ++-- plot_types/B_arrays/b_pcolormesh.py | 15 +++++++------- plot_types/B_arrays/c_contourf.py | 2 +- plot_types/B_arrays/d_quiver.py | 8 +++++--- plot_types/B_arrays/e_streamplot.py | 4 ++-- plot_types/C_stats/a_hist.py | 8 +++++--- plot_types/C_stats/b_boxplot.py | 14 +++++++------ plot_types/C_stats/c_errorbar.py | 6 ++++-- plot_types/C_stats/d_violin.py | 7 ++++--- plot_types/C_stats/e_barbs.py | 6 ++++-- plot_types/C_stats/f_eventplot.py | 8 +++++--- plot_types/C_stats/g_hist2d.py | 3 +-- plot_types/C_stats/h_hexbin.py | 2 +- plot_types/D_unstructured/a_tricontour.py | 2 +- plot_types/D_unstructured/b_tripcolor.py | 2 +- plot_types/D_unstructured/c_triplot.py | 2 +- 24 files changed, 97 insertions(+), 85 deletions(-) diff --git a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle index c58ffe4dc0ee..c9d42e94b90a 100644 --- a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle @@ -1,23 +1,8 @@ # from the Matplotlib cheatsheet as used in our gallery: - -axes.facecolor: white -axes.edgecolor: black -axes.linewidth: 1.0 axes.grid: True -axes.axisbelow: True # grid/ticks are below elements (e.g., lines, text) - -xtick.color: 555555 -xtick.direction: out - -ytick.color: 555555 -ytick.direction: out - -grid.color: b0b0b0 -grid.linewidth: 0.7 -grid.linestyle: - # solid line +axes.axisbelow: True -figure.facecolor: white figure.figsize: 2, 2 # make it so the axes labels don't show up. Obviously # not good style for any quantitative analysis: @@ -26,3 +11,6 @@ figure.subplot.right: 0.99 figure.subplot.bottom: 0.01 figure.subplot.top: 0.99 +# colors: +image.cmap : Oranges +axes.prop_cycle : cycler('color', ['ff7f0e', '1f77b4', '2ca02c']) \ No newline at end of file diff --git a/plot_types/A_basic/a_plot.py b/plot_types/A_basic/a_plot.py index ff0e9ec6febb..f3ac195c9743 100644 --- a/plot_types/A_basic/a_plot.py +++ b/plot_types/A_basic/a_plot.py @@ -15,9 +15,10 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.plot(X, Y, color="C1", linewidth=2.0) - - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.plot(X, Y, linewidth=2.0) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/A_basic/b_scatter.py b/plot_types/A_basic/b_scatter.py index 113d93592f53..ed1998ce617c 100644 --- a/plot_types/A_basic/b_scatter.py +++ b/plot_types/A_basic/b_scatter.py @@ -16,9 +16,11 @@ fig, ax = plt.subplots() ax.scatter(X, Y, 20, zorder=10, - edgecolor="none", facecolor="C1", linewidth=0.25) + edgecolor="none", linewidth=0.25) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/A_basic/c_bar.py b/plot_types/A_basic/c_bar.py index 0a68936224e3..e3d9fdb20497 100644 --- a/plot_types/A_basic/c_bar.py +++ b/plot_types/A_basic/c_bar.py @@ -15,10 +15,11 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.bar(X, Y, bottom=0, width=1, edgecolor="white", - facecolor="C1", linewidth=0.7) + ax.bar(X, Y, bottom=0, width=1, edgecolor="white", linewidth=0.7) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/A_basic/d_stem.py b/plot_types/A_basic/d_stem.py index ea18396ccd46..27cf5f6d4df8 100644 --- a/plot_types/A_basic/d_stem.py +++ b/plot_types/A_basic/d_stem.py @@ -15,8 +15,10 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.stem(X, Y, bottom=0, linefmt="C1-", markerfmt="C1d") + ax.stem(X, Y, bottom=0, linefmt="-", markerfmt="d") - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/A_basic/e_step.py b/plot_types/A_basic/e_step.py index 8561996fd989..734ee3c42d38 100644 --- a/plot_types/A_basic/e_step.py +++ b/plot_types/A_basic/e_step.py @@ -15,8 +15,10 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.step(X, Y, color="C1", linewidth=2.5) + ax.step(X, Y, linewidth=2.5) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/A_basic/f_pie.py b/plot_types/A_basic/f_pie.py index e77ebe5d4d4b..4c73f2c38a5c 100644 --- a/plot_types/A_basic/f_pie.py +++ b/plot_types/A_basic/f_pie.py @@ -7,22 +7,25 @@ import matplotlib.pyplot as plt import numpy as np -# make data -X = [1, 2, 3, 4] -colors = np.zeros((len(X), 4)) -colors[:] = mpl.colors.to_rgba("C1") -colors[:, 3] = np.linspace(0.25, 0.75, len(X)) # plot with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() + + # make data + X = [1, 2, 3, 4] + colors = np.zeros((len(X), 4)) + colors[:] = mpl.colors.to_rgba("C0") + colors[:, 3] = np.linspace(0.25, 0.75, len(X)) ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4), wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) ax.pie(X, colors=colors, radius=3, center=(4, 4), wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/A_basic/g_fill_between.py b/plot_types/A_basic/g_fill_between.py index 8c5cb315bed0..18cebef16cac 100644 --- a/plot_types/A_basic/g_fill_between.py +++ b/plot_types/A_basic/g_fill_between.py @@ -16,10 +16,12 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.fill_between(X, Y1, Y2, color="C1", alpha=.5, linewidth=0) - ax.plot(X, (Y1+Y2)/2, color="C1", linewidth=2.5) + ax.fill_between(X, Y1, Y2, alpha=.5, linewidth=0) + ax.plot(X, (Y1+Y2)/2, linewidth=2.5) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/B_arrays/a_imshow.py b/plot_types/B_arrays/a_imshow.py index 9b6c6c0b2441..5a92a44d9d5e 100644 --- a/plot_types/B_arrays/a_imshow.py +++ b/plot_types/B_arrays/a_imshow.py @@ -20,6 +20,6 @@ ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest", cmap=plt.get_cmap('Oranges'), vmin=0, vmax=1.6) - ax.set_xlim(0, 8), ax.set_xticks([]) - ax.set_ylim(0, 8), ax.set_yticks([]) + ax.set_xticks([]) + ax.set_yticks([]) plt.show() diff --git a/plot_types/B_arrays/b_pcolormesh.py b/plot_types/B_arrays/b_pcolormesh.py index ca087a0ce6e4..38e7446b07e1 100644 --- a/plot_types/B_arrays/b_pcolormesh.py +++ b/plot_types/B_arrays/b_pcolormesh.py @@ -10,19 +10,18 @@ import matplotlib.pyplot as plt import numpy as np -# make data: -np.random.seed(3) -Z = np.random.uniform(0.1, 1.0, (8, 8)) -x = np.array([0, 0.5, 1.5, 3, 5.2, 6.3, 7.2, 7.5, 8]) -y = 1.2**np.arange(0, 9) +# make data +X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) +Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) +Z = Z - Z.min() # plot with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() # plot: - ax.pcolormesh(x, y, Z, cmap=plt.get_cmap('Oranges'), vmin=0, vmax=1.1) + ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.1) - ax.set_ylim(1, np.max(y)) - ax.set_xlim(np.min(x), np.max(x)) + #ax.set_ylim(np.min(Y), np.max(Y)) + #ax.set_xlim(np.min(X), np.max(X)) plt.show() diff --git a/plot_types/B_arrays/c_contourf.py b/plot_types/B_arrays/c_contourf.py index e11f5d5065d2..1cc7bd526a44 100644 --- a/plot_types/B_arrays/c_contourf.py +++ b/plot_types/B_arrays/c_contourf.py @@ -16,7 +16,7 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - plt.contourf(X, Y, Z, levels=levs, cmap=plt.get_cmap('Oranges')) + plt.contourf(X, Y, Z, levels=levs) plt.contour(X, Y, Z, levels=levs, colors="white", linewidths=0.5) plt.show() diff --git a/plot_types/B_arrays/d_quiver.py b/plot_types/B_arrays/d_quiver.py index ed359fd90915..b28c18f2bd4a 100644 --- a/plot_types/B_arrays/d_quiver.py +++ b/plot_types/B_arrays/d_quiver.py @@ -15,10 +15,12 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - plt.quiver(X, Y, U, V, color="C1", angles='xy', + plt.quiver(X, Y, U, V, color="C0", angles='xy', scale_units='xy', scale=0.5, width=.05) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/B_arrays/e_streamplot.py b/plot_types/B_arrays/e_streamplot.py index 14f9a111f3db..bc667b963ae7 100644 --- a/plot_types/B_arrays/e_streamplot.py +++ b/plot_types/B_arrays/e_streamplot.py @@ -18,8 +18,8 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() # contour stream function - ax.contour(X, Y, Z, colors='C0', alpha=0.5, zorder=1, linewidths=3) + ax.contour(X, Y, Z, colors='C1', alpha=0.5, zorder=1, linewidths=3) # plot stream plot - ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V, color='C1', zorder=2) + ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V, zorder=2) plt.show() diff --git a/plot_types/C_stats/a_hist.py b/plot_types/C_stats/a_hist.py index 506e199267e2..80e526bd039c 100644 --- a/plot_types/C_stats/a_hist.py +++ b/plot_types/C_stats/a_hist.py @@ -14,9 +14,11 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.hist(X, bins=8, facecolor="C1", linewidth=0.5, edgecolor="white",) + ax.hist(X, bins=8, linewidth=0.5, edgecolor="white",) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 80), ax.set_yticks(np.arange(1, 80, 10)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 80) + ax.set_yticks(np.arange(1, 80, 10)) plt.show() diff --git a/plot_types/C_stats/b_boxplot.py b/plot_types/C_stats/b_boxplot.py index 16aedb3404aa..a53a687834b1 100644 --- a/plot_types/C_stats/b_boxplot.py +++ b/plot_types/C_stats/b_boxplot.py @@ -13,20 +13,22 @@ # plot with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - + orange = '#ff7f0e' VP = ax.boxplot(D, positions=[2, 4, 6], widths=1.5, patch_artist=True, showmeans=False, showfliers=False, medianprops={"color": "white", "linewidth": 0.5}, - boxprops={"facecolor": "C1", + boxprops={"facecolor": orange, "edgecolor": "white", "linewidth": 0.5}, - whiskerprops={"color": "C1", + whiskerprops={"color": orange, "linewidth": 1.5}, - capprops={"color": "C1", + capprops={"color": orange, "linewidth": 1.5}) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/C_stats/c_errorbar.py b/plot_types/C_stats/c_errorbar.py index 54dde3a74e94..2349b0364268 100644 --- a/plot_types/C_stats/c_errorbar.py +++ b/plot_types/C_stats/c_errorbar.py @@ -18,7 +18,9 @@ ax.errorbar(X, Y, E, color="C1", linewidth=2, capsize=6) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/C_stats/d_violin.py b/plot_types/C_stats/d_violin.py index ad08ab658be4..5ea562eac3a6 100644 --- a/plot_types/C_stats/d_violin.py +++ b/plot_types/C_stats/d_violin.py @@ -18,10 +18,11 @@ showmeans=False, showmedians=False, showextrema=False) #style: for body in VP['bodies']: - body.set_facecolor('C1') body.set_alpha(0.9) -ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) -ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/C_stats/e_barbs.py b/plot_types/C_stats/e_barbs.py index 0e66a77c876b..490e5568d4ff 100644 --- a/plot_types/C_stats/e_barbs.py +++ b/plot_types/C_stats/e_barbs.py @@ -20,7 +20,9 @@ ax.barbs(X, Y, U, V, barbcolor="C1", flagcolor="C1", length=10, linewidth=1.5) -ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) -ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/C_stats/f_eventplot.py b/plot_types/C_stats/f_eventplot.py index 53470412dc31..2561992e0895 100644 --- a/plot_types/C_stats/f_eventplot.py +++ b/plot_types/C_stats/f_eventplot.py @@ -15,10 +15,12 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.eventplot(D, colors="C1", orientation="vertical", + ax.eventplot(D, colors="C0", orientation="vertical", lineoffsets=X, linewidth=0.75) - ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) plt.show() diff --git a/plot_types/C_stats/g_hist2d.py b/plot_types/C_stats/g_hist2d.py index 25ef97e77935..a7798cd9e70c 100644 --- a/plot_types/C_stats/g_hist2d.py +++ b/plot_types/C_stats/g_hist2d.py @@ -15,8 +15,7 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1)), - cmap=plt.get_cmap('Oranges')) + ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1))) ax.set_xlim(-2, 2) ax.set_ylim(-3, 3) diff --git a/plot_types/C_stats/h_hexbin.py b/plot_types/C_stats/h_hexbin.py index a3e8e0fd3d5e..1c41f4815f1c 100644 --- a/plot_types/C_stats/h_hexbin.py +++ b/plot_types/C_stats/h_hexbin.py @@ -15,7 +15,7 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.hexbin(x, y, gridsize=20, cmap=plt.get_cmap('Oranges')) + ax.hexbin(x, y, gridsize=20) ax.set_xlim(-2, 2) ax.set_ylim(-3, 3) diff --git a/plot_types/D_unstructured/a_tricontour.py b/plot_types/D_unstructured/a_tricontour.py index a4527301005a..966b3cd84308 100644 --- a/plot_types/D_unstructured/a_tricontour.py +++ b/plot_types/D_unstructured/a_tricontour.py @@ -25,7 +25,7 @@ ax.plot(x, y, '.k', alpha=0.5) levs = np.linspace(np.min(Z), np.max(Z), 7) - ax.tricontourf(x, y, z, levels=levs, cmap=plt.get_cmap('Oranges')) + ax.tricontourf(x, y, z, levels=levs) ax.set_xlim(-3, 3) ax.set_ylim(-3, 3) diff --git a/plot_types/D_unstructured/b_tripcolor.py b/plot_types/D_unstructured/b_tripcolor.py index b4118c446e99..1ab66801912a 100644 --- a/plot_types/D_unstructured/b_tripcolor.py +++ b/plot_types/D_unstructured/b_tripcolor.py @@ -24,7 +24,7 @@ fig, ax = plt.subplots() ax.plot(x, y, '.k', alpha=0.5) - ax.tripcolor(x, y, z, cmap=plt.get_cmap('Oranges')) + ax.tripcolor(x, y, z) ax.set_xlim(-3, 3) ax.set_ylim(-3, 3) diff --git a/plot_types/D_unstructured/c_triplot.py b/plot_types/D_unstructured/c_triplot.py index 7ee181acb263..6c9a017f8d87 100644 --- a/plot_types/D_unstructured/c_triplot.py +++ b/plot_types/D_unstructured/c_triplot.py @@ -20,7 +20,7 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.triplot(x, y, color='C1') + ax.triplot(x, y) ax.set_xlim(-3, 3) ax.set_ylim(-3, 3) From 42df67e2b1954db9603cb18d5eb72fb12dc22599 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 16 Mar 2021 14:33:02 -0700 Subject: [PATCH 03/11] FIX: make pcolormesh sample unevenly --- .../mpl-data/stylelib/cheatsheet_gallery.mplstyle | 2 +- plot_types/A_basic/f_pie.py | 5 ++--- plot_types/B_arrays/b_pcolormesh.py | 15 ++++++++++----- plot_types/B_arrays/d_quiver.py | 2 +- plot_types/B_arrays/e_streamplot.py | 2 +- plot_types/C_stats/a_hist.py | 2 +- plot_types/C_stats/b_boxplot.py | 9 ++++----- plot_types/C_stats/c_errorbar.py | 4 ++-- plot_types/C_stats/d_violin.py | 11 ++++++----- plot_types/C_stats/f_eventplot.py | 5 ++--- plot_types/C_stats/g_hist2d.py | 6 +++--- plot_types/C_stats/h_hexbin.py | 6 +++--- 12 files changed, 36 insertions(+), 33 deletions(-) diff --git a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle index c9d42e94b90a..5abd2c5a7344 100644 --- a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle @@ -13,4 +13,4 @@ figure.subplot.top: 0.99 # colors: image.cmap : Oranges -axes.prop_cycle : cycler('color', ['ff7f0e', '1f77b4', '2ca02c']) \ No newline at end of file +axes.prop_cycle: cycler('color', ['FF7F0E', '1F77B4', '2CA02C']) diff --git a/plot_types/A_basic/f_pie.py b/plot_types/A_basic/f_pie.py index 4c73f2c38a5c..0464b7d7d1e2 100644 --- a/plot_types/A_basic/f_pie.py +++ b/plot_types/A_basic/f_pie.py @@ -7,11 +7,10 @@ import matplotlib.pyplot as plt import numpy as np - # plot with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - + # make data X = [1, 2, 3, 4] colors = np.zeros((len(X), 4)) @@ -28,4 +27,4 @@ ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() diff --git a/plot_types/B_arrays/b_pcolormesh.py b/plot_types/B_arrays/b_pcolormesh.py index 38e7446b07e1..d1a3f32a92fb 100644 --- a/plot_types/B_arrays/b_pcolormesh.py +++ b/plot_types/B_arrays/b_pcolormesh.py @@ -10,18 +10,23 @@ import matplotlib.pyplot as plt import numpy as np -# make data +# make full-res data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) Z = Z - Z.min() +# sample unevenly in x: +dx = np.sqrt((np.arange(16) - 8)**2) + 6 +dx = np.floor(dx / sum(dx) * 255) +xint = np.cumsum(dx).astype('int') +X = X[0, xint] +Y = Y[::8, 0] +Z = Z[::8, :][:, xint] + # plot with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() # plot: - ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.1) - - #ax.set_ylim(np.min(Y), np.max(Y)) - #ax.set_xlim(np.min(X), np.max(X)) + ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5) plt.show() diff --git a/plot_types/B_arrays/d_quiver.py b/plot_types/B_arrays/d_quiver.py index b28c18f2bd4a..aaf35f14e84a 100644 --- a/plot_types/B_arrays/d_quiver.py +++ b/plot_types/B_arrays/d_quiver.py @@ -23,4 +23,4 @@ ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() diff --git a/plot_types/B_arrays/e_streamplot.py b/plot_types/B_arrays/e_streamplot.py index bc667b963ae7..5d8ba13281b1 100644 --- a/plot_types/B_arrays/e_streamplot.py +++ b/plot_types/B_arrays/e_streamplot.py @@ -22,4 +22,4 @@ # plot stream plot ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V, zorder=2) -plt.show() + plt.show() diff --git a/plot_types/C_stats/a_hist.py b/plot_types/C_stats/a_hist.py index 80e526bd039c..380555abda34 100644 --- a/plot_types/C_stats/a_hist.py +++ b/plot_types/C_stats/a_hist.py @@ -21,4 +21,4 @@ ax.set_ylim(0, 80) ax.set_yticks(np.arange(1, 80, 10)) -plt.show() + plt.show() diff --git a/plot_types/C_stats/b_boxplot.py b/plot_types/C_stats/b_boxplot.py index a53a687834b1..9257d220f1d9 100644 --- a/plot_types/C_stats/b_boxplot.py +++ b/plot_types/C_stats/b_boxplot.py @@ -13,17 +13,16 @@ # plot with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - orange = '#ff7f0e' VP = ax.boxplot(D, positions=[2, 4, 6], widths=1.5, patch_artist=True, showmeans=False, showfliers=False, medianprops={"color": "white", "linewidth": 0.5}, - boxprops={"facecolor": orange, + boxprops={"facecolor": "C0", "edgecolor": "white", "linewidth": 0.5}, - whiskerprops={"color": orange, + whiskerprops={"color": "C0", "linewidth": 1.5}, - capprops={"color": orange, + capprops={"color": "C0", "linewidth": 1.5}) ax.set_xlim(0, 8) @@ -31,4 +30,4 @@ ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() diff --git a/plot_types/C_stats/c_errorbar.py b/plot_types/C_stats/c_errorbar.py index 2349b0364268..cc20faf2805a 100644 --- a/plot_types/C_stats/c_errorbar.py +++ b/plot_types/C_stats/c_errorbar.py @@ -16,11 +16,11 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.errorbar(X, Y, E, color="C1", linewidth=2, capsize=6) + ax.errorbar(X, Y, E, linewidth=2, capsize=6) ax.set_xlim(0, 8) ax.set_xticks(np.arange(1, 8)) ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() diff --git a/plot_types/C_stats/d_violin.py b/plot_types/C_stats/d_violin.py index 5ea562eac3a6..3bfd73500751 100644 --- a/plot_types/C_stats/d_violin.py +++ b/plot_types/C_stats/d_violin.py @@ -18,11 +18,12 @@ showmeans=False, showmedians=False, showextrema=False) #style: for body in VP['bodies']: + body.set_alpha(0.9) -ax.set_xlim(0, 8) -ax.set_xticks(np.arange(1, 8)) -ax.set_ylim(0, 8) -ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() diff --git a/plot_types/C_stats/f_eventplot.py b/plot_types/C_stats/f_eventplot.py index 2561992e0895..3f9e744650bc 100644 --- a/plot_types/C_stats/f_eventplot.py +++ b/plot_types/C_stats/f_eventplot.py @@ -15,12 +15,11 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.eventplot(D, colors="C0", orientation="vertical", - lineoffsets=X, linewidth=0.75) + ax.eventplot(D, orientation="vertical", lineoffsets=X, linewidth=0.75) ax.set_xlim(0, 8) ax.set_xticks(np.arange(1, 8)) ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() diff --git a/plot_types/C_stats/g_hist2d.py b/plot_types/C_stats/g_hist2d.py index a7798cd9e70c..7b382af885fe 100644 --- a/plot_types/C_stats/g_hist2d.py +++ b/plot_types/C_stats/g_hist2d.py @@ -17,7 +17,7 @@ ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1))) -ax.set_xlim(-2, 2) -ax.set_ylim(-3, 3) + ax.set_xlim(-2, 2) + ax.set_ylim(-3, 3) -plt.show() + plt.show() diff --git a/plot_types/C_stats/h_hexbin.py b/plot_types/C_stats/h_hexbin.py index 1c41f4815f1c..67158eb57efd 100644 --- a/plot_types/C_stats/h_hexbin.py +++ b/plot_types/C_stats/h_hexbin.py @@ -17,7 +17,7 @@ ax.hexbin(x, y, gridsize=20) -ax.set_xlim(-2, 2) -ax.set_ylim(-3, 3) + ax.set_xlim(-2, 2) + ax.set_ylim(-3, 3) -plt.show() + plt.show() From 7b79ba4ac2c000d580f6817e6a347de81711a905 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 16 Mar 2021 15:33:32 -0700 Subject: [PATCH 04/11] FIX: make pcolormesh sample unevenly --- plot_types/A_basic/b_scatter.py | 1 - plot_types/A_basic/c_bar.py | 1 - plot_types/A_basic/g_fill_between.py | 2 +- plot_types/B_arrays/b_pcolormesh.py | 4 ++-- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/plot_types/A_basic/b_scatter.py b/plot_types/A_basic/b_scatter.py index ed1998ce617c..ed92c5361d1e 100644 --- a/plot_types/A_basic/b_scatter.py +++ b/plot_types/A_basic/b_scatter.py @@ -22,5 +22,4 @@ ax.set_xticks(np.arange(1, 8)) ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) - plt.show() diff --git a/plot_types/A_basic/c_bar.py b/plot_types/A_basic/c_bar.py index e3d9fdb20497..03f98fd183e1 100644 --- a/plot_types/A_basic/c_bar.py +++ b/plot_types/A_basic/c_bar.py @@ -21,5 +21,4 @@ ax.set_xticks(np.arange(1, 8)) ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) - plt.show() diff --git a/plot_types/A_basic/g_fill_between.py b/plot_types/A_basic/g_fill_between.py index 18cebef16cac..662adff05e50 100644 --- a/plot_types/A_basic/g_fill_between.py +++ b/plot_types/A_basic/g_fill_between.py @@ -24,4 +24,4 @@ ax.set_ylim(0, 8) ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() diff --git a/plot_types/B_arrays/b_pcolormesh.py b/plot_types/B_arrays/b_pcolormesh.py index d1a3f32a92fb..decf5634a4c5 100644 --- a/plot_types/B_arrays/b_pcolormesh.py +++ b/plot_types/B_arrays/b_pcolormesh.py @@ -27,6 +27,6 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - # plot: - ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5) + ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5, shading='nearest') + plt.show() From f3a5b2778c5963a24d3f7cbc1ae0fc757d77a661 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 16 Mar 2021 21:17:09 -0700 Subject: [PATCH 05/11] Blues --- .../mpl-data/stylelib/cheatsheet_gallery.mplstyle | 4 ++-- plot_types/B_arrays/a_imshow.py | 2 +- plot_types/C_stats/e_barbs.py | 12 ++++++------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle index 5abd2c5a7344..3053e4209ee5 100644 --- a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle @@ -12,5 +12,5 @@ figure.subplot.bottom: 0.01 figure.subplot.top: 0.99 # colors: -image.cmap : Oranges -axes.prop_cycle: cycler('color', ['FF7F0E', '1F77B4', '2CA02C']) +image.cmap : Blues +# axes.prop_cycle: cycler('color', ['FF7F0E', '1F77B4', '2CA02C']) diff --git a/plot_types/B_arrays/a_imshow.py b/plot_types/B_arrays/a_imshow.py index 5a92a44d9d5e..88691b59b513 100644 --- a/plot_types/B_arrays/a_imshow.py +++ b/plot_types/B_arrays/a_imshow.py @@ -18,7 +18,7 @@ fig, ax = plt.subplots() ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest", - cmap=plt.get_cmap('Oranges'), vmin=0, vmax=1.6) + cmap=plt.get_cmap('Blues'), vmin=0, vmax=1.6) ax.set_xticks([]) ax.set_yticks([]) diff --git a/plot_types/C_stats/e_barbs.py b/plot_types/C_stats/e_barbs.py index 490e5568d4ff..80ea1a70816a 100644 --- a/plot_types/C_stats/e_barbs.py +++ b/plot_types/C_stats/e_barbs.py @@ -17,12 +17,12 @@ with plt.style.context('cheatsheet_gallery'): fig, ax = plt.subplots() - ax.barbs(X, Y, U, V, barbcolor="C1", flagcolor="C1", + ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", length=10, linewidth=1.5) -ax.set_xlim(0, 8) -ax.set_xticks(np.arange(1, 8)) -ax.set_ylim(0, 8) -ax.set_yticks(np.arange(1, 8)) + ax.set_xlim(0, 8) + ax.set_xticks(np.arange(1, 8)) + ax.set_ylim(0, 8) + ax.set_yticks(np.arange(1, 8)) -plt.show() + plt.show() From aec15b09694dc812fc502769ec10d6eec5ec1b1c Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Tue, 16 Mar 2021 21:25:21 -0700 Subject: [PATCH 06/11] No context manager --- plot_types/A_basic/a_plot.py | 17 ++++++----- plot_types/A_basic/b_scatter.py | 19 ++++++------ plot_types/A_basic/c_bar.py | 16 +++++----- plot_types/A_basic/d_stem.py | 17 ++++++----- plot_types/A_basic/e_step.py | 17 ++++++----- plot_types/A_basic/f_pie.py | 35 ++++++++++----------- plot_types/A_basic/g_fill_between.py | 19 ++++++------ plot_types/B_arrays/a_imshow.py | 15 ++++----- plot_types/B_arrays/b_pcolormesh.py | 9 +++--- plot_types/B_arrays/c_contourf.py | 11 ++++--- plot_types/B_arrays/d_quiver.py | 19 ++++++------ plot_types/B_arrays/e_streamplot.py | 15 ++++----- plot_types/C_stats/a_hist.py | 17 ++++++----- plot_types/C_stats/b_boxplot.py | 37 ++++++++++++----------- plot_types/C_stats/c_errorbar.py | 17 ++++++----- plot_types/C_stats/d_violin.py | 26 ++++++++-------- plot_types/C_stats/e_barbs.py | 19 ++++++------ plot_types/C_stats/f_eventplot.py | 17 ++++++----- plot_types/C_stats/g_hist2d.py | 13 ++++---- plot_types/C_stats/h_hexbin.py | 13 ++++---- plot_types/D_unstructured/a_tricontour.py | 17 ++++++----- plot_types/D_unstructured/b_tripcolor.py | 15 ++++----- plot_types/D_unstructured/c_triplot.py | 13 ++++---- 23 files changed, 217 insertions(+), 196 deletions(-) diff --git a/plot_types/A_basic/a_plot.py b/plot_types/A_basic/a_plot.py index f3ac195c9743..eef676790b43 100644 --- a/plot_types/A_basic/a_plot.py +++ b/plot_types/A_basic/a_plot.py @@ -7,18 +7,19 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data X = np.linspace(0, 10, 100) Y = 4 + 2 * np.sin(2 * X) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.plot(X, Y, linewidth=2.0) +ax.plot(X, Y, linewidth=2.0) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) - plt.show() +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) +plt.show() diff --git a/plot_types/A_basic/b_scatter.py b/plot_types/A_basic/b_scatter.py index ed92c5361d1e..768b1fc01001 100644 --- a/plot_types/A_basic/b_scatter.py +++ b/plot_types/A_basic/b_scatter.py @@ -6,20 +6,21 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make the data np.random.seed(3) X = 4 + np.random.normal(0, 1.25, 24) Y = 4 + np.random.normal(0, 1.25, len(X)) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.scatter(X, Y, 20, zorder=10, - edgecolor="none", linewidth=0.25) +ax.scatter(X, Y, 20, zorder=10, + edgecolor="none", linewidth=0.25) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) - plt.show() +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) +plt.show() diff --git a/plot_types/A_basic/c_bar.py b/plot_types/A_basic/c_bar.py index 03f98fd183e1..b0c74815a5b5 100644 --- a/plot_types/A_basic/c_bar.py +++ b/plot_types/A_basic/c_bar.py @@ -5,6 +5,7 @@ """ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') # make data: np.random.seed(3) @@ -12,13 +13,12 @@ Y = np.random.uniform(2, 7, len(X)) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.bar(X, Y, bottom=0, width=1, edgecolor="white", linewidth=0.7) +ax.bar(X, Y, bottom=0, width=1, edgecolor="white", linewidth=0.7) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) - plt.show() +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) +plt.show() diff --git a/plot_types/A_basic/d_stem.py b/plot_types/A_basic/d_stem.py index 27cf5f6d4df8..9d11d12023fd 100644 --- a/plot_types/A_basic/d_stem.py +++ b/plot_types/A_basic/d_stem.py @@ -6,19 +6,20 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data np.random.seed(3) X = 0.5 + np.arange(8) Y = np.random.uniform(2, 7, len(X)) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.stem(X, Y, bottom=0, linefmt="-", markerfmt="d") +ax.stem(X, Y, bottom=0, linefmt="-", markerfmt="d") - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) - plt.show() +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) +plt.show() diff --git a/plot_types/A_basic/e_step.py b/plot_types/A_basic/e_step.py index 734ee3c42d38..edd2ba0c8373 100644 --- a/plot_types/A_basic/e_step.py +++ b/plot_types/A_basic/e_step.py @@ -6,19 +6,20 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data np.random.seed(3) X = 0.5 + np.arange(8) Y = np.random.uniform(2, 7, len(X)) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.step(X, Y, linewidth=2.5) +ax.step(X, Y, linewidth=2.5) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) - plt.show() +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) +plt.show() diff --git a/plot_types/A_basic/f_pie.py b/plot_types/A_basic/f_pie.py index 0464b7d7d1e2..cb83e38eb114 100644 --- a/plot_types/A_basic/f_pie.py +++ b/plot_types/A_basic/f_pie.py @@ -7,24 +7,25 @@ import matplotlib.pyplot as plt import numpy as np -# plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +plt.style.use('cheatsheet_gallery') + - # make data - X = [1, 2, 3, 4] - colors = np.zeros((len(X), 4)) - colors[:] = mpl.colors.to_rgba("C0") - colors[:, 3] = np.linspace(0.25, 0.75, len(X)) +# make data +X = [1, 2, 3, 4] +colors = np.zeros((len(X), 4)) +colors[:] = mpl.colors.to_rgba("C0") +colors[:, 3] = np.linspace(0.25, 0.75, len(X)) - ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4), - wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) - ax.pie(X, colors=colors, radius=3, center=(4, 4), - wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) +# plot +fig, ax = plt.subplots() +ax.pie(X, colors=["white"]*len(X), radius=3, center=(4, 4), + wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) +ax.pie(X, colors=colors, radius=3, center=(4, 4), + wedgeprops={"linewidth": 1, "edgecolor": "white"}, frame=True) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/A_basic/g_fill_between.py b/plot_types/A_basic/g_fill_between.py index 662adff05e50..43358f5b2d6e 100644 --- a/plot_types/A_basic/g_fill_between.py +++ b/plot_types/A_basic/g_fill_between.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data np.random.seed(1) X = np.linspace(0, 8, 16) @@ -13,15 +15,14 @@ Y2 = 1 + 2*X/8 + np.random.uniform(0.0, 0.5, len(X)) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.fill_between(X, Y1, Y2, alpha=.5, linewidth=0) - ax.plot(X, (Y1+Y2)/2, linewidth=2.5) +ax.fill_between(X, Y1, Y2, alpha=.5, linewidth=0) +ax.plot(X, (Y1+Y2)/2, linewidth=2.5) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/B_arrays/a_imshow.py b/plot_types/B_arrays/a_imshow.py index 88691b59b513..be59a4920d71 100644 --- a/plot_types/B_arrays/a_imshow.py +++ b/plot_types/B_arrays/a_imshow.py @@ -7,6 +7,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) @@ -14,12 +16,11 @@ Z = Z[::16, ::16] # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest", - cmap=plt.get_cmap('Blues'), vmin=0, vmax=1.6) +ax.imshow(Z, extent=[0, 8, 0, 8], interpolation="nearest", + cmap=plt.get_cmap('Blues'), vmin=0, vmax=1.6) - ax.set_xticks([]) - ax.set_yticks([]) - plt.show() +ax.set_xticks([]) +ax.set_yticks([]) +plt.show() diff --git a/plot_types/B_arrays/b_pcolormesh.py b/plot_types/B_arrays/b_pcolormesh.py index decf5634a4c5..4dbf9e450cf1 100644 --- a/plot_types/B_arrays/b_pcolormesh.py +++ b/plot_types/B_arrays/b_pcolormesh.py @@ -10,6 +10,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make full-res data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) @@ -24,9 +26,8 @@ Z = Z[::8, :][:, xint] # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5, shading='nearest') +ax.pcolormesh(X, Y, Z, vmin=0, vmax=1.5, shading='nearest') - plt.show() +plt.show() diff --git a/plot_types/B_arrays/c_contourf.py b/plot_types/B_arrays/c_contourf.py index 1cc7bd526a44..27776efd7130 100644 --- a/plot_types/B_arrays/c_contourf.py +++ b/plot_types/B_arrays/c_contourf.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2) @@ -13,10 +15,9 @@ levs = np.linspace(np.min(Z), np.max(Z), 7) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - plt.contourf(X, Y, Z, levels=levs) - plt.contour(X, Y, Z, levels=levs, colors="white", linewidths=0.5) +plt.contourf(X, Y, Z, levels=levs) +plt.contour(X, Y, Z, levels=levs, colors="white", linewidths=0.5) - plt.show() +plt.show() diff --git a/plot_types/B_arrays/d_quiver.py b/plot_types/B_arrays/d_quiver.py index aaf35f14e84a..1545c8f3d9c1 100644 --- a/plot_types/B_arrays/d_quiver.py +++ b/plot_types/B_arrays/d_quiver.py @@ -6,21 +6,22 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data T = np.linspace(0, 2*np.pi, 8) X, Y = 4 + 1 * np.cos(T), 4 + 1 * np.sin(T) U, V = 1.5 * np.cos(T), 1.5 * np.sin(T) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - plt.quiver(X, Y, U, V, color="C0", angles='xy', - scale_units='xy', scale=0.5, width=.05) +plt.quiver(X, Y, U, V, color="C0", angles='xy', + scale_units='xy', scale=0.5, width=.05) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/B_arrays/e_streamplot.py b/plot_types/B_arrays/e_streamplot.py index 5d8ba13281b1..f085023c77b7 100644 --- a/plot_types/B_arrays/e_streamplot.py +++ b/plot_types/B_arrays/e_streamplot.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make a stream function: X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2. + X**5 + Y**3) * np.exp(-X**2 - Y**2) @@ -15,11 +17,10 @@ U = -np.diff(Z[:, 1:], axis=0) # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() - # contour stream function - ax.contour(X, Y, Z, colors='C1', alpha=0.5, zorder=1, linewidths=3) - # plot stream plot - ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V, zorder=2) +fig, ax = plt.subplots() +# contour stream function +ax.contour(X, Y, Z, colors='C1', alpha=0.5, zorder=1, linewidths=3) +# plot stream plot +ax.streamplot(X[1:, 1:], Y[1:, 1:], U, V, zorder=2) - plt.show() +plt.show() diff --git a/plot_types/C_stats/a_hist.py b/plot_types/C_stats/a_hist.py index 380555abda34..99bf7ba3799b 100644 --- a/plot_types/C_stats/a_hist.py +++ b/plot_types/C_stats/a_hist.py @@ -6,19 +6,20 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data np.random.seed(1) X = 4 + np.random.normal(0, 1.5, 200) # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.hist(X, bins=8, linewidth=0.5, edgecolor="white",) +ax.hist(X, bins=8, linewidth=0.5, edgecolor="white",) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 80) - ax.set_yticks(np.arange(1, 80, 10)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 80) +ax.set_yticks(np.arange(1, 80, 10)) - plt.show() +plt.show() diff --git a/plot_types/C_stats/b_boxplot.py b/plot_types/C_stats/b_boxplot.py index 9257d220f1d9..21440f62bf46 100644 --- a/plot_types/C_stats/b_boxplot.py +++ b/plot_types/C_stats/b_boxplot.py @@ -6,28 +6,29 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data: np.random.seed(10) D = np.random.normal((3, 5, 4), (1.25, 1.00, 1.25), (100, 3)) # plot -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() - VP = ax.boxplot(D, positions=[2, 4, 6], widths=1.5, patch_artist=True, - showmeans=False, showfliers=False, - medianprops={"color": "white", - "linewidth": 0.5}, - boxprops={"facecolor": "C0", - "edgecolor": "white", - "linewidth": 0.5}, - whiskerprops={"color": "C0", - "linewidth": 1.5}, - capprops={"color": "C0", - "linewidth": 1.5}) +fig, ax = plt.subplots() +VP = ax.boxplot(D, positions=[2, 4, 6], widths=1.5, patch_artist=True, + showmeans=False, showfliers=False, + medianprops={"color": "white", + "linewidth": 0.5}, + boxprops={"facecolor": "C0", + "edgecolor": "white", + "linewidth": 0.5}, + whiskerprops={"color": "C0", + "linewidth": 1.5}, + capprops={"color": "C0", + "linewidth": 1.5}) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/C_stats/c_errorbar.py b/plot_types/C_stats/c_errorbar.py index cc20faf2805a..f4f527f63eb3 100644 --- a/plot_types/C_stats/c_errorbar.py +++ b/plot_types/C_stats/c_errorbar.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data: np.random.seed(1) X = [2, 4, 6] @@ -13,14 +15,13 @@ E = np.random.uniform(0.5, 1.5, 3) # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.errorbar(X, Y, E, linewidth=2, capsize=6) +ax.errorbar(X, Y, E, linewidth=2, capsize=6) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/C_stats/d_violin.py b/plot_types/C_stats/d_violin.py index 3bfd73500751..db5aba8d4793 100644 --- a/plot_types/C_stats/d_violin.py +++ b/plot_types/C_stats/d_violin.py @@ -6,24 +6,24 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data: np.random.seed(10) D = np.random.normal((3, 5, 4), (0.75, 1.00, 0.75), (200, 3)) # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() - - VP = ax.violinplot(D, [2, 4, 6], widths=2, - showmeans=False, showmedians=False, showextrema=False) - #style: - for body in VP['bodies']: +fig, ax = plt.subplots() - body.set_alpha(0.9) +VP = ax.violinplot(D, [2, 4, 6], widths=2, + showmeans=False, showmedians=False, showextrema=False) +#style: +for body in VP['bodies']: + body.set_alpha(0.9) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/C_stats/e_barbs.py b/plot_types/C_stats/e_barbs.py index 80ea1a70816a..4a08f21e4499 100644 --- a/plot_types/C_stats/e_barbs.py +++ b/plot_types/C_stats/e_barbs.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data: np.random.seed(1) X = [[2, 4, 6]] @@ -14,15 +16,14 @@ V = -np.ones((1, 3)) * np.linspace(50, 100, 3) # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", - length=10, linewidth=1.5) +ax.barbs(X, Y, U, V, barbcolor="C0", flagcolor="C0", + length=10, linewidth=1.5) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/C_stats/f_eventplot.py b/plot_types/C_stats/f_eventplot.py index 3f9e744650bc..72978c926ffb 100644 --- a/plot_types/C_stats/f_eventplot.py +++ b/plot_types/C_stats/f_eventplot.py @@ -6,20 +6,21 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data: np.random.seed(1) X = [2, 4, 6] D = np.random.gamma(4, size=(3, 50)) # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.eventplot(D, orientation="vertical", lineoffsets=X, linewidth=0.75) +ax.eventplot(D, orientation="vertical", lineoffsets=X, linewidth=0.75) - ax.set_xlim(0, 8) - ax.set_xticks(np.arange(1, 8)) - ax.set_ylim(0, 8) - ax.set_yticks(np.arange(1, 8)) +ax.set_xlim(0, 8) +ax.set_xticks(np.arange(1, 8)) +ax.set_ylim(0, 8) +ax.set_yticks(np.arange(1, 8)) - plt.show() +plt.show() diff --git a/plot_types/C_stats/g_hist2d.py b/plot_types/C_stats/g_hist2d.py index 7b382af885fe..8bc2a4d40f27 100644 --- a/plot_types/C_stats/g_hist2d.py +++ b/plot_types/C_stats/g_hist2d.py @@ -6,18 +6,19 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data: correlated + noise np.random.seed(1) x = np.random.randn(5000) y = 1.2 * x + np.random.randn(5000)/3 # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1))) +ax.hist2d(x, y, bins=(np.arange(-3, 3, 0.1), np.arange(-3, 3, 0.1))) - ax.set_xlim(-2, 2) - ax.set_ylim(-3, 3) +ax.set_xlim(-2, 2) +ax.set_ylim(-3, 3) - plt.show() +plt.show() diff --git a/plot_types/C_stats/h_hexbin.py b/plot_types/C_stats/h_hexbin.py index 67158eb57efd..927a46796203 100644 --- a/plot_types/C_stats/h_hexbin.py +++ b/plot_types/C_stats/h_hexbin.py @@ -6,18 +6,19 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make data: correlated + noise np.random.seed(1) x = np.random.randn(5000) y = 1.2 * x + np.random.randn(5000)/3 # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.hexbin(x, y, gridsize=20) +ax.hexbin(x, y, gridsize=20) - ax.set_xlim(-2, 2) - ax.set_ylim(-3, 3) +ax.set_xlim(-2, 2) +ax.set_ylim(-3, 3) - plt.show() +plt.show() diff --git a/plot_types/D_unstructured/a_tricontour.py b/plot_types/D_unstructured/a_tricontour.py index 966b3cd84308..5739f7019fe6 100644 --- a/plot_types/D_unstructured/a_tricontour.py +++ b/plot_types/D_unstructured/a_tricontour.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2) @@ -20,14 +22,13 @@ z = Z[ysamp, xsamp] # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.plot(x, y, '.k', alpha=0.5) - levs = np.linspace(np.min(Z), np.max(Z), 7) - ax.tricontourf(x, y, z, levels=levs) +ax.plot(x, y, '.k', alpha=0.5) +levs = np.linspace(np.min(Z), np.max(Z), 7) +ax.tricontourf(x, y, z, levels=levs) - ax.set_xlim(-3, 3) - ax.set_ylim(-3, 3) +ax.set_xlim(-3, 3) +ax.set_ylim(-3, 3) - plt.show() +plt.show() diff --git a/plot_types/D_unstructured/b_tripcolor.py b/plot_types/D_unstructured/b_tripcolor.py index 1ab66801912a..5f1e3524675e 100644 --- a/plot_types/D_unstructured/b_tripcolor.py +++ b/plot_types/D_unstructured/b_tripcolor.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) Z = (1 - X/2. + X**5 + Y**3)*np.exp(-X**2-Y**2) @@ -20,13 +22,12 @@ z = Z[ysamp, xsamp] # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.plot(x, y, '.k', alpha=0.5) - ax.tripcolor(x, y, z) +ax.plot(x, y, '.k', alpha=0.5) +ax.tripcolor(x, y, z) - ax.set_xlim(-3, 3) - ax.set_ylim(-3, 3) +ax.set_xlim(-3, 3) +ax.set_ylim(-3, 3) - plt.show() +plt.show() diff --git a/plot_types/D_unstructured/c_triplot.py b/plot_types/D_unstructured/c_triplot.py index 6c9a017f8d87..fd2ec7446e9a 100644 --- a/plot_types/D_unstructured/c_triplot.py +++ b/plot_types/D_unstructured/c_triplot.py @@ -6,6 +6,8 @@ import matplotlib.pyplot as plt import numpy as np +plt.style.use('cheatsheet_gallery') + # make structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) @@ -17,12 +19,11 @@ x = X[0, :][xsamp] # plot: -with plt.style.context('cheatsheet_gallery'): - fig, ax = plt.subplots() +fig, ax = plt.subplots() - ax.triplot(x, y) +ax.triplot(x, y) - ax.set_xlim(-3, 3) - ax.set_ylim(-3, 3) +ax.set_xlim(-3, 3) +ax.set_ylim(-3, 3) - plt.show() +plt.show() From 265317008c04043e8401f9aaae916fd0ef631620 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Wed, 17 Mar 2021 07:06:29 -0700 Subject: [PATCH 07/11] Make ticks invisible --- lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle index 3053e4209ee5..31aa18ad134e 100644 --- a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle +++ b/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle @@ -11,6 +11,9 @@ figure.subplot.right: 0.99 figure.subplot.bottom: 0.01 figure.subplot.top: 0.99 +xtick.major.size: 0.0 +ytick.major.size: 0.0 + # colors: image.cmap : Blues # axes.prop_cycle: cycler('color', ['FF7F0E', '1F77B4', '2CA02C']) From b40ed418198d4df5bad8789cc9d918b69d1f56cb Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Thu, 1 Apr 2021 22:15:41 -0700 Subject: [PATCH 08/11] FIX: review suggestions --- plot_types/A_basic/b_scatter.py | 9 +++++---- plot_types/A_basic/c_bar.py | 2 +- plot_types/C_stats/a_hist.py | 2 +- plot_types/C_stats/b_boxplot.py | 14 +++++--------- 4 files changed, 12 insertions(+), 15 deletions(-) diff --git a/plot_types/A_basic/b_scatter.py b/plot_types/A_basic/b_scatter.py index 768b1fc01001..e8b6a3105db6 100644 --- a/plot_types/A_basic/b_scatter.py +++ b/plot_types/A_basic/b_scatter.py @@ -10,14 +10,15 @@ # make the data np.random.seed(3) -X = 4 + np.random.normal(0, 1.25, 24) -Y = 4 + np.random.normal(0, 1.25, len(X)) +X = 4 + np.random.normal(0, 2, 24) +Y = 4 + np.random.normal(0, 2, len(X)) +# size and color: +S = np.random.uniform(15, 80, len(X)) # plot fig, ax = plt.subplots() -ax.scatter(X, Y, 20, zorder=10, - edgecolor="none", linewidth=0.25) +ax.scatter(X, Y, s=S, c=-S, cmap=plt.get_cmap('Blues'), vmin=-100, vmax=0) ax.set_xlim(0, 8) ax.set_xticks(np.arange(1, 8)) diff --git a/plot_types/A_basic/c_bar.py b/plot_types/A_basic/c_bar.py index b0c74815a5b5..78cc665d8c77 100644 --- a/plot_types/A_basic/c_bar.py +++ b/plot_types/A_basic/c_bar.py @@ -15,7 +15,7 @@ # plot fig, ax = plt.subplots() -ax.bar(X, Y, bottom=0, width=1, edgecolor="white", linewidth=0.7) +ax.bar(X, Y, width=1, edgecolor="white", linewidth=0.7) ax.set_xlim(0, 8) ax.set_xticks(np.arange(1, 8)) diff --git a/plot_types/C_stats/a_hist.py b/plot_types/C_stats/a_hist.py index 99bf7ba3799b..65a0d4837f5f 100644 --- a/plot_types/C_stats/a_hist.py +++ b/plot_types/C_stats/a_hist.py @@ -15,7 +15,7 @@ # plot: fig, ax = plt.subplots() -ax.hist(X, bins=8, linewidth=0.5, edgecolor="white",) +ax.hist(X, bins=8, linewidth=0.5, edgecolor="white") ax.set_xlim(0, 8) ax.set_xticks(np.arange(1, 8)) diff --git a/plot_types/C_stats/b_boxplot.py b/plot_types/C_stats/b_boxplot.py index 21440f62bf46..d6631265e2e5 100644 --- a/plot_types/C_stats/b_boxplot.py +++ b/plot_types/C_stats/b_boxplot.py @@ -16,15 +16,11 @@ fig, ax = plt.subplots() VP = ax.boxplot(D, positions=[2, 4, 6], widths=1.5, patch_artist=True, showmeans=False, showfliers=False, - medianprops={"color": "white", - "linewidth": 0.5}, - boxprops={"facecolor": "C0", - "edgecolor": "white", - "linewidth": 0.5}, - whiskerprops={"color": "C0", - "linewidth": 1.5}, - capprops={"color": "C0", - "linewidth": 1.5}) + medianprops={"color": "white", "linewidth": 0.5}, + boxprops={"facecolor": "C0", "edgecolor": "white", + "linewidth": 0.5}, + whiskerprops={"color": "C0", "linewidth": 1.5}, + capprops={"color": "C0", "linewidth": 1.5}) ax.set_xlim(0, 8) ax.set_xticks(np.arange(1, 8)) From 69327fbd0eb271b3168a7e94e6a37a99f29eb20b Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Fri, 2 Apr 2021 13:14:46 -0700 Subject: [PATCH 09/11] DOC: rename stylefile --- .../{cheatsheet_gallery.mplstyle => mpl_plot_gallery.mplstyle} | 0 plot_types/A_basic/a_plot.py | 2 +- plot_types/A_basic/b_scatter.py | 2 +- plot_types/A_basic/c_bar.py | 2 +- plot_types/A_basic/d_stem.py | 2 +- plot_types/A_basic/e_step.py | 2 +- plot_types/A_basic/f_pie.py | 2 +- plot_types/A_basic/g_fill_between.py | 2 +- plot_types/B_arrays/a_imshow.py | 2 +- plot_types/B_arrays/b_pcolormesh.py | 2 +- plot_types/B_arrays/c_contourf.py | 2 +- plot_types/B_arrays/d_quiver.py | 2 +- plot_types/B_arrays/e_streamplot.py | 2 +- plot_types/C_stats/a_hist.py | 2 +- plot_types/C_stats/b_boxplot.py | 2 +- plot_types/C_stats/c_errorbar.py | 2 +- plot_types/C_stats/d_violin.py | 2 +- plot_types/C_stats/e_barbs.py | 2 +- plot_types/C_stats/f_eventplot.py | 2 +- plot_types/C_stats/g_hist2d.py | 2 +- plot_types/C_stats/h_hexbin.py | 2 +- plot_types/D_unstructured/a_tricontour.py | 2 +- plot_types/D_unstructured/b_tripcolor.py | 2 +- plot_types/D_unstructured/c_triplot.py | 2 +- 24 files changed, 23 insertions(+), 23 deletions(-) rename lib/matplotlib/mpl-data/stylelib/{cheatsheet_gallery.mplstyle => mpl_plot_gallery.mplstyle} (100%) diff --git a/lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle b/lib/matplotlib/mpl-data/stylelib/mpl_plot_gallery.mplstyle similarity index 100% rename from lib/matplotlib/mpl-data/stylelib/cheatsheet_gallery.mplstyle rename to lib/matplotlib/mpl-data/stylelib/mpl_plot_gallery.mplstyle diff --git a/plot_types/A_basic/a_plot.py b/plot_types/A_basic/a_plot.py index eef676790b43..d149f12aef72 100644 --- a/plot_types/A_basic/a_plot.py +++ b/plot_types/A_basic/a_plot.py @@ -7,7 +7,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data X = np.linspace(0, 10, 100) diff --git a/plot_types/A_basic/b_scatter.py b/plot_types/A_basic/b_scatter.py index e8b6a3105db6..a204025bcf01 100644 --- a/plot_types/A_basic/b_scatter.py +++ b/plot_types/A_basic/b_scatter.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make the data np.random.seed(3) diff --git a/plot_types/A_basic/c_bar.py b/plot_types/A_basic/c_bar.py index 78cc665d8c77..560c4d5e25b3 100644 --- a/plot_types/A_basic/c_bar.py +++ b/plot_types/A_basic/c_bar.py @@ -5,7 +5,7 @@ """ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: np.random.seed(3) diff --git a/plot_types/A_basic/d_stem.py b/plot_types/A_basic/d_stem.py index 9d11d12023fd..45a2b7d95669 100644 --- a/plot_types/A_basic/d_stem.py +++ b/plot_types/A_basic/d_stem.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data np.random.seed(3) diff --git a/plot_types/A_basic/e_step.py b/plot_types/A_basic/e_step.py index edd2ba0c8373..c2150d57ae8c 100644 --- a/plot_types/A_basic/e_step.py +++ b/plot_types/A_basic/e_step.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data np.random.seed(3) diff --git a/plot_types/A_basic/f_pie.py b/plot_types/A_basic/f_pie.py index cb83e38eb114..d139f7ae214d 100644 --- a/plot_types/A_basic/f_pie.py +++ b/plot_types/A_basic/f_pie.py @@ -7,7 +7,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data diff --git a/plot_types/A_basic/g_fill_between.py b/plot_types/A_basic/g_fill_between.py index 43358f5b2d6e..264f639f562e 100644 --- a/plot_types/A_basic/g_fill_between.py +++ b/plot_types/A_basic/g_fill_between.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data np.random.seed(1) diff --git a/plot_types/B_arrays/a_imshow.py b/plot_types/B_arrays/a_imshow.py index be59a4920d71..f9c4830d54cb 100644 --- a/plot_types/B_arrays/a_imshow.py +++ b/plot_types/B_arrays/a_imshow.py @@ -7,7 +7,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/B_arrays/b_pcolormesh.py b/plot_types/B_arrays/b_pcolormesh.py index 4dbf9e450cf1..a71637dae09e 100644 --- a/plot_types/B_arrays/b_pcolormesh.py +++ b/plot_types/B_arrays/b_pcolormesh.py @@ -10,7 +10,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make full-res data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/B_arrays/c_contourf.py b/plot_types/B_arrays/c_contourf.py index 27776efd7130..aba6ec2b06e8 100644 --- a/plot_types/B_arrays/c_contourf.py +++ b/plot_types/B_arrays/c_contourf.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/B_arrays/d_quiver.py b/plot_types/B_arrays/d_quiver.py index 1545c8f3d9c1..29572971a371 100644 --- a/plot_types/B_arrays/d_quiver.py +++ b/plot_types/B_arrays/d_quiver.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data T = np.linspace(0, 2*np.pi, 8) diff --git a/plot_types/B_arrays/e_streamplot.py b/plot_types/B_arrays/e_streamplot.py index f085023c77b7..789bff2b58df 100644 --- a/plot_types/B_arrays/e_streamplot.py +++ b/plot_types/B_arrays/e_streamplot.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make a stream function: X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/C_stats/a_hist.py b/plot_types/C_stats/a_hist.py index 65a0d4837f5f..c59543fddb16 100644 --- a/plot_types/C_stats/a_hist.py +++ b/plot_types/C_stats/a_hist.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data np.random.seed(1) diff --git a/plot_types/C_stats/b_boxplot.py b/plot_types/C_stats/b_boxplot.py index d6631265e2e5..513e0ba81054 100644 --- a/plot_types/C_stats/b_boxplot.py +++ b/plot_types/C_stats/b_boxplot.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: np.random.seed(10) diff --git a/plot_types/C_stats/c_errorbar.py b/plot_types/C_stats/c_errorbar.py index f4f527f63eb3..fc2e5892bf02 100644 --- a/plot_types/C_stats/c_errorbar.py +++ b/plot_types/C_stats/c_errorbar.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: np.random.seed(1) diff --git a/plot_types/C_stats/d_violin.py b/plot_types/C_stats/d_violin.py index db5aba8d4793..df611a6d4e7c 100644 --- a/plot_types/C_stats/d_violin.py +++ b/plot_types/C_stats/d_violin.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: np.random.seed(10) diff --git a/plot_types/C_stats/e_barbs.py b/plot_types/C_stats/e_barbs.py index 4a08f21e4499..2ef37a0091ed 100644 --- a/plot_types/C_stats/e_barbs.py +++ b/plot_types/C_stats/e_barbs.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: np.random.seed(1) diff --git a/plot_types/C_stats/f_eventplot.py b/plot_types/C_stats/f_eventplot.py index 72978c926ffb..535742fa555e 100644 --- a/plot_types/C_stats/f_eventplot.py +++ b/plot_types/C_stats/f_eventplot.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: np.random.seed(1) diff --git a/plot_types/C_stats/g_hist2d.py b/plot_types/C_stats/g_hist2d.py index 8bc2a4d40f27..894ce5b756f5 100644 --- a/plot_types/C_stats/g_hist2d.py +++ b/plot_types/C_stats/g_hist2d.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: correlated + noise np.random.seed(1) diff --git a/plot_types/C_stats/h_hexbin.py b/plot_types/C_stats/h_hexbin.py index 927a46796203..bf87bfeb0fba 100644 --- a/plot_types/C_stats/h_hexbin.py +++ b/plot_types/C_stats/h_hexbin.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make data: correlated + noise np.random.seed(1) diff --git a/plot_types/D_unstructured/a_tricontour.py b/plot_types/D_unstructured/a_tricontour.py index 5739f7019fe6..1296fe54f058 100644 --- a/plot_types/D_unstructured/a_tricontour.py +++ b/plot_types/D_unstructured/a_tricontour.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/D_unstructured/b_tripcolor.py b/plot_types/D_unstructured/b_tripcolor.py index 5f1e3524675e..a414da4b7a2e 100644 --- a/plot_types/D_unstructured/b_tripcolor.py +++ b/plot_types/D_unstructured/b_tripcolor.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) diff --git a/plot_types/D_unstructured/c_triplot.py b/plot_types/D_unstructured/c_triplot.py index fd2ec7446e9a..d3e74099c8c2 100644 --- a/plot_types/D_unstructured/c_triplot.py +++ b/plot_types/D_unstructured/c_triplot.py @@ -6,7 +6,7 @@ import matplotlib.pyplot as plt import numpy as np -plt.style.use('cheatsheet_gallery') +plt.style.use('mpl_plot_gallery') # make structured data X, Y = np.meshgrid(np.linspace(-3, 3, 256), np.linspace(-3, 3, 256)) From b3b44b15de000d6bc9a54164acce406ee685ac67 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 4 Apr 2021 15:29:23 -0700 Subject: [PATCH 10/11] Rename and order --- doc/sphinxext/gallery_order.py | 18 +++++++++++- plot_types/A_basic/g_fill_between.py | 28 ------------------- plot_types/{B_arrays => arrays}/README.rst | 0 .../c_contourf.py => arrays/contourf.py} | 0 .../a_imshow.py => arrays/imshow.py} | 0 .../b_pcolormesh.py => arrays/pcolormesh.py} | 0 .../d_quiver.py => arrays/quiver.py} | 0 .../e_streamplot.py => arrays/streamplot.py} | 0 plot_types/{A_basic => basic}/README.rst | 0 plot_types/{A_basic/c_bar.py => basic/bar.py} | 0 plot_types/{A_basic/f_pie.py => basic/pie.py} | 0 .../{A_basic/a_plot.py => basic/plot.py} | 0 .../b_scatter.py => basic/scatter.py} | 0 .../{A_basic/d_stem.py => basic/stem.py} | 0 .../{A_basic/e_step.py => basic/step.py} | 0 plot_types/{C_stats => stats}/README.rst | 0 .../{C_stats/e_barbs.py => stats/barbs.py} | 0 .../b_boxplot.py => stats/boxplot.py} | 0 .../c_errorbar.py => stats/errorbar.py} | 0 .../f_eventplot.py => stats/eventplot.py} | 0 .../{C_stats/h_hexbin.py => stats/hexbin.py} | 0 .../{C_stats/a_hist.py => stats/hist.py} | 0 .../{C_stats/g_hist2d.py => stats/hist2d.py} | 0 .../{C_stats/d_violin.py => stats/violin.py} | 0 .../README.rst | 0 .../tricontour.py} | 0 .../tripcolor.py} | 0 .../c_triplot.py => unstructured/triplot.py} | 0 28 files changed, 17 insertions(+), 29 deletions(-) delete mode 100644 plot_types/A_basic/g_fill_between.py rename plot_types/{B_arrays => arrays}/README.rst (100%) rename plot_types/{B_arrays/c_contourf.py => arrays/contourf.py} (100%) rename plot_types/{B_arrays/a_imshow.py => arrays/imshow.py} (100%) rename plot_types/{B_arrays/b_pcolormesh.py => arrays/pcolormesh.py} (100%) rename plot_types/{B_arrays/d_quiver.py => arrays/quiver.py} (100%) rename plot_types/{B_arrays/e_streamplot.py => arrays/streamplot.py} (100%) rename plot_types/{A_basic => basic}/README.rst (100%) rename plot_types/{A_basic/c_bar.py => basic/bar.py} (100%) rename plot_types/{A_basic/f_pie.py => basic/pie.py} (100%) rename plot_types/{A_basic/a_plot.py => basic/plot.py} (100%) rename plot_types/{A_basic/b_scatter.py => basic/scatter.py} (100%) rename plot_types/{A_basic/d_stem.py => basic/stem.py} (100%) rename plot_types/{A_basic/e_step.py => basic/step.py} (100%) rename plot_types/{C_stats => stats}/README.rst (100%) rename plot_types/{C_stats/e_barbs.py => stats/barbs.py} (100%) rename plot_types/{C_stats/b_boxplot.py => stats/boxplot.py} (100%) rename plot_types/{C_stats/c_errorbar.py => stats/errorbar.py} (100%) rename plot_types/{C_stats/f_eventplot.py => stats/eventplot.py} (100%) rename plot_types/{C_stats/h_hexbin.py => stats/hexbin.py} (100%) rename plot_types/{C_stats/a_hist.py => stats/hist.py} (100%) rename plot_types/{C_stats/g_hist2d.py => stats/hist2d.py} (100%) rename plot_types/{C_stats/d_violin.py => stats/violin.py} (100%) rename plot_types/{D_unstructured => unstructured}/README.rst (100%) rename plot_types/{D_unstructured/a_tricontour.py => unstructured/tricontour.py} (100%) rename plot_types/{D_unstructured/b_tripcolor.py => unstructured/tripcolor.py} (100%) rename plot_types/{D_unstructured/c_triplot.py => unstructured/triplot.py} (100%) diff --git a/doc/sphinxext/gallery_order.py b/doc/sphinxext/gallery_order.py index 1c1034ec5819..d5ee4ced1888 100644 --- a/doc/sphinxext/gallery_order.py +++ b/doc/sphinxext/gallery_order.py @@ -23,7 +23,12 @@ '../examples/showcase', '../tutorials/introductory', '../tutorials/intermediate', - '../tutorials/advanced'] + '../tutorials/advanced', + '../plot_types/basic', + '../plot_types/arrays', + '../plot_types/stats', + '../plot_types/unstructured', + ] class MplExplicitOrder(ExplicitOrder): @@ -60,6 +65,17 @@ def __call__(self, item): "color_demo", # pies "pie_features", "pie_demo2", + + # **Plot Types + # Basic + "plot", "scatter", "bar", "stem", "step", "pie", "fill_between", + # Arrays + "imshow", "pcolormesh", "contourf", "quiver", "streamplot", + # Stats + "hist", "boxplot", "errorbar", "violin", "barbs", "eventplot", + "hist2d", "hexbin", + # Unstructured + "tricontour", "tripcolor", "triplot", ] explicit_subsection_order = [item + ".py" for item in list_all] diff --git a/plot_types/A_basic/g_fill_between.py b/plot_types/A_basic/g_fill_between.py deleted file mode 100644 index 264f639f562e..000000000000 --- a/plot_types/A_basic/g_fill_between.py +++ /dev/null @@ -1,28 +0,0 @@ -""" -================================= -fill[_between][x](X, Y1, Y2, ...) -================================= -""" -import matplotlib.pyplot as plt -import numpy as np - -plt.style.use('mpl_plot_gallery') - -# make data -np.random.seed(1) -X = np.linspace(0, 8, 16) -Y1 = 3 + 4*X/8 + np.random.uniform(0.0, 0.5, len(X)) -Y2 = 1 + 2*X/8 + np.random.uniform(0.0, 0.5, len(X)) - -# plot -fig, ax = plt.subplots() - -ax.fill_between(X, Y1, Y2, alpha=.5, linewidth=0) -ax.plot(X, (Y1+Y2)/2, linewidth=2.5) - -ax.set_xlim(0, 8) -ax.set_xticks(np.arange(1, 8)) -ax.set_ylim(0, 8) -ax.set_yticks(np.arange(1, 8)) - -plt.show() diff --git a/plot_types/B_arrays/README.rst b/plot_types/arrays/README.rst similarity index 100% rename from plot_types/B_arrays/README.rst rename to plot_types/arrays/README.rst diff --git a/plot_types/B_arrays/c_contourf.py b/plot_types/arrays/contourf.py similarity index 100% rename from plot_types/B_arrays/c_contourf.py rename to plot_types/arrays/contourf.py diff --git a/plot_types/B_arrays/a_imshow.py b/plot_types/arrays/imshow.py similarity index 100% rename from plot_types/B_arrays/a_imshow.py rename to plot_types/arrays/imshow.py diff --git a/plot_types/B_arrays/b_pcolormesh.py b/plot_types/arrays/pcolormesh.py similarity index 100% rename from plot_types/B_arrays/b_pcolormesh.py rename to plot_types/arrays/pcolormesh.py diff --git a/plot_types/B_arrays/d_quiver.py b/plot_types/arrays/quiver.py similarity index 100% rename from plot_types/B_arrays/d_quiver.py rename to plot_types/arrays/quiver.py diff --git a/plot_types/B_arrays/e_streamplot.py b/plot_types/arrays/streamplot.py similarity index 100% rename from plot_types/B_arrays/e_streamplot.py rename to plot_types/arrays/streamplot.py diff --git a/plot_types/A_basic/README.rst b/plot_types/basic/README.rst similarity index 100% rename from plot_types/A_basic/README.rst rename to plot_types/basic/README.rst diff --git a/plot_types/A_basic/c_bar.py b/plot_types/basic/bar.py similarity index 100% rename from plot_types/A_basic/c_bar.py rename to plot_types/basic/bar.py diff --git a/plot_types/A_basic/f_pie.py b/plot_types/basic/pie.py similarity index 100% rename from plot_types/A_basic/f_pie.py rename to plot_types/basic/pie.py diff --git a/plot_types/A_basic/a_plot.py b/plot_types/basic/plot.py similarity index 100% rename from plot_types/A_basic/a_plot.py rename to plot_types/basic/plot.py diff --git a/plot_types/A_basic/b_scatter.py b/plot_types/basic/scatter.py similarity index 100% rename from plot_types/A_basic/b_scatter.py rename to plot_types/basic/scatter.py diff --git a/plot_types/A_basic/d_stem.py b/plot_types/basic/stem.py similarity index 100% rename from plot_types/A_basic/d_stem.py rename to plot_types/basic/stem.py diff --git a/plot_types/A_basic/e_step.py b/plot_types/basic/step.py similarity index 100% rename from plot_types/A_basic/e_step.py rename to plot_types/basic/step.py diff --git a/plot_types/C_stats/README.rst b/plot_types/stats/README.rst similarity index 100% rename from plot_types/C_stats/README.rst rename to plot_types/stats/README.rst diff --git a/plot_types/C_stats/e_barbs.py b/plot_types/stats/barbs.py similarity index 100% rename from plot_types/C_stats/e_barbs.py rename to plot_types/stats/barbs.py diff --git a/plot_types/C_stats/b_boxplot.py b/plot_types/stats/boxplot.py similarity index 100% rename from plot_types/C_stats/b_boxplot.py rename to plot_types/stats/boxplot.py diff --git a/plot_types/C_stats/c_errorbar.py b/plot_types/stats/errorbar.py similarity index 100% rename from plot_types/C_stats/c_errorbar.py rename to plot_types/stats/errorbar.py diff --git a/plot_types/C_stats/f_eventplot.py b/plot_types/stats/eventplot.py similarity index 100% rename from plot_types/C_stats/f_eventplot.py rename to plot_types/stats/eventplot.py diff --git a/plot_types/C_stats/h_hexbin.py b/plot_types/stats/hexbin.py similarity index 100% rename from plot_types/C_stats/h_hexbin.py rename to plot_types/stats/hexbin.py diff --git a/plot_types/C_stats/a_hist.py b/plot_types/stats/hist.py similarity index 100% rename from plot_types/C_stats/a_hist.py rename to plot_types/stats/hist.py diff --git a/plot_types/C_stats/g_hist2d.py b/plot_types/stats/hist2d.py similarity index 100% rename from plot_types/C_stats/g_hist2d.py rename to plot_types/stats/hist2d.py diff --git a/plot_types/C_stats/d_violin.py b/plot_types/stats/violin.py similarity index 100% rename from plot_types/C_stats/d_violin.py rename to plot_types/stats/violin.py diff --git a/plot_types/D_unstructured/README.rst b/plot_types/unstructured/README.rst similarity index 100% rename from plot_types/D_unstructured/README.rst rename to plot_types/unstructured/README.rst diff --git a/plot_types/D_unstructured/a_tricontour.py b/plot_types/unstructured/tricontour.py similarity index 100% rename from plot_types/D_unstructured/a_tricontour.py rename to plot_types/unstructured/tricontour.py diff --git a/plot_types/D_unstructured/b_tripcolor.py b/plot_types/unstructured/tripcolor.py similarity index 100% rename from plot_types/D_unstructured/b_tripcolor.py rename to plot_types/unstructured/tripcolor.py diff --git a/plot_types/D_unstructured/c_triplot.py b/plot_types/unstructured/triplot.py similarity index 100% rename from plot_types/D_unstructured/c_triplot.py rename to plot_types/unstructured/triplot.py From 6e4c4beacf32cb82a8ab218e79b54d770c5a1752 Mon Sep 17 00:00:00 2001 From: Jody Klymak Date: Sun, 4 Apr 2021 16:26:57 -0700 Subject: [PATCH 11/11] dedupe some names --- doc/sphinxext/gallery_order.py | 6 +++--- plot_types/basic/{scatter.py => scatter_plot.py} | 0 plot_types/stats/{boxplot.py => boxplot_plot.py} | 0 plot_types/stats/{errorbar.py => errorbar_plot.py} | 0 plot_types/stats/{hist.py => hist_plot.py} | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename plot_types/basic/{scatter.py => scatter_plot.py} (100%) rename plot_types/stats/{boxplot.py => boxplot_plot.py} (100%) rename plot_types/stats/{errorbar.py => errorbar_plot.py} (100%) rename plot_types/stats/{hist.py => hist_plot.py} (100%) diff --git a/doc/sphinxext/gallery_order.py b/doc/sphinxext/gallery_order.py index d5ee4ced1888..9c53fff9f131 100644 --- a/doc/sphinxext/gallery_order.py +++ b/doc/sphinxext/gallery_order.py @@ -68,12 +68,12 @@ def __call__(self, item): # **Plot Types # Basic - "plot", "scatter", "bar", "stem", "step", "pie", "fill_between", + "plot", "scatter_plot", "bar", "stem", "step", "pie", "fill_between", # Arrays "imshow", "pcolormesh", "contourf", "quiver", "streamplot", # Stats - "hist", "boxplot", "errorbar", "violin", "barbs", "eventplot", - "hist2d", "hexbin", + "hist_plot", "boxplot_plot", "errorbar_plot", "violin", + "barbs", "eventplot", "hist2d", "hexbin", # Unstructured "tricontour", "tripcolor", "triplot", ] diff --git a/plot_types/basic/scatter.py b/plot_types/basic/scatter_plot.py similarity index 100% rename from plot_types/basic/scatter.py rename to plot_types/basic/scatter_plot.py diff --git a/plot_types/stats/boxplot.py b/plot_types/stats/boxplot_plot.py similarity index 100% rename from plot_types/stats/boxplot.py rename to plot_types/stats/boxplot_plot.py diff --git a/plot_types/stats/errorbar.py b/plot_types/stats/errorbar_plot.py similarity index 100% rename from plot_types/stats/errorbar.py rename to plot_types/stats/errorbar_plot.py diff --git a/plot_types/stats/hist.py b/plot_types/stats/hist_plot.py similarity index 100% rename from plot_types/stats/hist.py rename to plot_types/stats/hist_plot.py