Native and external processing tools

figure plot engine comparison.svg

  • Compare: Graphing tool comparison - Compare native and external calculation and drawing engines like PGF, MatPlotLib, PyX for visualising data

Modify spines of the x or y axis

figure plot spines.svg

Add legend

  • Show legend at best determined location inside data, see 2.1
  • Position legend outside data, see 2.2
  • Position legend entries horizontally or in a grid, see 2.2
  • Annotate the lines directly within the data, see 2.3
  • See source code examples: Function legend - Show formulas for multiple functions

figure plot legend.svg

Differentiate functions with color or line style

See source code examples: Cycles - Differentiate data set with colors or line style

figure plot cycles.svg

Text

  • Annotate - Write text on the plot

annotate interval Multiline titles: Wrap overlong title

def wrap_title(axes):
    import textwrap as tw
    long_title = axes.get_title()
    axes.set_title(tw.fill(long_title, 20))

Terminology

Explicit Axes through Figure fig , Axes ax

Implicit Axes through PyPlot plt

  • figure: entire canvas
  • axes: subplot
  • spines: connecting lines between ticks
  • savefig.bbox: add tight padding around figure to prevent cropped legends
  • constrained_layout: Place elements next to each other instead of overlaying
  • titlesize 10: default fontsize for latex figures, allows longer titles
  • grid linesstyle: less visual dominant that solid lines, to keep focus on function line
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams.update({'savefig.transparent':True, 'savefig.bbox':'tight', 
    'figure.constrained_layout.use':True, 'svg.fonttype':'none',
    'axes.titlesize': 10, 'axes.grid':True, 'grid.linestyle':':'})
plt.rc('axes.spines', left=False, top=False, right=False, bottom=False)
def plot_example_function(axes):
    x = np.linspace(0, 2.5, 100)
    axes.set_xlabel("x")
    axes.plot(x, np.cos(np.pi*x)*np.exp(-x), 
        label=r"$f(x) = \dfrac{\cos(\pi x)}{e^x}$")
    axes.legend()
 
fig, ax = plt.subplots(figsize=(6,2.2))
plot_example_function(ax)
# plt.savefig(@vault_path + '/attachments/plot .svg')
plt.show()

Dufte

  • Source code examples: dufte plots

Size

  • Size of plots

Legend

Color gradients

Layout multiple subfigures

Collection for note preview

figure plots collection.svg

Plot collection - Collage example plots for note preview


Sources:

Related:

Tags:

3 items under this folder.