From 59b75b8d873c970d6af96eb7cf8193f08ccb3397 Mon Sep 17 00:00:00 2001 From: Steffen Rehberg Date: Mon, 22 Nov 2021 12:44:07 +0100 Subject: [PATCH] Fix various typos and inconsistencies - annotation: missing x in xycoords and "text" instead of "Annotation" to correspond to function call signature above - clear a figure how-to: make code correspond to heading - remove ticks how-to: same for yaxis as is the other how-to's - explicitly set legend location in anatomy.py as mpl 3.5.0 "best" default location results in lower right corner --- cheatsheets.tex | 6 +++--- scripts/anatomy.py | 2 +- scripts/annotate.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cheatsheets.tex b/cheatsheets.tex index 3f54ce5..9d4421a 100644 --- a/cheatsheets.tex +++ b/cheatsheets.tex @@ -968,12 +968,12 @@ \hspace*{2.5mm}~$\rightarrow$ fig.savefig("figure.pdf")\\ \textbf{… save a transparent figure?}\\ \hspace*{2.5mm}~$\rightarrow$ fig.savefig("figure.pdf", transparent=True)\\ - \textbf{… clear a figure?}\\ - \hspace*{2.5mm}~$\rightarrow$ ax.clear()\\ + \textbf{… clear a figure/an axes?}\\ + \hspace*{2.5mm}~$\rightarrow$ fig.clear() $\rightarrow$ ax.clear()\\ \textbf{… close all figures?}\\ \hspace*{2.5mm}~$\rightarrow$ plt.close("all")\\ \textbf{… remove ticks?}\\ - \hspace*{2.5mm}~$\rightarrow$ ax.set\_xticks([])\\ + \hspace*{2.5mm}~$\rightarrow$ ax.set\_[xy]ticks([])\\ \textbf{… remove tick labels ?}\\ \hspace*{2.5mm}~$\rightarrow$ ax.set\_[xy]ticklabels([])\\ \textbf{… rotate tick labels ?}\\ diff --git a/scripts/anatomy.py b/scripts/anatomy.py index 35c5661..4a32544 100644 --- a/scripts/anatomy.py +++ b/scripts/anatomy.py @@ -49,7 +49,7 @@ def minor_tick(x, pos): ax.set_xlabel("X axis label") ax.set_ylabel("Y axis label") -ax.legend() +ax.legend(loc="upper right") def circle(x, y, radius=0.15): diff --git a/scripts/annotate.py b/scripts/annotate.py index f138bc1..4254941 100644 --- a/scripts/annotate.py +++ b/scripts/annotate.py @@ -17,10 +17,10 @@ plt.xlim(0, 6), plt.ylim(0, 1) plt.xticks([]), plt.yticks([]) -plt.annotate("Annotation", (5.5, .75), (0.1, .75), size=16, va="center", +plt.annotate("text", (5.5, .75), (0.75, .75), size=16, va="center", ha="center", arrowprops=dict(facecolor='black', shrink=0.05)) -plt.text( 5.5, 0.6, "xy\nycoords", size=10, va="top", ha="center", color=".5") +plt.text( 5.5, 0.6, "xy\nxycoords", size=10, va="top", ha="center", color=".5") plt.text( .75, 0.6, "xytext\ntextcoords", size=10, va="top", ha="center", color=".5") plt.savefig("../figures/annotate.pdf")