From 82bbe9c8cef7c818117dfba4ae8e1a18ee4b9ead Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 21 Aug 2018 23:31:55 +0200 Subject: [PATCH] Simplify linestyle and fillstyle reference docs. I don't know what's up with "cornflowerblue" but "tab:blue" is just as good :) --- .../line_styles_reference.py | 22 ++++++------------ .../marker_fillstyle_reference.py | 23 ++++++++----------- 2 files changed, 16 insertions(+), 29 deletions(-) diff --git a/examples/lines_bars_and_markers/line_styles_reference.py b/examples/lines_bars_and_markers/line_styles_reference.py index 4db1d40f7059..785bbcc6fe20 100644 --- a/examples/lines_bars_and_markers/line_styles_reference.py +++ b/examples/lines_bars_and_markers/line_styles_reference.py @@ -5,29 +5,21 @@ Reference for line-styles included with Matplotlib. """ + import numpy as np import matplotlib.pyplot as plt -color = 'cornflowerblue' -points = np.ones(5) # Draw 5 points for each line -text_style = dict(horizontalalignment='right', verticalalignment='center', - fontsize=12, fontdict={'family': 'monospace'}) - - -def format_axes(ax): - ax.margins(0.2) - ax.set_axis_off() - - # Plot all line styles. fig, ax = plt.subplots() linestyles = ['-', '--', '-.', ':'] for y, linestyle in enumerate(linestyles): - ax.text(-0.1, y, repr(linestyle), **text_style) - ax.plot(y * points, linestyle=linestyle, color=color, linewidth=3) - format_axes(ax) - ax.set_title('line styles') + ax.text(-0.1, y, repr(linestyle), + horizontalalignment='center', verticalalignment='center') + ax.plot([y, y], linestyle=linestyle, linewidth=3, color='tab:blue') + +ax.set_axis_off() +ax.set_title('line styles') plt.show() diff --git a/examples/lines_bars_and_markers/marker_fillstyle_reference.py b/examples/lines_bars_and_markers/marker_fillstyle_reference.py index cffe2cbc401f..512bc4c5da53 100644 --- a/examples/lines_bars_and_markers/marker_fillstyle_reference.py +++ b/examples/lines_bars_and_markers/marker_fillstyle_reference.py @@ -9,30 +9,25 @@ :doc:`/gallery/lines_bars_and_markers/marker_fillstyle_reference` and :doc:`/gallery/shapes_and_collections/marker_path` examples. """ + import numpy as np import matplotlib.pyplot as plt from matplotlib.lines import Line2D -points = np.ones(5) # Draw 3 points for each line -text_style = dict(horizontalalignment='right', verticalalignment='center', - fontsize=12, fontdict={'family': 'monospace'}) -marker_style = dict(color='cornflowerblue', linestyle=':', marker='o', - markersize=15, markerfacecoloralt='gray') - - -def format_axes(ax): - ax.margins(0.2) - ax.set_axis_off() - +points = np.ones(5) # Draw 5 points for each line +marker_style = dict(color='tab:blue', linestyle=':', marker='o', + markersize=15, markerfacecoloralt='tab:red') fig, ax = plt.subplots() # Plot all fill styles. for y, fill_style in enumerate(Line2D.fillStyles): - ax.text(-0.5, y, repr(fill_style), **text_style) + ax.text(-0.5, y, repr(fill_style), + horizontalalignment='center', verticalalignment='center') ax.plot(y * points, fillstyle=fill_style, **marker_style) - format_axes(ax) - ax.set_title('fill style') + +ax.set_axis_off() +ax.set_title('fill style') plt.show()