Friday, April 2, 2021

Matplotlib: Lines Connecting Points and Boxes

This gist has python functions that help Matplotlib draw lines connecting points, and to draw boxes.

def drawBox(xlim, ylim):
    pts = [[xlim[0], ylim[0]], [xlim[1], ylim[0]], 
           [xlim[1], ylim[1]], [xlim[0], ylim[1]], 
           [xlim[0], ylim[0]]]
    x, y = zip(*pts)
    return x, y

def connectPoints(pts):
    x, y = zip(*pts)
    return x, y

Tuesday, March 30, 2021

Quicktip: Batch convert LibreOffice documents to PDF

To convert all the DOCX files the current working directory to PDF

 lowriter --headless --convert-to pdf *.docx

Similarly, to convert ODT files,

 lowriter --headless --convert-to pdf *.docx

Wednesday, February 3, 2021

QuickTip: LaTeX multiline equations with explanations

Sometimes you want to write a sequence of steps, and write the explanation for each step next to it.

abc = xyz    pythagoras rule

    = uvw    triangle inequality

    = ABC    

It is easy to do this with the amsmath package as detailed in this StackOverflow question.
\usepackage{amsmath}

\begin{align*}
abc &= xyz \\
    &= uvw && \text{pythagoras rule} \\
    &= D   && \text{triangle inequality} \\
    &= ABC && 
\end{align*}