diff --git a/examples/lines_bars_and_markers/linestyles.py b/examples/lines_bars_and_markers/linestyles.py index 50b2e6fcd7f4..cbae3f1d7419 100644 --- a/examples/lines_bars_and_markers/linestyles.py +++ b/examples/lines_bars_and_markers/linestyles.py @@ -16,10 +16,9 @@ """ import numpy as np import matplotlib.pyplot as plt -from matplotlib.transforms import blended_transform_factory linestyle_str = [ - ('solid', 'solid'), # Same as (0, ()) or '-' + ('solid', 'solid'), # Same as (0, ()) or '-' ('dotted', 'dotted'), # Same as (0, (1, 1)) or '.' ('dashed', 'dashed'), # Same as '--' ('dashdot', 'dashdot')] # Same as '-.' @@ -55,11 +54,11 @@ def plot_linestyles(ax, linestyles): # For each line style, add a text annotation with a small offset from # the reference point (0 in Axes coords, y tick value in Data coords). - reference_transform = blended_transform_factory(ax.transAxes, ax.transData) for i, (name, linestyle) in enumerate(linestyles): - ax.annotate(repr(linestyle), xy=(0.0, i), xycoords=reference_transform, - xytext=(-6, -12), textcoords='offset points', color="blue", - fontsize=8, ha="right", family="monospace") + ax.annotate(repr(linestyle), + xy=(0.0, i), xycoords=ax.get_yaxis_transform(), + xytext=(-6, -12), textcoords='offset points', + color="blue", fontsize=8, ha="right", family="monospace") fig, (ax0, ax1) = plt.subplots(2, 1, gridspec_kw={'height_ratios': [1, 3]}, diff --git a/examples/pie_and_polar_charts/pie_and_donut_labels.py b/examples/pie_and_polar_charts/pie_and_donut_labels.py index a04b087c5e60..237c5e71508e 100644 --- a/examples/pie_and_polar_charts/pie_and_donut_labels.py +++ b/examples/pie_and_polar_charts/pie_and_donut_labels.py @@ -102,7 +102,7 @@ def func(pct, allvals): wedges, texts = ax.pie(data, wedgeprops=dict(width=0.5), startangle=-40) bbox_props = dict(boxstyle="square,pad=0.3", fc="w", ec="k", lw=0.72) -kw = dict(xycoords='data', textcoords='data', arrowprops=dict(arrowstyle="-"), +kw = dict(arrowprops=dict(arrowstyle="-"), bbox=bbox_props, zorder=0, va="center") for i, p in enumerate(wedges): @@ -113,7 +113,7 @@ def func(pct, allvals): connectionstyle = "angle,angleA=0,angleB={}".format(ang) kw["arrowprops"].update({"connectionstyle": connectionstyle}) ax.annotate(recipe[i], xy=(x, y), xytext=(1.35*np.sign(x), 1.4*y), - horizontalalignment=horizontalalignment, **kw) + horizontalalignment=horizontalalignment, **kw) ax.set_title("Matplotlib bakery: A donut") diff --git a/examples/showcase/anatomy.py b/examples/showcase/anatomy.py index 67e36d755ad8..b29f99f0dd9d 100644 --- a/examples/showcase/anatomy.py +++ b/examples/showcase/anatomy.py @@ -125,15 +125,13 @@ def text(x, y, text): text(-0.3, 0.45, "Figure") color = 'blue' -ax.annotate('Spines', xy=(4.0, 0.35), xycoords='data', - xytext=(3.3, 0.5), textcoords='data', +ax.annotate('Spines', xy=(4.0, 0.35), xytext=(3.3, 0.5), weight='bold', color=color, arrowprops=dict(arrowstyle='->', connectionstyle="arc3", color=color)) -ax.annotate('', xy=(3.15, 0.0), xycoords='data', - xytext=(3.45, 0.45), textcoords='data', +ax.annotate('', xy=(3.15, 0.0), xytext=(3.45, 0.45), weight='bold', color=color, arrowprops=dict(arrowstyle='->', connectionstyle="arc3", diff --git a/examples/style_sheets/style_sheets_reference.py b/examples/style_sheets/style_sheets_reference.py index 718bf5d3086a..261285f3434e 100644 --- a/examples/style_sheets/style_sheets_reference.py +++ b/examples/style_sheets/style_sheets_reference.py @@ -91,8 +91,8 @@ def plot_histograms(ax, prng, nb_samples=10000): ax.hist(values, histtype="stepfilled", bins=30, alpha=0.8, density=True) # Add a small annotation. - ax.annotate('Annotation', xy=(0.25, 4.25), xycoords='data', - xytext=(0.9, 0.9), textcoords='axes fraction', + ax.annotate('Annotation', xy=(0.25, 4.25), + xytext=(0.9, 0.9), textcoords=ax.transAxes, va="top", ha="right", bbox=dict(boxstyle="round", alpha=0.2), arrowprops=dict( diff --git a/examples/text_labels_and_annotations/mathtext_examples.py b/examples/text_labels_and_annotations/mathtext_examples.py index 22faf370c0e0..280964e0c0e8 100644 --- a/examples/text_labels_and_annotations/mathtext_examples.py +++ b/examples/text_labels_and_annotations/mathtext_examples.py @@ -78,8 +78,7 @@ def doall(): full_demo = mathext_demos[0] plt.annotate(full_demo, xy=(0.5, 1. - 0.59 * line_axesfrac), - xycoords='data', color=mpl_orange_rvb, ha='center', - fontsize=20) + color=mpl_orange_rvb, ha='center', fontsize=20) # Plotting features demonstration formulae for i_line in range(1, n_lines): @@ -92,12 +91,11 @@ def doall(): color=fill_color, alpha=0.5) plt.annotate(title, xy=(0.07, baseline - 0.3 * line_axesfrac), - xycoords='data', color=mpl_grey_rvb, weight='bold') + color=mpl_grey_rvb, weight='bold') demo = mathext_demos[i_line] plt.annotate(demo, xy=(0.05, baseline - 0.75 * line_axesfrac), - xycoords='data', color=mpl_grey_rvb, - fontsize=16) + color=mpl_grey_rvb, fontsize=16) for i in range(n_lines): s = mathext_demos[i] diff --git a/examples/text_labels_and_annotations/usetex_demo.py b/examples/text_labels_and_annotations/usetex_demo.py index 17f6fadbf9bc..09902ad9efe1 100644 --- a/examples/text_labels_and_annotations/usetex_demo.py +++ b/examples/text_labels_and_annotations/usetex_demo.py @@ -25,8 +25,7 @@ shadow=True, loc=(0.01, 0.48), handlelength=1.5, fontsize=16) # the arrow -plt.annotate("", xy=(-delta / 2., 0.1), xycoords='data', - xytext=(delta / 2., 0.1), textcoords='data', +plt.annotate("", xy=(-delta / 2., 0.1), xytext=(delta / 2., 0.1), arrowprops=dict(arrowstyle="<->", connectionstyle="arc3")) plt.text(0, 0.1, r'$\delta$', {'color': 'black', 'fontsize': 24, 'ha': 'center', 'va': 'center',