From 2b5438b2a04008aed26413f5c9b43d62ea3718ae Mon Sep 17 00:00:00 2001 From: Jamal Mustafa Date: Wed, 29 Sep 2021 20:25:45 -0700 Subject: [PATCH] remove obsolete scripts - figure.py appears to have been superseded by adjustments.py and the figure produced by figure.py is unused in the cheatsheets/handouts - line.py appears to have been superseded by linestyles.py - tick-locators-single.py produces a figure that seems incomplete and conflicts with the figure produced by tick-multiple-locator.py --- scripts/figure.py | 128 -------------------------------- scripts/line.py | 85 --------------------- scripts/tick-locators-single.py | 39 ---------- 3 files changed, 252 deletions(-) delete mode 100644 scripts/figure.py delete mode 100644 scripts/line.py delete mode 100644 scripts/tick-locators-single.py diff --git a/scripts/figure.py b/scripts/figure.py deleted file mode 100644 index b0a90d6..0000000 --- a/scripts/figure.py +++ /dev/null @@ -1,128 +0,0 @@ -# ---------------------------------------------------------------------------- -# Title: Scientific Visualisation - Python & Matplotlib -# Author: Nicolas P. Rougier -# License: BSD -# ---------------------------------------------------------------------------- -import numpy as np -import matplotlib.pyplot as plt -import matplotlib.patches as mpatches -from matplotlib.collections import PatchCollection - - -fig = plt.figure(figsize=(4.25, 4.25 * 95/115)) -ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1, - xlim=(0-5,100+10), ylim=(-10,80+5), xticks=[], yticks=[]) - - -box = mpatches.FancyBboxPatch( - (0,0), 100, 83, mpatches.BoxStyle("Round", pad=0, rounding_size=2), - linewidth=1., facecolor="0.9", edgecolor="black") -ax.add_artist(box) - -box = mpatches.FancyBboxPatch( - (0,0), 100, 75, mpatches.BoxStyle("Round", pad=0, rounding_size=0), - linewidth=1., facecolor="white", edgecolor="black") -ax.add_artist(box) - - -box = mpatches.Rectangle( - (5,5), 45, 30, zorder=10, - linewidth=1.0, facecolor="white", edgecolor="black") -ax.add_artist(box) - -box = mpatches.Rectangle( - (5,40), 45, 30, zorder=10, - linewidth=1.0, facecolor="white", edgecolor="black") -ax.add_artist(box) - -box = mpatches.Rectangle( - (55,5), 40, 65, zorder=10, - linewidth=1.0, facecolor="white", edgecolor="black") -ax.add_artist(box) - -# Window button -X, Y = [5,10,15], [79,79,79] -plt.scatter(X, Y, s=75, zorder=10, - edgecolor="black", facecolor="white", linewidth=1) - - -# Window size extension -X, Y = [0, 0], [0, -8] -plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False) - -X, Y = [100, 100], [0, -8] -plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False) - -X, Y = [100, 108], [0, 0] -plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False) - -X, Y = [100, 108], [75, 75] -plt.plot(X, Y, color="black", linestyle=":", linewidth=1, clip_on=False) - - -def ext_arrow(p0,p1,p2,p3): - p0, p1 = np.asarray(p0), np.asarray(p1) - p2, p3 = np.asarray(p2), np.asarray(p3) - ax.arrow(*p0, *(p1-p0), zorder=20, linewidth=0, - length_includes_head=True, width=.4, - head_width=2, head_length=2, color="black") - ax.arrow(*p3, *(p2-p3), zorder=20, linewidth=0, - length_includes_head=True, width=.4, - head_width=2, head_length=2, color="black") - plt.plot([p1[0],p2[0]], [p1[1],p2[1]], linewidth=.9, color="black") - -def int_arrow(p0,p1): - p0, p1 = np.asarray(p0), np.asarray(p1) - ax.arrow(*((p0+p1)/2), *((p1-p0)/2), zorder=20, linewidth=0, - length_includes_head=True, width=.4, - head_width=2, head_length=2, color="black") - ax.arrow(*((p0+p1)/2), *(-(p1-p0)/2), zorder=20, linewidth=0, - length_includes_head=True, width=.4, - head_width=2, head_length=2, color="black") - - - -x = 0 -y = 10 -ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) ) -ax.text(x+9.5, y, "left", ha="left", va="center", size="x-small", zorder=20) - -x += 50 -ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) ) -ax.text(x-4.5, y, "wspace", ha="right", va="center", size="x-small", zorder=20) - -x += 45 -ext_arrow( (x-4,y), (x,y), (x+5,y), (x+9,y) ) -ax.text(x-4.5, y, "right", ha="right", va="center", size="x-small", zorder=20) - -y = 0 -x = 25 -ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) ) -ax.text(x, y+9.5, "bottom", ha="center", va="bottom", size="x-small", zorder=20) - -y += 35 -ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) ) -ax.text(x, y-4.5, "hspace", ha="center", va="top", size="x-small", zorder=20) - -y += 35 -ext_arrow( (x,y-4), (x,y), (x,y+5), (x,y+9) ) -ax.text(x, y-4.5, "top", ha="center", va="top", size="x-small", zorder=20) - -int_arrow((0,-5), (100,-5)) -ax.text(50, -5, "figure width", backgroundcolor="white", zorder=30, - ha="center", va="center", size="x-small") - -int_arrow((105,0), (105,75)) -ax.text(105, 75/2, "figure height", backgroundcolor="white", zorder=30, - rotation = "vertical", ha="center", va="center", size="x-small") - -int_arrow((55,62.5), (95,62.5)) -ax.text(75, 62.5, "axes width", backgroundcolor="white", zorder=30, - ha="center", va="center", size="x-small") - -int_arrow((62.5,5), (62.5,70)) -ax.text(62.5, 35, "axes height", backgroundcolor="white", zorder=30, - rotation = "vertical", ha="center", va="center", size="x-small") - -plt.savefig("figure.pdf") -# plt.show() diff --git a/scripts/line.py b/scripts/line.py deleted file mode 100644 index 456f414..0000000 --- a/scripts/line.py +++ /dev/null @@ -1,85 +0,0 @@ -import numpy as np -import matplotlib.pyplot as plt - - -fig = plt.figure(figsize=(4.25,4*.45)) -ax = fig.add_axes([0,0,1,1], xlim=[0,11], ylim=[0.5,4.5], frameon=False, - xticks=[], yticks=[]) -y = 4 - -def split(n_segment): - width = 9 - segment_width = 0.75*(width/n_segment) - segment_pad = (width - n_segment*segment_width)/(n_segment-1) - X0 = 1+np.arange(n_segment)*(segment_width+segment_pad) - X1 = X0 + segment_width - return X0, X1 - - - -# Line width -# ---------------------------------------------------------------------------- -X0, X1 = split(5) -LW = np.arange(1,6) -for x0,x1,lw in zip(X0,X1,LW): - ax.plot([x0,x1], [y,y], color="black", linewidth=lw, solid_capstyle="round") - plt.text((x0+x1)/2, y-0.2, '%d' % lw, - size="x-small", ha="center", va="top") -ax.text(X0[0]-0.25, y+0.2, "Line width", size="small", ha="left", va="baseline") -ax.text(X1[-1]+0.25, y+0.2, "linewidth / lw", color="blue", - size="small", ha="right", va="baseline", family="monospace") -y -= 1 - -# Solid capstyle -# ---------------------------------------------------------------------------- -X0, X1 = split(3) -styles = "butt", "round", "projecting" -for x0,x1,style in zip(X0,X1,styles): - ax.plot([x0,x1],[y,y], color=".85", - solid_capstyle="projecting", linewidth=7) - ax.plot([x0,x1],[y,y], color="black", - solid_capstyle=style, linewidth=7) - ax.text((x0+x1)/2, y-0.2, '"%s"' % style, - size="x-small", ha="center", va="top", family="monospace") - -ax.text(X0[0]-0.25, y+0.2, "Cap style", size="small", ha="left", va="baseline") -ax.text(X1[-1]+0.25, y+0.2, "solid_capstyle", color="blue", - size="small", ha="right", va="baseline", family="monospace") -y -= 1 - -# Dash capstyle -# ---------------------------------------------------------------------------- -X0, X1 = split(3) -styles = "butt", "round", "projecting" -for x0,x1,style in zip(X0,X1,styles): - ax.plot([x0,x1],[y,y], color=".85", dash_capstyle="projecting", - linewidth=7, linestyle="--") - ax.plot([x0,x1],[y,y], color="black", linewidth=7, - linestyle="--", dash_capstyle=style) - ax.text((x0+x1)/2, y-0.2, '"%s"' % style, - size="x-small", ha="center", va="top", family="monospace") -ax.text(X0[0]-0.25, y+0.2, "Dash cap style", size="small", ha="left", va="baseline") -ax.text(X1[-1]+0.25, y+0.2, "dash_capstyle", color="blue", - size="small", ha="right", va="baseline", family="monospace") -y -= 1 - -# Line style -# ---------------------------------------------------------------------------- -X0, X1 = split(5) -styles = "-", ":", "--", "-.", (0,(0.01,2)) - -for x0,x1,style in zip(X0,X1,styles): - ax.plot([x0,x1],[y,y], color="black", linestyle=style, - solid_capstyle="round", dash_capstyle="round", linewidth=3) - if isinstance(style,str): text = '"%s"' % style - else: text = '%s' % str(style) - - ax.text((x0+x1)/2, y-0.2, text, - size="x-small", ha="center", va="top", family="monospace") -ax.text(X0[0]-0.25, y+0.2, "Line style", size="small", ha="left", va="baseline") -ax.text(X1[-1]+0.25, y+0.2, "linestyle / ls", color="blue", - size="small", ha="right", va="baseline", family="monospace") -y -= 1 - -plt.savefig("line.pdf", dpi=200) -# plt.show() diff --git a/scripts/tick-locators-single.py b/scripts/tick-locators-single.py deleted file mode 100644 index 3652e6a..0000000 --- a/scripts/tick-locators-single.py +++ /dev/null @@ -1,39 +0,0 @@ -# ---------------------------------------------------------------------------- -# Title: Scientific Visualisation - Python & Matplotlib -# Author: Nicolas P. Rougier -# License: BSD -# ---------------------------------------------------------------------------- -import numpy as np -import matplotlib.pyplot as plt -import matplotlib.ticker as ticker - -# Setup a plot such that only the bottom spine is shown -def setup(ax): - ax.spines['right'].set_color('none') - ax.spines['left'].set_color('none') - ax.yaxis.set_major_locator(ticker.NullLocator()) - ax.spines['top'].set_color('none') - ax.xaxis.set_ticks_position('bottom') - ax.tick_params(which='major', width=1.00) - ax.tick_params(which='major', length=5) - ax.tick_params(which='minor', width=0.75) - ax.tick_params(which='minor', length=2.5) - ax.set_xlim(0, 5) - ax.set_ylim(0, 1) - ax.patch.set_alpha(0.0) - - -fig = plt.figure(figsize=(5, .5)) -fig.patch.set_alpha(0.0) -n = 1 - -fontsize = 18 -family = "Source Code Pro" - -# Null Locator -ax = plt.subplot(n, 1, 1) -setup(ax) -ax.xaxis.set_major_locator(ticker.MultipleLocator(1)) -ax.xaxis.set_minor_locator(ticker.MultipleLocator(.1)) -plt.savefig("../figures/tick-multiple-locator.pdf", transparent=True) -# plt.show()