This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_heatline_with_border(ax, x, y, c, w, bw=4, bc='midnightblue'): | |
"""Plot a colour-coded segmented line graph with a border. | |
Args: | |
ax - the current axis. | |
x - x-axis values. | |
y - y-axis values. | |
c - the colours for the segments in the line graph defined by x, y. | |
w - the line widths for the segments in the line graph defined by x, y. | |
bw - the border thisckness. | |
bc - the border colour. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_heatline(ax, x, y, c, w): | |
"""Plot a colour-coded segmented line graph with a border. | |
Args: | |
ax - the current axis. | |
x - x-axis values. | |
y - y-axis values. | |
c - the colours for the segments in the line graph defined by x, y. | |
w - the line widths for the segments in the line graph defined by x, y. | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_session_pie(headline, header, chart, footer, session, fontsize=15, min_frac=0.05): | |
""" Plot a pie chart based on the minutes in each HR zone for the session. | |
Args: | |
headline - axis for the chart headline/title | |
header - axis for the chart header info (weekly mins, RE, % easy). | |
chart - axis for the main chart (horizontal bar). | |
footer - axis for the weekly kms and mean pace. | |
week - a dataframe with data for the week to be summarised. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def plot_training_week_summary_bars(headline, header, chart, footer, week, fontsize=15): | |
""" Plot a summary of the training week. | |
Args: | |
headline - axis for the chart headline/title. | |
header - axis for the chart header info (weekly mins, RE, % easy). | |
chart - axis for the main chart (horizontal bar). | |
footer - axis for the weekly kms and mean pace. | |
week - a dataframe with data for the week to be summarised. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The unit height of each row. | |
row_h = 10 | |
# The outer grid. | |
sessions_grid = gridspec.GridSpec((16*row_h), 8, figure=fig, wspace=.1, hspace=.5) | |
fig = plt.figure(figsize=(10, 20)) | |
# Iterate for each row (16 weeks) and column (weekly summary col + 7 x days) ... | |
for row in range(16): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib.pylab import plt | |
# Create a 16x8 grid of axes. | |
fig, axs = plt.subplots(figsize=(4, 10), nrows=16, ncols=8) | |
# Assign plots to asxes ... | |
plot_weekly_summary(ax=axs[0, 0], ...) | |
plot_session_pie(ax=axs[0, 1], ...) | |
: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def play_wordle(target, words, v): | |
""" | |
Play Wordle for a given target word. | |
Args: | |
target: the target word. | |
words: the words available as guesses. | |
v: the vocabulary setting. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy as np | |
import matplotlib.pylab as plt | |
def harriss_plot_adj( | |
ax, n, | |
angle=11.45, twist=1.8, # Controls the odd/even turn angles | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def collatz(n): | |
"""The Collatz operator: If n is even return n/2 else return 3n+1.""" | |
# If n is even then divide by 2. | |
if n%2==0: | |
return int(n/2) | |
# Otherwise return 3n+1 | |
else: | |
return (3*n)+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy as np | |
import matplotlib.pylab as plt | |
def turn_angle(n, angle, twist): | |
"""Compute the turn angle based on whether n is even or odd. | |
Args: | |
NewerOlder