Publishing documents with Quarto

2 min read Original article ↗

import matplotlib

import matplotlib.pyplot as plt

import numpy as np

ALPHA = 0.25

with plt.xkcd():

plt.rcParams.update({'font.size': 22})

x = np.arange(0, 1, 0.1)

word_y = 40 * x**2 + 2

latex_y = 2 * x**2 + 5

markdown_y = np.array([3, 3.1, 3.2, 1.5, 1.6, 3, 3.7, 7.5, 7.75, 8, 100])

markdown_x = np.array([0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.61, 0.7, 0.8, 0.9])

quarto_y = 22.5 * (x-0.3)**2 + 0.75

fig, axs = plt.subplots(1, 1, figsize=(16, 10))

ax = axs

segment_positions = [0.25, 0.5, 0.75]

segment_labels = ['Basic Reports OR\nStandard Documents', 'Papers with Figures\nbased on Results', 'Per-Page Layout\nOR Web Content', 'Professional\nBook Layout']

range_starts = [0, 0.25, 0.5, 0.75]

range_ends = [0.25, 0.5, 0.75, 0.9]

y_pos_annotations = -0.15

y_pos_arrows = -0.1

for start, end, label in zip(range_starts, range_ends, segment_labels):

ax.annotate('',

xy=(start, y_pos_arrows), xycoords=('data', 'axes fraction'),

xytext=(end, y_pos_arrows), textcoords=('data', 'axes fraction'),

arrowprops=dict(arrowstyle='<->', color='black'))

for i, position in enumerate(segment_positions):

ax.axvline(x=position, color='black', linestyle='-.', linewidth=0.5, alpha = 0.5)

ax.annotate(segment_labels[i],

xy=(position, 0), xycoords=('data', 'axes fraction'),

xytext=(-125, -50), textcoords='offset points',

ha='center', va='baseline', alpha = 0.5)

ax.annotate(segment_labels[-1],

xy=(1, 0), xycoords=('axes fraction', 'axes fraction'),

xytext=(-75, -50), textcoords='offset points',

ha='center', va='baseline', alpha = 0.5)

word_line, = ax.plot(x, word_y, label="Word")

latex_line, = ax.plot(x, latex_y, label="LaTeX")

markdown_line, = ax.plot(markdown_x, markdown_y, alpha=ALPHA, label="Markdown")

quarto_line, = ax.plot(x, quarto_y, linewidth=5, label="Quarto")

ax.legend(handles=[word_line, latex_line, markdown_line, quarto_line], loc="upper left")

ax.set_ylim(0, 10)

ax.set_xlim(0, 0.9)

arrowprops = dict(arrowstyle="->", alpha=ALPHA)

ax.annotate("WHEN YOU START\n USING MAKEFILES", xy=(0.2, 3.3), arrowprops=arrowprops, xytext=(0.025, 3.75), alpha = ALPHA/5)

ax.annotate("WHEN YOU START USING\n UNSUPPORTED SYNTAX", xy=(0.6, 3.7), arrowprops=arrowprops, xytext=(0.30, 4), alpha = ALPHA/5)

ax.annotate("WHEN YOU DISCOVER\n PANDOCFILTERS", xy=(0.61, 7.5), arrowprops=arrowprops, xytext=(0.375, 6.25), alpha = ALPHA/5)

ax.annotate("WHEN YOU REALIZE YOU \nHAVE TO LEARN HASKELL", xy=(0.8, 8), arrowprops=arrowprops, xytext=(0.45, 8.5), alpha=ALPHA/5)

ax.get_xaxis().set_ticks([])

ax.get_yaxis().set_ticks([])

ax.set_xlabel("DOCUMENT COMPLEXITY")

ax.xaxis.set_label_position('top')

ax.set_ylabel("IMPLEMENTATION DIFFICULTY")

plt.savefig("./images/learningcurve.png") #| hide_line

None #| hide_line