Tags: Web-App

Tabelle & Diagramm

Tabellen und Diagramme für Größen mit Einheiten unter Anwendung von DIN EN ISO 80000-1:2013-08

../../../_images/a.png

Beispiel: Temperatur \(T\) auf einer Linealkante abhängig von der Position \(x\)

Einheiten in den Daten

Tabelle

\(x\)

\(T\)

\(0 \, \mathrm{cm}\)

\(270{,}00 \, \mathrm{K}\)

\(5 \, \mathrm{cm}\)

\(270{,}25 \, \mathrm{K}\)

\(10 \, \mathrm{cm}\)

\(270{,}46 \, \mathrm{K}\)

\(15 \, \mathrm{cm}\)

\(270{,}62 \, \mathrm{K}\)

\(20 \, \mathrm{cm}\)

\(270{,}70 \, \mathrm{K}\)

\(25 \, \mathrm{cm}\)

\(270{,}67 \, \mathrm{K}\)

\(30 \, \mathrm{cm}\)

\(270{,}50 \, \mathrm{K}\)

Diagramm

Bokeh Plot

Einheiten außerhalb der Daten

Tabelle

\(x \, / \, \mathrm{cm}\)

\(T \, / \, \mathrm{K}\)

\(0\)

\(270{,}00\)

\(5\)

\(270{,}25\)

\(10\)

\(270{,}46\)

\(15\)

\(270{,}62\)

\(20\)

\(270{,}70\)

\(25\)

\(270{,}67\)

\(30\)

\(270{,}50\)

Diagramm

Bokeh Plot

Elegant

Die Einheiten außerhalb der Daten zu verwenden, ist elegant. Denn:

  • Die Einheiten tauchen nur auf im Tabellenkopf bzw. als Achsenbeschriftung, sodass die Darstellung kürzer und übersichtlicher ist.

  • Die Daten selbst enthalten keine Einheiten, sodass man mit den Daten leicht rechnen kann.

SymPy

Source Code eines Programms dazu:

from numpy import linspace
import matplotlib.pyplot as plt

# Function:
def f(x):
    return(x**2)

x = linspace(0,4, num=9)
xlabel = "x / cm"

y = list(map(f,x))
ylabel = "T / °C"

# Diagram and table in one figure:
fig, ax = plt.subplots(2, 1, layout="constrained")
ax1, ax2 = ax[0], ax[1]

# Table:
ax1.set_axis_off()
table = ax1.table(
    cellText = list(zip(x,y)),
    colLabels = [xlabel, ylabel],
    )

# Adjust:
box = ax1.get_position()
box.y0 += 0.43
box.y1 += 0.43
ax1.set_position(box)

# Diagram:
ax2.grid()
ax2.set_xlabel(xlabel), ax2.set_ylabel(ylabel)
diagram = ax2.plot(x, y, "r-+", lw=1)

plt.show()

Programm ausführen? Dazu:

  1. Copy: Source Code in die Zwischenablage kopieren.

  2. Paste: Source Code ins Eingabefeld hinter [ ]: einfügen.

  3. Play: Knopf ▶ drücken.