Skip to content

Instantly share code, notes, and snippets.

How to typeset a value and its uncertainty in HTML (without a CSS stylesheet)

If you want to quote a value and a plus/minus uncertainty range in HTML, using the <sup> and <sub> tags leaves the values offset, e.g.:

2.3<sup>+1.2</sup><sub>-0.5</sub>

gives:

@mattpitkin
mattpitkin / examplenetworkgrid.py
Last active May 22, 2023 11:55
A network plot of 2x2 grids
import numpy as np
from matplotlib import pyplot as plt
from matplotlib.patches import Rectangle
fig, ax = plt.subplots()
def draw_2x2_grid(ax, xy, bwidth=0.25, bheight=0.25, numbers=[]):
for i in range(2):
@mattpitkin
mattpitkin / colourfillviolin.md
Last active February 20, 2024 16:31
Violin plot with gradient colour fill

In answer to this StackOverflow question, here is a method (based heavily on this answer) to create a violin plot with a gradient colour fill based on the density of the samples (i.e., width of the violin):

from matplotlib import pyplot as plt
from matplotlib.path import Path
from matplotlib.patches import PathPatch
import matplotlib as mpl