2024-10-25 13:28:49 +02:00
{
"cells": [
{
"cell_type": "markdown",
"id": "495dd375-03bd-468b-9efa-4c0dc0e03e71",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-d5e39caeb15d5f93",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# 4. Programmierübung: Matplotlib\n",
"\n",
"<div style=\"display:flex;\">\n",
" <div style=\"text-align: left\">\n",
" Willkommen zur vierten Programmierübung Einführung in Python 3.\n",
" </div>\n",
" <img style=\"float: right; margin: 0px 15px 15px 0px\" src=\"https://www.python.org/static/img/python-logo-large.c36dccadd999.png?1576869008\" width=\"100\" />\n",
"</div>\n",
"\n",
"Wenn Sie Fragen oder Verbesserungsvorschläge zum Inhalt oder Struktur der Notebooks haben, dann können sie eine E-Mail an Phil Keier ([p.keier@hbk-bs.de](mailto:p.keier@hbk-bs.de?subject=[SigSys]%20Feedback%20Programmierübung&)) oder Martin Le ([martin.le@tu-bs.de](mailto:martin.le@tu-bs.de?subject=[SigSys]%20Feedback%20Programmierübung&)) schreiben.\n",
"\n",
"Link zu einem Python Spickzettel: [hier](https://s3.amazonaws.com/assets.datacamp.com/blog_assets/PythonForDataScience.pdf)\n",
"\n",
"Der Großteil des Python-Tutorials stammt aus der Veranstaltung _Deep Learning Lab_ und von [www.python-kurs.eu](https://www.python-kurs.eu/python3_kurs.php) und wurde für _Signale und Systeme_, sowie _Einführung in die Programmierung für Nicht Informatiker_ angepasst.\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "d6320c43-281a-4c81-86ca-ded1f2d57f19",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-56a32bfbc0754cb7",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# Was ist Matplotlib\n",
"\n",
"Matplotlib ist eine Python Bibliothek zum (interaktiven) Visualisieren von Daten. Die Bibliothek intergiert sich super mit anderen viel Benutzten Python Bibliotheken wie NumPy. Der Vorteil in Kombination mit Jupyter besteht in der direkten Ausgabe eines Plots auf dem Bildschirm.\n",
"\n",
"__Nutzen Sie für diese Aufgabe gerne die [Matplotlib Reference](https://matplotlib.org/stable/users/index.html)__\n",
"\n",
"---"
]
},
{
"cell_type": "markdown",
"id": "994c8d87-9f58-4915-9eb5-f55e16d31487",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-bc85a0be9322c558",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# Import & Jupyter Magick\n",
"\n",
"Um Matplotlib zu verwenden müssen wir diese importieren. Dabei ist das Objekt `pyplot` der Dreh und Angelpunkt der ganzen Magie. Wie auch bei NumPy hat das Internet ein ungeschriebenes Gesetz, dass die Abkürzung von `matplotlib.pyplot` `plt` heißt. \n",
"\n",
"Importieren wir im ersten Schritt matplotlib als plt:"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4e07b9b9-adab-46d6-97bd-c9fce64f4280",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-68fd2b50ade28cf5",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"id": "cf8480a8-a92b-401f-90fb-a92d4d8cb33d",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-bef28e9b16f2bbd6",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"Jupyter hat magische Parameter die von den Bibliotheken verwendet werden können um gewissen Einstellungen im Hintergrund zu treffen. Daher brauchen wir in nächster Zeile genau dieses \"magische\" Statement. \n",
"\n",
"Falls Sie dazu mehr Wissen wollen Lesen Sie den Eintrag zu [Rich Outputs](https://ipython.readthedocs.io/en/stable/interactive/plotting.html) in der IPython Dokumentation."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "27f26d6b-2b3c-4c60-b878-b728d2467b1f",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-5c87d5ef9d857466",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"id": "58332e87-d29d-4307-92de-bc5d70ac6419",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-f5c587ae3eade082",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"Im Allgemeinen steht folgendes Import Statement in jedem Jupyter Notebook das im entferntesten etwas mit Datenanalyse zu tun hat. Achtung in nächster Zelle wird NumPy gleich mit importiert."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "f8d54007-5094-4d34-b5ce-11a62d367f53",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-67eb623e3d643f2d",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"id": "e7b78221-3568-45c5-964f-422b2668f4e5",
"metadata": {
2024-11-14 19:06:50 +01:00
"jp-MarkdownHeadingCollapsed": true,
2024-10-25 13:28:49 +02:00
"nbgrader": {
"grade": false,
"grade_id": "cell-30de8243b097dfdc",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# First plot\n",
"\n",
"Wie dem [Getting Started](https://matplotlib.org/stable/users/getting_started/index.html#getting-started) Beispiel zu entnehmen, wollen wir einmal die Sinus Funktion plotten.\n",
"\n",
"Dazu brauchen wir zwei Attribute:\n",
"1. Die x-Skala - Dies kann die Länge eines Datensets sein, oder ein allegemeiner Linespace. Aufjedenfall eine Liste bzw. Array.\n",
"2. Die y-Skala - Im Allgemeinen die Werte eines zu plottenden Datensets. Aufjedenfall auch eine Liste bzw. Array.\n",
"\n",
"Plotten wir im Folgenden die Sinus Funktion. Eine der schönen Eigenschaften der Sinus Funktion ist, dass diese sich nach dem Intervall $[0...2\\pi]$ wiederholt. Daher enthält die x-Skala einen linespace von $[0...2\\pi]$. Als Wert für $\\pi$ wird die NumPy Konstante [np.pi](https://numpy.org/doc/stable/reference/constants.html#numpy.pi) verwendet.\n",
"\n",
"Auf der y-Skala plotten wir im folgenden das zuvor berechnete Array mit den Sinus Werten. Die Hierfür verwendete Funktion ist [np.sin](https://numpy.org/doc/stable/reference/generated/numpy.sin.html). \n",
"\n",
"Das `plt` Objekt hat mehrere Funktionen die in einer bestimmten Reihenfolge aufgerufen werden müssen. Dabei können zuerst mehrere plots mit [plt.plot](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html) definiert werden. Zum Schluss wird zur Ausgabe [plt.show](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.show.html) aufgerufen."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "72fa4224-095a-4d6a-9a9f-e1c136a79115",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-2eaf77b2d04abff1",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
2024-11-14 19:06:50 +01:00
},
"scrolled": true
2024-10-25 13:28:49 +02:00
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGdCAYAAAAfTAk2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABZaElEQVR4nO3deVhU9eIG8PfMAMO+yS6biIqmgqISLmVJopllWWlXQ830ZmqZ3krur7TbZvstzatprmXZapndUMMtFUVRXHBFQTbZRGbYl5nz+wOc4rqBMnxneT/Pc557Hc4c3kFzXs98F0mWZRlEREREZkQhOgARERFRa2PBISIiIrPDgkNERERmhwWHiIiIzA4LDhEREZkdFhwiIiIyOyw4REREZHZYcIiIiMjsWIkOIIJOp0NeXh6cnJwgSZLoOERERNQMsiyjrKwMfn5+UChufI/GIgtOXl4eAgICRMcgIiKiW5CdnQ1/f/8bnmORBcfJyQlAww/I2dlZcBoi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3hj8kBOB79VSoWEhU/0QntXO2QUV2DOt0eg08miYxERGR0WHDIonU7G7G9TkVvaMKj4/cfCOWPqNrk72GDJ+N6wsVJg64kCLNl5TnQkIiKjw4JDBrVk5zlsP10ElZUC/xnXG8621qIjmYWe/q5446E7AAAfbjmN5IwSwYmIiIwLCw4ZzL7zl/DhltMAgDce6o47/FwEJzIvY/oGYnRvf+hk4IVvUqGu4ngcIqIrWHDIINRVdZj9TSp0MjC6tz8e78s9pgzhXw/dgaB29sgtrcL/bTgGWeZ
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x = np.linspace(0, 2*np.pi, num=200) # Definiere einen linearen Bereich von 0 bis 2pi\n",
"y = np.sin(x) # Berechne den Sinus mit den Werten von x\n",
"\n",
"plt.plot(x, y) # Setze für die X-Achse x und für die Y-Achse y\n",
"plt.show() # Zeige den Plot"
]
},
{
"cell_type": "markdown",
"id": "b67896b4-8a1c-4c3f-92c7-7459f95916e0",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-1dd3b7172bc39b59",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# Zwei Funktionen \n",
"\n",
"Wie bereits zuvor erwähnt lässt sich `plt.plot` mehr als einmal aufrufen. Wollen wir im folgenden den Kosinus mittels [np.cos](https://numpy.org/doc/stable/reference/generated/numpy.cos.html) dazu plotten. Dafür werden die Werte aus dem bereits definierten x wiederverwendet. Die Variabelen `y1 = np.sin(x)` & `y2 = np.cos(x)` enthälten die jeweiligen y werte. "
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "3ef7123c-255d-42ae-8ae6-d63cdcc6b032",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-2e9cc2ce95f1e20e",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGdCAYAAAAfTAk2AAAAOXR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vd3C+oAR/D2c+GB1J7xb+qmNVi9lsZt7GRGb+fhCjyUybEC/mjetGqE/9HI0TQtSxzKPwzShtfqfBWStsuoy1qUUs1fn8tv5ffcVFzfrBPzdAw25ab4Ivb9OW9Nm5b7clc9/8OM4XlNCpkTfLH+ljc8UNaBvOPtC3GYsfiMLfw4kDp3MYPmsTu1LOq44mhLB3x9fB3AFacePVCB5YCV3H2VRxU11S4NgarxAY/xt0uAvMRm1Z3+pXtdVXdsZsNvPuysM88+MejCYzIyJD+faf0QR7u6iOdl16NmvAz1N60zrIkzO5RYz6bAtryi5dCSFErdvzA3w1Umvg16gHTF4DIZ1Up7I4KXBskaML3P4Z9C/bVX39W/Dro9qurnbCaDLz76V7+XDVEQAeHdCC90ZFWtUqqevRyNeNHx6Kpl+rAApLTEz6Yjs/7zylOpYQwt5s/VSb2mAqgXa3wbhftf2i6gEpcGyVTgf9n4Wb3wedHnZ8Ab9MsYsip8RoYtp3CXwTl4xeB6/f1oFpg1rb3aojTxdH5o7rxojIUEpNZh7/NoGvY5NVxxJC2IvNH8GKZ7TjqAdh5HztF+R6QgocW9dtAtyxAHQG2PWNzRc5pUYTj3y9k18SUnHQ6/jw7s7cExWuOpbFOBr0vHtXJON7NQHg30v38N22FLWhhBC2b/PHWgM/gH7PwJD/gL5+feTLGlV70G6E9vWH+7UiB53W+diK2mtXhclk5l/f72LFvjScDHpm39uFgW2qtr+YLdP
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"y1 = np.sin(x) # Sinus Werte mittels x berechnen\n",
"y2 = np.cos(x) # Kosinus Werte mittels x berechnen\n",
"\n",
"plt.plot(x, y1) # Plotte den Sinus\n",
"plt.plot(x, y2) # Plotte den Kosinus\n",
"\n",
"plt.show() # Zeige das Diagramm"
]
},
{
"cell_type": "markdown",
"id": "caf293fb-ee33-48d1-85f1-82cc3afca0cf",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-d1d50ca1d203ac29",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Aufgabe - Erster eigener Plot Square Root\n",
"\n",
"Analog zu voheriger Erklärung Plotten Sie im folgenden die Funktion Square Root Mathematisch definiert als $f(x) = \\sqrt x; \\quad x \\geq 0$.\n",
"\n",
"Gehen Sie dabei wie folgt vor:\n",
"1. Definieren Sie einen geeigneten [Linespace](https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy-linspace) für die Zahlenraum 0...100. (Tipp: Achten Sie auf die Definition! Die Wurzel ist nur für positive Zahlen definiert.)\n",
"2. Berechnen Sie mittels der Funktion [np.sqrt](https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html#numpy.sqrt) die Werte für die Wurzel.\n",
"3. Plotten Sie das Ergebnis"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "94a1aacc-0c6f-443f-b11c-de8f3c6137bc",
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-bae73642cf0a866a",
"locked": false,
"points": 3,
"schema_version": 3,
"solution": true,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA4tklEQVR4nO3deXhU5cH+8Xuyh6xASELIZGGTfZEAsogiuG+4oCJaRKu1xQVpX5W61Sri8nuttbVYrEhVEJcqKiq+FhSkQELCvgcCJEA2lmQSQibJzPn9EZwaRdlm5szy/VxXrqs5c8jc1wPN3J7znOexGIZhCAAAwEtCzA4AAACCC+UDAAB4FeUDAAB4FeUDAAB4FeUDAAB4FeUDAAB4FeUDAAB4FeUDAAB4VZjZAX7I6XRq//79iouLk8ViMTsOAAA4CYZhqKamRmlpaQoJ+flrGz5XPvbv3y+r1Wp2DAAAcBpKSk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wAQZJxOQ0u2V+r1Zbu0bMcB1/F+1kTdPjxbl/ZK5dYKPIryAQBB4miDQx+u2atZy3ZpZ2XzNvYhFunSXu11+/BsDchsbXJCBAvKBwAEuApbvd5csUdzcvfocF2jJCkuMkw3DrRqwtAsWdu0Mjkhgg3lAwAC1MZ91Zq1bJc+Xb9fjY7mR2WtbaI1cWi2xuakKy4q3OSECFaUDwAIIE6nocVbK/SPZUVaWXTIdTwns7V+eW62LuyRqtAQtrGHuSgfABAA6hqa9EHBXr3xn93adaB5PkdoiEWX926vO4Znq6810dyAwPdQPgDAj5VV12v28t1
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# BEGIN SOLUTION\n",
"xs = np.linspace(0, 100, num=200)\n",
"ys = np.sqrt(xs)\n",
"plt.plot(xs, ys)\n",
"plt.show()\n",
"# END SOLUTION"
]
},
{
"cell_type": "markdown",
"id": "89a722de-8f9f-4d92-a3c1-867b61f4ddaf",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-998243908406c7d4",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"# Styling\n",
"\n",
"Da bei mehreren Plots der Überblick schnell verloren geht beschäftigen wir uns im folgenden mit dem Styling. Dabei gehen wir im Schnelldurchlauf durch alle Parameter.\n",
"\n",
"Die Grundlage für alle folgenden Plots werden in nächster Zelle gesetzt."
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "88f9cd6c-0347-4df4-9b5f-0cfb9b655a4c",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-a86ddac229c0bbbb",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"x = np.linspace(0, 2*np.pi, num=200)\n",
"s = np.sin(x)\n",
"c = np.cos(x)"
]
},
{
"cell_type": "markdown",
"id": "3b164da6-f153-4e50-98f0-18c75f6adf19",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-e27c575962048d7b",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Farbe ändern\n",
"\n",
"Die Standard Farbe für den ersten Plot ist immer Blau. Um die Farbe zu verändern wird `plt.plot` der Parameter `color` übergeben. Dieser erwartet einen String. Für eine genauere Erläuterung lesen Sie die Dokumentation zu [Specifying color](https://matplotlib.org/stable/users/explain/colors/colors.html). Für dieses Notebook werden die Beispiele mit den \"Single Character Shorthands\" (Aus der Dokumentation zu entnehmen) ausgestattet.\n",
"\n",
"Plotten wir den Sinus nun in Rot:"
]
},
{
"cell_type": "code",
"execution_count": 38,
"id": "de303799-2d02-4793-a40b-f5e528bc6f42",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-1ec79feac73af81f",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGdCAYAAAAfTAk2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABPeklEQVR4nO3de3zO9f/H8cc2tiEbwmY1p5RDCZG11Le+2dccvsX324GiIYdoiMlh5VAplA4iOZ86OFS/CJXScuggRCuEEjnEJmEXk2G7fn+8v9ssp41de1+H5/12+9yu9659rs+e16Lr5f15H/ycTqcTERERES/ibzuAiIiISGFTgSMiIiJeRwWOiIiIeB0VOCIiIuJ1VOCIiIiI11GBIyIiIl5HBY6IiIh4HRU4IiIi4nWK2Q5gQ1ZWFvv27aN06dL4+fnZjiMiIiL54HQ6OXr0KBEREfj7X7iPxicLnH379hEZGWk7hoiIiFyCPXv2cPXVV1/wHJ8scEqXLg2YX1BISIjlNCIiIpIfDoeDyMjInM/xC/HJAif7tlRISIgKHBEREQ+Tn+ElGmQsIiIiXkcFjoiIiHgdFTgiIiLidVTgiIiIiNdRgSMiIiJeRwWO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M6NwZTp60nUhExAqXFzjz588nISGB4cOHs2HDBurVq0dsbCwHDhw45/kffPAB+/fvzzk2bdpEQEAA999/f57zmjdvnue8uXPnuvqtyPlkZUHXrpCRAc2bm7bYM2GC2aX9hx+0yrGI+CyXFzivvPIK3bp1o3PnztSpU4dJkyZRsmR
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, s, color='r') # Plot mit der Farbe Rot\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "dcf5f847-7d69-4b29-81a2-c2dc2c0b3e90",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-6d559d4604922bd9",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Titel für den Plot setzen\n",
"\n",
"Dafür wird [plt.title](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.title.html) der Paramter wird als String übergeben:"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "aa2a1bba-3ec6-4097-874f-508a7b11c68f",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-106786a4fca81b67",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGzCAYAAAAi6m1wAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABf0klEQVR4nO3deVxU5eIG8OfMMAz7vssmouIGKCrhUprkmmlZaVdTyeVXuVTaxr2lttzMtluaV7PcKlOzm2VWuOCWiqIoLogLCrLJJjLDvsyc3x/gFLmBMpxZnu/nM58bw5nDM6PXeXjnvO8riKIogoiIiMiEyKQOQERERNTSWHCIiIjI5LDgEBERkclhwSEiIiKTw4JDREREJocFh4iIiEwOCw4RERGZHBYcIiIiMjksOERERGRyW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CmIg2GBXeBu097O5qpEUuE9DB0x4dPO3xZC8/aLQiDl+6ip+Tc7H1ZC4uFJThzZ9T8OnOC5h+fxAm3BcAW6VB/d+LiMisGNS/wFFRUfjtt98a3bdjxw5ERUUBACwtLREREYH4+HjdxcparRbx8fGYOXNma8clA1JaVYvPd6VhzcEMVDd8DNUzwBnT7g9CdCfPFr84WC4T0CfYDX2C3fCvhzvhx6RsrDyQjqziSiz8/Sy+2p+OV4Z0xOM9fCHjhclERK1OrwWnrKwMaWlpuq/T09ORnJwMFxcX+Pv7IzY2Fjk5Ofj6668BAM8++yw+//xzvPrqq3jmmWe
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, s)\n",
"plt.title(\"Sinus Plot\") # Titel Setzen\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "f5de5666-aa6f-43cc-a230-8c54779b1f73",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-8d7bed3592e18530",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Legende und Labels\n",
"\n",
"Um eine Legende anzuzeigen muss vor `plt.show` die Funktion [plt.legend](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html) aufgerufen werden. Damit dies Wirkung zeigt braucht muss jeder Plot mit dem Parameter `label` (als String) ausgezeichnet werden. Plotten wir im Folgenden den Sinus und Kosinus mit entsprechenden Labels."
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "b6962f15-dd2d-45fe-895a-e388687847aa",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-b1d037b9a275622c",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGdCAYAAAAfTAk2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90b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dAcCvWxzNE4IUcPSTsF3w5X5nTpHpbBpN8qiFrFU5vPb/H/1FVc16AmPbYG6HZTeBN/coyzps3Lf70rgkYUxZOQV0SbIk9VPdrO44gaUDWfHd2/AsvER+Lo5cPRiFkPmbGP/uQy1owkhrN2ZTTC/j1LceATB+LXQfrRFFTeVJQWOpfGoA2N+h1YPgFGvLOtb/7ay+srKGI1GPl57gpd+PojeYGRoeCDfPxZJgKeT2tFuS+cGtVg5uStN/d1JzS5g+JfRbCi5dCWEENXu4E+wdJjSwC+oE0zcAHXaqJ3K5KTAsUT2TnDvl9CrZFf1zR/Ab08pu7paCb3ByH9WHGLWupMAPNWnEZ8MDzerVVK3I8jbhZ8mRdKziR/5RQYmfL2blfsuqB1LCGFtdsxTpjYYiqDFPTD6N2W/KBsgBY6l0mig18tw10zQaGHv1/DrZKsocor0Bqb+EMt3MQloNfDOPa2Y2q+p1a06cneyZ/7oDgwND6TYYOSZ72P5dmeC2rGEENZi+2xY85JyHPE4DFuo/IJsI6TAsXQdxsJ9i0Cjg/3fWXyRU6w38OS3+/g1NhE7rYZZD7bloYgQtWOZjL1Oy8cPhDOmSygA/1lxkB92nVM3lBDC8m3/TGngB9DzJRjwLmht6yNf1qhagxZDla8/PaoUOWiUzsdm1F67IgwGI8//uJ81h5Nw0GmZ+3A7+jar2P5ilkyr1TB9cHM0Gli
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, s, label=\"Sinus\") # Plotte Sinus mit label Sinus\n",
"plt.plot(x, c, label=\"Kosinus\") # Plotte Kosinus mit label Kosinus\n",
"plt.legend() # Füge die Legende ein\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "712b286b-d173-4aef-8bc0-04e067659a86",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-63bbc82ff5e6892a",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Linestyle\n",
"\n",
"Die letze wichtige Eigenschaft ist das Setzen eines Linestyles. Dazu wird `plt.plot` der parameter `linestyle` als String übergeben. Entnehmen Sie die verschiednen Linestyles bitte der Dokumentation zu [Linestyles](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html).\n",
"\n",
"Sinus als `dashed` line:"
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "bc6a2a76-51c3-46d8-9e07-3c3b3f2a571f",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-402e40ea2ceafc35",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGdCAYAAAAfTAk2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABVL0lEQVR4nO3deVxU9f4/8NfMADPsi+yyKq6poKCIS2lyxbLS8pp2LZdMf5lWRmVxb2llZYu3zPJmi2tpWt200sIQt1QURTF3Rdn3RWbYl5nz+wObLl9FQRk+s7yej8d53OZwzuF1xgvz5nM+i0ySJAlEREREZkQuOgARERFRe2OBQ0RERGaHBQ4RERGZHRY4REREZHZY4BAREZHZYYFDREREZocFDhEREZkdFjhERERkdqxEBxBBp9MhLy8Pjo6OkMlkouMQERFRK0iShIqKCvj6+kIuv3EbjUUWOHl5efD39xcdg4iIiG5BdnY2/Pz8bniMRRY4jo6OAJreICcnJ8FpiIiIqDU0Gg38/f31n+M3YpEFzp+PpZycnFjgEBERmZjWdC9hJ2MiIiIyOyxwiIiIyOywwCEiIiKzwwKHiIiIzA4LHCIiIjI7LHCIiIjI7LDAISIiIrPDAoeIiIjMDgscIiIiMjsGLXD27duH+++/H76+vpDJZNi6detNz9mzZw8GDBgApVKJkJAQrF279ppjVqxYgaCgIKhUKkRGRiI5Obn9wxMREZHJMmiBU1VVhdDQUKxYsaJVx6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Fs9uOo4GrldFRBaOBQ61G51OwgvfnkBFbSPC/F0w7+4Q0ZEshkIuw4eTwuCkssKJHDU+33dZdCQiIqH
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(x, s, linestyle=\"dashed\")\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "14d3e8ec-dec6-4d42-90a3-86ffdd11d061",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-88e04ff7645c08cd",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Aufgabe - Multiplot\n",
"\n",
"In der nächsten Aufgabe wollen wir gleich zwei Funktionen Plotten. $f(x) = \\sqrt x$ und $g(x) = x^2$.\n",
"\n",
"Gehen Sie dabei wie folgt vor:\n",
"1. Definieren Sie einen geeigneten [Linespace](https://numpy.org/doc/stable/reference/generated/numpy.linspace.html#numpy-linspace) für die Zahlenraum 0...3. (Tipp: Achten Sie auf die Definition! Die Wurzel ist nur für positive Zahlen definiert.)\n",
"2. Berechnen Sie mittels der Funktion [np.sqrt](https://numpy.org/doc/stable/reference/generated/numpy.sqrt.html#numpy.sqrt) die Werte für die Wurzel.\n",
"3. Berechnen Sie mittels der Funktion [np.square](https://numpy.org/doc/stable/reference/generated/numpy.square.html#numpy-square) die Werte für die Quadrat Zahlen\n",
"4. Geben Sie den beiden Plots die Farben Grün & Rot. Nutzen Sie gerne die [Color Shorthands](https://matplotlib.org/stable/users/explain/colors/colors.html) aus der Dokumentation.\n",
"5. Plotten Sie die Square Funktion mit dem Linestyle `dashdot`, wie der Dokumentation zu entnehmen [Linestyles](https://matplotlib.org/stable/gallery/lines_bars_and_markers/linestyles.html)\n",
"6. Geben Sie den beiden Plots angemessene Labels.\n",
"7. Fügen Sie die Legende hinzu.\n",
"8. Plotten Sie das Ergebnis."
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "b354952b-f922-42a7-914a-cda9522dff69",
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-6bb6ab1d60fffde5",
"locked": false,
"points": 8,
"schema_version": 3,
"solution": true,
"task": false
2024-11-14 19:06:50 +01:00
},
"scrolled": true
2024-10-25 13:28:49 +02:00
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAhYAAAGdCAYAAABO2DpVAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABMr0lEQVR4nO3dd3hT9eIG8Ddpm3RvOqClbEqhjLIsXFmyZyuyREQURYbai3iFR7mA6EVEEK4XRVSgArIt8mP1ArL3KrNShAKFTkppuuhIvr8/cgkE2tKUtCfj/TzPedqcnCRvjrF5+Z4lE0IIEBERERmBXOoAREREZDlYLIiIiMhoWCyIiIjIaFgsiIiIyGhYLIiIiMhoWCyIiIjIaFgsiIiIyGhYLIiIiMhobKv7BTUaDZKTk+Hi4gKZTFbdL09ERESVIIRATk4OatasCbm87HGJai8WycnJCAwMrO6XJSIiIiNISkpCQEBAmfdXe7FwcXEBoA3m6upa3S9PRERElaBSqRAYGKj7Hi9LtReLh5s/XF1dWSyIiIjMzLN2Y+DOm0RERGQ0LBZERERkNCwWREREZDTVvo9FRajVahQXF0sdg6yQjY0NbG1teSg0EVElmVyxyM3Nxe3btyGEkDoKWSlHR0f4+/tDoVBIHYWIyOyYVLFQq9W4ffs2HB0dUaNGDf6rkaqVEAJFRUXIyMhAYmIiGjZsWO5JYIiI6GkmVSyKi4shhECNGjXg4OAgdRyyQg4ODrCzs8PNmzdRVFQEe3t7qSMREZkVk/znGEcqSEocpSAiqjz+BSUiIiKjYbEgIiIio2GxMIKMjAyMHz8etWvXhlKphJ+fH3r16oXDhw9LHa3S9u3bB5lMpptq1KiBvn374sKFC0Z9nRUrVsDd3d2oz0lERNIxqZ03zdXgwYNRVFSE6Oho1KtX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NAg3XN07txZfPDBB0/lTEhIEJGRkcLd3V04ODiI4OBgERUVJTQaTanvq7SdSYUQ4tatW8LW1lasW7dOCKHdcTUkJETY2dmJ2rVri3nz5uktf+/ePTFq1Cjh5uYmHBwcRK9evURCQoLeMu+++67w8vISAMSMGTPKX+HVwBw/h0RkfbYnbBeYCYGZEPsS91X561V0502ZEBU8rtJIVCoV3NzckJ2dDVdXV737Hjx4gMTERNStW9cqriopk8kQExODiIgIqaPQY6ztc0hE5ierIAvNvm+G5JxkfND+AyzsvbDKX7O87+/HcVMIERGRmdmasBXJOclo5NUI/3rpX1LH0WPaO28SERHRU0a1GAV/F3+4Kl3haGfYUYxVjcVCQtW8FYqIiCxI93rdpY5QKm4KISIiMgNCCMzaNws37t+QOkq5WCyIiIjMwC/nfsHM/TPRZmkb5BTmSB2nTNwUQkREZAZeDHoRf6v9N/Rr2A8uShep45SJxYKIiMgM1POoh32j90kd45m4KYSIiMiEpeSk6H63kdvARm4jYZpnY7EgIiIyUZfSL6H+v+vj7zv/jmJ18bMfYAJYLMiszJw5Ey1btpQ6BhFRlStSF2FUzCgUlBQg4V4CbOXmsfcCi4URZGRkYPz48ahduzaUSiX8/PzQq1evp678aU727dsHmUz21PTpp59WWwaZTKa7QuxDU6ZMwZ49e6otAxGRVD7b/xnOpp6Fl4MXfhrwE2QymdSRKsQ86o+JGzx4MIqKihAdHY169eohLS0Ne/bsQWZmptTRUFRUBIVCUenHX7lyRe+c8M7OzsaIVWnOzs6SZyAiqmrHbh/DnENzAABL+i+Bv4u/xIkqjiMWz+n+/fs4ePAg5s6di65duyIoKAjt2rXDtGnTMHDgQN1yV69eRadOnWBvb4+QkBDs2rVL71/kD0cI7t+/r3tMXFw
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# BEGIN SOLUTION\n",
"xt = np.linspace(0, 3, num=200)\n",
"sqrt = np.sqrt(xt)\n",
"square = np.square(xt)\n",
"\n",
"plt.plot(xt, sqrt, color='r', label=\"Square Root\")\n",
"plt.plot(xt, square, color='g', label=\"Square Function\", linestyle=\"dashdot\")\n",
"plt.legend()\n",
"plt.show()\n",
"# END SOLUTION"
]
},
{
"cell_type": "markdown",
"id": "0f9041af-6d24-4786-969a-5f8fb9b5ba3a",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-486bea96505ad0a6",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"---\n",
"\n",
"# Plot Types\n",
"\n",
"Im folgenden Kapitel beschäftigen wir uns mit verschiedensten Plot typen."
]
},
{
"cell_type": "markdown",
"id": "4ffad0de-cd56-47e1-b327-7c9b16d46865",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-79e43d78c9874975",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Line Plots\n",
"\n",
"Line Plots haben wir im voherigen Kapitel bereits kennengelernt. Diese können mittels `plt.plot` augerufen werden.\n",
"\n",
"Beispiel Sinus:"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "2375e035-4413-4cc5-875d-5463685299f4",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-b48b1eec8fe65537",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjgAAAGdCAYAAAAfTAk2AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABZaElEQVR4nO3deVhU9eIG8PfMAMO+yS6biIqmgqISLmVJopllWWlXQ830ZmqZ3krur7TbZvstzatprmXZapndUMMtFUVRXHBFQTbZRGbYl5nz+wOc4rqBMnxneT/Pc557Hc4c3kFzXs98F0mWZRlEREREZkQhOgARERFRa2PBISIiIrPDgkNERERmhwWHiIiIzA4LDhEREZkdFhwiI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dKhYQl4yPR0dNRdCSTMqy7L54d3BEA8PL3RzmziojoBlhwqE2kZpfi9U0NM6bih4dhQKiH4ESmac7QLhgY6oGqOi2e+TIFmuo60ZGIiIwSCw4Z3OWKWkxfdwh1Whmxd3hj8kBOB79VSoWEhU/0QntXO2QUV2DOt0eg08miYxERGR0WHDIonU7G7G9TkVvaMKj4/cfCOWPqNrk72GDJ+N6wsVJg64kCLNl5TnQkIiKjw4JDBrVk5zlsP10ElZUC/xnXG8621qIjmYWe/q5446E7AAAfbjmN5IwSwYmIiIwLCw4ZzL7zl/DhltMAgDce6o47/FwEJzIvY/oGYnRvf+hk4IVvUqGu4ngcIqIrWHDIINRVdZj9TSp0MjC6tz8e78s9pgzhXw/dgaB29sgtrcL/bTgGWeZ
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"x = np.linspace(0, 2*np.pi, num=200)\n",
"y = np.sin(x) \n",
"\n",
"plt.plot(x, y) \n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "d5893a0a-65be-418b-889c-ee5d48ed1c9e",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-d81b654168ec4bc8",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Bar Charts\n",
"\n",
"Beliebt sind Barcharts. Dazu werden aber mehrere Parameter benötigt. Da einfache mathematische Funktionen bei dieser Art Plot keinen Sinn ergeben.\n",
"\n",
"Konsultieren wir dafür folgendes Beispiel.\n",
"\n",
"Wir wollen wissen wie viele Kinder an einer Grundschule in jeder Klassenstufe sind.\n",
"Dazu benötigen wir 2 Listen.\n",
"1. Die Klassenstufen\n",
"2. Die Anzahl an Kinder in der Klassenstufe"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "bc2b7a3f-0a8d-4f33-9c37-99850e33f6c6",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-3767e976a92e292a",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"classes = [\"1. Klasse\", \"2. Klasse\", \"3. Klasse\", \"4. Klasse\"]\n",
"kids = [42, 30, 26, 45]"
]
},
{
"cell_type": "markdown",
"id": "b484d826-1539-4650-891d-d80ab60f4e4f",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-a702a6b994c5809e",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"Plotten wir die Werte nun als Bar Chart mit der Funktion `plt.bar`:"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "2ceb28ef-7db1-4d2e-993b-5a0fa17b0785",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-8c604c68ae96c752",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAc10lEQVR4nO3df3TX1X348VdCSIIhCYICIqDsjBYZwo6oJXUd5YcyhhRG3JnOFVQ2znYCU9npKluHR482tDtD2zVa7XFw9BSxeoYe54rz0IFyCgpx+IuN4YaDjiY6OwKmJQK53z92zLcRVBLCDYmPxznvPz7v933fz02uJz7zySekIKWUAgAgk8LuXgAA8OkiPgCArMQHAJCV+AAAshIfAEBW4gMAyEp8AABZiQ8AIKui7l7Ah7W2tsb+/fujvLw8CgoKuns5AMBJSCnFoUOHYtiwYVFY+PGvbZxx8bF///4YMWJEdy8DAOiEffv2xfDhwz92zBkXH+Xl5RHxf4uvqKjo5tUAACfj4MGDMWLEiLb/j3+cMy4+PvhRS0VFhfgAgB7mZN4y4Q2nAEBW4gMAyEp8AABZiQ8AICvxAQBkJT4AgKzEBwCQlfgAALISHwBAVuIDAMhKfAAAWYkPACAr8QEAZCU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Xx1FNPRXl5edv7OCorK6Nfv35RWVkZCxcujKVLl8bAgQOjoqIilixZElVVVX7TBQCIiA7Gx/333x8REV/84hfbnV+1alXccMMNERFxzz33RGFhYVRXV0dLS0vMmDEj7rvvvi5ZLAD
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.bar(classes, kids)\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "a46c7700-d039-4345-b59f-4fc0d0400e95",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-c2444cb0f1af6626",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"### Bessere Datenrepresentation\n",
"\n",
"Da die Daten aus `classes` & `kids` miteinander eine Verbindung teilen wäre die Repräsentation mittels Dictionary die klügere Wahl um keine Fehler in den Plot zu bringen.\n",
"\n",
"Mittels der `.keys` & `.values` Funktion auf dem Dictionary lassen sich dann die Daten gezielt plotten.\n",
"\n",
"Schauen Sie sich daher folgendes Beispiel an:"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "63a994e2-4f9c-44c2-940a-6ea202b50e44",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-1777b8fcd5bd30c4",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCAYAAACyzRGfAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAc10lEQVR4nO3df3TX1X348VdCSIIhCYICIqDsjBYZwo6oJXUd5YcyhhRG3JnOFVQ2znYCU9npKluHR482tDtD2zVa7XFw9BSxeoYe54rz0IFyCgpx+IuN4YaDjiY6OwKmJQK53z92zLcRVBLCDYmPxznvPz7v933fz02uJz7zySekIKWUAgAgk8LuXgAA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j5aW1vjlltuiSuuuCLGjRsXERENDQ1RXFwcAwYMaDd2yJAh0dDQcMJ5amtro7Kysu0YMWJEZ5cEAPQAnY6PmpqaeP3112Pt2rWntIBly5ZFU1NT27Fv375Tmg8AOLN16D0fH1i8eHH8wz/8Qzz//PMxfPjwtvNDhw6N999/Pw4cONDu1Y/GxsYYOnToCecqKSmJkpKSziwDAOiBOvTKR0opFi9eHOvWrYsf/ehHMWrUqHbXJ06cGH379o0NGza0ndu1a1fs3bs3qqqqumbFAECP1qFXPmpqamLNmjXx1FNPRXl5edv7OCorK6Nfv35RWVkZCxcujKVLl8bAgQOjoqIilixZElVVVX7TBQCIiA7Gx/333x8REV/84hfbnV+1alXccMMNERFxzz33RGFhYVRXV0dLS0vMmDEj7rvvvi5ZLAD
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# Definiere ein Dictionary welches die Anzahl der Schüler ihrer Klasse zuweist \n",
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"plt.bar(school.keys(), school.values()) # Plotte mit den Werten des Dictionarys\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "3371f47f-319b-4387-bcca-ae2363fe0662",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-d2c659803a58f15e",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"### Styling\n",
"\n",
"Bar plots können auch gestyled werden. Hierzu wird dem Parameter `color` eine Liste mit farbwerten übergeben:"
]
},
{
"cell_type": "code",
"execution_count": 57,
"id": "ace35364-3865-4bbb-92c3-8d9804636329",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-a3604899d50585d2",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAh8AAAGdCA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EBW4gMAyEp8AABZiQ8AIKtOxUdDQ0NccsklUVlZGSNGjIj58+fH7t27O5xz+PDhqK+vj2HDhkVFRUXU1dVFc3Nzt04aAOi7OhUfW7Zsifr6+nj++efjmWeeiSNHjsSVV14ZbW1thXNuueWWePLJJ+PRRx+NLVu2xIEDB2LBggXdPnEAoG8qSimlrl789ttvx4gRI2LLli3xG7/xG9HS0hLDhw+P9evXx8KFCyMi4o033ogLLrggtm3bFtOmTfvYMVtbW6O6ujpaWlqiqqqqq1P7cEVF3T8mp6br32qnxNL2jh5e1ihabWF7S7qthxc3rG3v6f617czP79N6zUdLS0tERAwdOjQiIhobG+PIkSMxa9aswjkTJkyIsWPHxrZt2046Rnt7e7S2tnbYAID+q8vxcfz48bj55pvjsssui0mTJkVERFNTU5SWlsaQIUM6nFtTUxNNTU0nHaehoSGqq6sL25gxY7o6JQCgD+hyfNTX18drr70WGzZsOK0JrFy5MlpaWgrb/v37T2s8AODMVtKVi5YtWxb/8A//EM8++2yMHj26sH/kyJHx3nvvxcGDBzs8+tHc3BwjR4486VhlZWVRVlbWlWkAAH1Qpx75SCnFsmXLYuPGjfGDH/wgxo0b1+H41KlTY+DAgbFp06bCvt27d8e+ffuitra2e2YMAPRpnXrko76+PtavXx9PPPFEVFZWFl7HUV1dHYMHD47q6up
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"bar_colors = [\"red\", \"blue\", \"green\", \"yellow\"] # Farben definieren\n",
"\n",
"plt.bar(school.keys(), school.values(), color=bar_colors) # Farben übergeben\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "875f5a2f-9db1-49ba-a7ab-c4452f7b0cb7",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-964f579ce46a2882",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"### Y-Label\n",
"\n",
"Mit `plt.ylabel` (als String) lässt sich die y-Achse beschriften:"
]
},
{
"cell_type": "code",
"execution_count": 60,
"id": "bedf0e03-583a-4a22-857f-0d786f9365c4",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-21cee3bf50f011e1",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAGdCAYAAAAIbpn/AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAlgklEQVR4nO3df3BU9b3/8dcmIQnmx0IiSYghlFujSBEqASRiy80P5SIgkWDVcgWEFusE/BHbau5toSiY2CqiRa2ihYERURjBaxUpk0owY9AQREAE4YolFhKoXJIQJUDy+f7huF/XhLgn7LL7SZ+PmZ2Rc3YP7+Qj4cnu2bMuY4wRAACAhcKCPQAAAEBnETIAAMBahAwAALAWIQMAAKxFyAAAAGsRMgAAwFqEDAAAsBYhAwAArBUR7AECrbW1VYcOHVJcXJxcLlewxwEAAD4wxqixsVGpqakKCzv78y5dPmQOHTqkPn36BHsMAADQCTU1NUpLSzvr/i4fMnFxcZK++kbEx8cHeRoAAOCLhoYG9enTx/P3+Nl0+ZD5+uWk+Ph4QgYAAMt812khnOwLAACsRcgAAABrETIAAMBahAwAALAWIQMAAKxFyAAAAGsRMgAAwFqEDAAAsBYhAwAArEXIAAAAaxEyAADAWoQMAACwFiEDAACsRcgAAABrRQR7AAAAzp0r2AP8CzNB/d15RgYAAFiLkAEAANYiZAAAgLUIGQAAYC1CBgAAWIuQAQAA1iJkAACAtQgZAABgLUIGAABYi5ABAADWImQAAIC1CBkAAGAtQgYAAFiLkAEAANYiZAAAgLUIGQAAYC1CBgAAWIuQAQAA1iJkAAC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YoSxs8nOyLzuEPbfAE9zoyjt+1tHjxYu3fv1+pqanq27evYmJivPZv27bN+bQAAACd4Dhk8vPzAzAGAACAcyH3EQX+xktLXRQvLXVZXfsnEgKHP7TBY+FHFBw/flzPPfeciouLdezYMUlfvaT0j3/8o3PTAgAAdILjl5Z27NihvLw8ud1uffrpp/r5z3+uhIQEvfLKKzp48KCWL18eiDkBAADacPyMTFFRkaZNm6Z9+/YpOjras/26667T5s2b/TocAABARxyHTFVVlW6//fY22y+66KIOP8wRAADA3xyHTFRUVLufKP3xxx+rV69efhkKAADAF45D5vrrr9cDDzyg06dPS5JcLpcOHjyo++67TwUFBX4fEAAA4Gwch8yjjz6qEydOKCkpSV9++aVGjRqliy++WHFxcVqwYEEgZgQAAGiX43ctud1ubdy4URUVFdqxY4dOnDihIUOGKC8vLxDzAQAAnJXjkPna1VdfrauvvtqfswAAADjiU8g88cQTPh/wzjvv7PQwAAAATvj0EQX9+vXz+vXRo0f1xRdfqEePHpK+utLvBRdcoKSkJH3yyScBGbSz+IiCLoqPKOiy+IgCdA5/aIPHgo8oOHDggOe2YMEC/fCHP9RHH32kY8eO6dixY/roo480ZMgQPfjgg377AgAAAL6L4w+N/P73v681a9boiiuu8NpeXV2tSZMm6cCBA34d8FzxjEwXxTMyXRbPyKBz+EMbPBY8I/NNhw8f1pkzZ9psb2lpUV1dndPDAQAAdJrjkMnNzdXtt9+ubdu2ebZVV1frjjvu4C3YAADgvHIcMn/+85+VkpKioUOHKioqSlFRURo+fLiSk5P13HPPBWJGAACAdjm+jkyvXr30xhtv6OOPP9aePXskSf3799cll1zi9+EAAAA60ukL4l1yySXECwAACCrHIdPS0qJly5aprKxMR44cUWtrq9f+v/3tb34bDgAAoCOOQ+auu+7SsmXLNHbsWA0
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"bar_colors = [\"red\", \"blue\", \"green\", \"yellow\"]\n",
"\n",
"plt.bar(school.keys(), school.values(), color=bar_colors)\n",
"\n",
"plt.ylabel(\"Anzahl Kinder\") # Beschriften der Y-Achse\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "329b675f-75a8-49c2-a6cc-331882010127",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-32dabb34444f6190",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"### X-Label\n",
"\n",
"Analog Dazu die Beschriftung der X-Achse mit `plt.xlabel`."
]
},
{
"cell_type": "code",
"execution_count": 61,
"id": "212535af-d1db-4e08-bb9f-8e14d047cee7",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-3737280b071f9d91",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAGwCAYAAACzXI8XAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAAtLUlEQVR4nO3de1TVVf7/8dcB5BI3hRAkQZ285XgpLyVZOQJlZiaJZY2T17Lxi3axK98pzbSkpsyuTlmj3/xmlk5qWVYuRjS+XkIUrVTUwrQUtEwQSlTYvz9anV8nUDnI6ZzNPB9rnbVk789nnzdny+HFPp+LwxhjBAAAYCE/bxcAAABQXwQZAABgLYIMAACwFkEGAABYiyADAACsRZABAADWIsgAAABrBXi7AE+rrq7W/v37FR4eLofD4e1yAABAHRhjdPToUcXHx8vP79TrLo0+yOzfv18JCQneLgMAANTDvn371LJly1P2N/ogEx4eLunnFyIiIsLL1QAAgLooKytTQkKC8/f4qTT6IPPLx0kREREEGQAALHOmw0I42BcAAFiLIAMAAKxFkAEAANYiyAA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V2tyspK9ejRQ02aNFF2drazr7CwUHv37lVSUpIXKwQAAL7CrRWZEydOKCQkRAUFBercufNZP3lmZqYGDBigxMREHT16VAsWLFBOTo4++ugjRUZGauzYsZo0aZKioqIUERGhiRMnKikpqc5nLAEAgMbNrSDTpEkTJSYmqqqqqkGe/ODBgxoxYoQOHDigyMhIde3aVR999JGuvPJKSdIzzzwjPz8/paenq7KyUv3799dLL73UIM8NAADs5/Z1ZF577TW98847mj9/vqKiojxVV4PhOjKNlIdPbWFqvYezllA//NB6j3evI+P2wb4vvPCCdu/erfj4eLVq1UqhoaEu/Zs2bXK/WgAAgHpwO8ikpaV5oAwAAAD3+dwtChoaHy01Uny01Gg17nckeA4/tN5j4S0Kjhw5oldffVWZmZk6fPiwpJ8/Uvr222/rVy0AAEA9uP3R0tatW5WamqrIyEjt2bNHt912m6KiovTOO+9o7969ev311z1RJwAAQA1ur8hMmjRJo0aN0q5duxQcHOxsv+aaa7RmzZoGLQ4AAOB03A4yeXl5uv3222u0n3feeae9mSMAAEBDczvIBAUFqaysrEb7zp07FRMT0yBFAQAA1IXbQea6667To48+qhMnTkiSHA6H9u7dqwceeEDp6ekNXiAAAMCpuB1knn76aZWXl6t58+b66aef1LdvX7Vt21bh4eF67LHHPFEjAABArdw+aykyMlIrV65Ubm6utm7dqvLycnXv3l2pqameqA8AAOCU3A4yv7jssst02WWXNWQtAAAAbqlTkHnuuefqPOAdd9xR72IAAADcUadbFLRp08bl60OHDunHH39U06ZNJf18pd9zzjlHzZs311dffeWRQuuLWxQ0UtyioNHiFgWoH35ovceCWxQUFRU5H4899pguvPBCbd++XYcPH9bhw4e1fft2de/eXdOmTWuwbwAAAOBM3L5p5Pnnn6/FixfroosucmnPz8/X0KFDVVRU1KAFni1WZBopVmQaLVZkUD/80HqPBSsyv3bgwAGdPHmyRntVVZVKSkrcHQ4AAKDe3A4yKSkpuv3227Vp0yZnW35+vsaPH88p2AAA4HfldpD55z//qbi4OPXs2VNBQUEKCgrSxRdfrNjYWL366queqBEAAKBWbl9HJiYmRh988IF27typHTt2SJI6duyo9u3bN3hxAAAAp1PvC+K1b9+e8AIAALzK7SBTVVWlefPmKTs7WwcPHlR1dbVL/7///e8GKw4AAOB03A4yd955p+bNm6eBAwe
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"bar_colors = [\"red\", \"blue\", \"green\", \"yellow\"]\n",
"\n",
"plt.bar(school.keys(), school.values(), color=bar_colors)\n",
"\n",
"plt.ylabel(\"Anzahl Kinder\") # Beschriften der Y-Achse\n",
"plt.xlabel(\"Klassenstufen\") # Beschriften der X-Achse\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "147244b1-7bdc-40bc-9f87-93997f9742ed",
"metadata": {
2024-11-14 19:06:50 +01:00
"jp-MarkdownHeadingCollapsed": true,
2024-10-25 13:28:49 +02:00
"nbgrader": {
"grade": false,
"grade_id": "cell-230328a26793cddb",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"### Aufgabe\n",
"\n",
"Ihnen ist ein Datenset `sec_school` einer Hauptschule gegeben, welches die Klassenstufen von 5 bis 9 auf die Anzahl ihrer Schüler im Jahrgang mappt. \n",
"\n",
"Definieren Sie einen Barplot. Gehen Sie dabei wie folgt vor:\n",
"1. Definieren Sie ein geeignetes Farbschema zur Darstellung der Daten.\n",
"2. Extrahieren Sie die Schlüssel und Werte aus dem Datenset und übergeben Sie diese zusammen mit den Farbwerten an die Funktion `plt.bar`.\n",
"3. Setzen Sie geeignete Werte für die X & Y-Achse.\n",
"4. Setzen Sie einen geeigneten Titel für den Plot.\n",
"5. Plotten Sie den Werte"
]
},
{
"cell_type": "code",
"execution_count": 64,
"id": "faec1d5e-c08c-4401-9fbd-5e324c045555",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-b954e989a8bbc2fa",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"sec_school = {\n",
" '5. Klasse': 29,\n",
" '6. Klasse': 35,\n",
" '7. Klasse': 25,\n",
" '8. Klasse': 28,\n",
" '9. Klasse': 31\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 65,
"id": "0713b074-1eb9-4b5a-ae37-7ee237f814d9",
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-8caba57a6ad34b87",
"locked": false,
"points": 5,
"schema_version": 3,
"solution": true,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjIAAAHHCAYAAACle7JuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABM/klEQVR4nO3deXxMd////+ckkUlEEkKIEEFstbW11Z4ShKJV1FJXa2tpiy66XbpY26KL6tWqan1Kq3a19NKiilhKe9lVLQ2l9qVUEkGQvH9/9Jf5GkmYYWJy9HG/3eZ2M2d5n9e8zzmTp7ONzRhjBAAAYEE+3i4AAADgRhFkAACAZRFkAACAZRFkAACAZRFkAACAZRFkAACAZRFkAACAZRFkAACAZRFkAACAZRFk/uEmT54sm82m/fv3O4bde++9uvfee71Wk6cNHTpUNpstz7d5sxISEmSz2ZSQkODtUnANpUuXVps2bTza5u22z7oju+8wuG7KlCmqVKmS8uXLp4IFC3q7nBtCkPGg+++/X/nz51dKSkqO03Tr1k3+/v46derUTS/vyJEjGjp0qLZs2XLTbVlN5pfXhg0bnIYnJSWpTp06CggI0OLFi71UHa507733qmrVqtmO279/v2w2m959991bXFX2/sn7VF6SGcrnzJnjNPzixYtq06aNfHx89Pnnn3upurxh2rRpGjt27E21sWvXLvXo0UMxMTH67LPP9Omnn3qmuFuMIONB3bp10/nz5zVv3rxsx587d04LFixQy5YtVbhw4Zte3pEjRzRs2LCb+tJ95JFHdP78eUVHR990Pd6WnJysFi1aaNu2bZo3b55atmwpSXrttdd0/vx5L1eX+xo3bqzz58+rcePG3i7FsjyxTyF3XLp0SR07dtR3332nzz77TL169fJ2SV7liSCTkJCgjIwMffDBB+rRo4c6derkmeJuMYKMB91///0KDg7WtGnTsh2/YMECpaamqlu3bje1nMuXL+vixYs31UYmX19fBQQE5LnTJO5KSUlRfHy8tmzZoq+//lqtWrVyjPPz81NAQIAXq7u+c+fO3XQbPj4+CggIkI/Prd2tMzIydOHChVu6TORdFy5cUEZGhkfbvHTpkjp16qSFCxdqwoQJ6t27t0fb/6c6ceKEJFn2lFImgowHBQYGqn379lq2bJljA7nStGnTFBwcrPvvv1+SdObMGT377LOKioqS3W5XuXLlNHr0aKcvgSsPvY8dO1YxMTGy2+36+OOPVbt2bUlSz549ZbPZZLPZNHnyZMe8P//8s1q2bKnQ0FDlz59fsbGx+vHHH51qcuX8ck7TZHdNRuZphB07dqhJkybKnz+/SpQoobfffjtLu3/88Yfuv/9+BQUFqWjRonruuee0ZMkSt6/zOHv2rFq2bKlNmzbp66+/VuvWrZ3GZ3c9i81mU//+/TV//nxVrVpVdrtdVapUyfZ01Jo1a1S7dm0FBAQoJiZGEyZMyLGWr776SjVr1lRgYKDCwsLUpUsXHTx40GmazD7auHGjGjdurPz58+uVV1655mfctWuXOnbsqLCwMAUEBKhWrVr65ptvnKa52fWRlpamIUOGqFy5crLb7YqKitJLL72ktLS0bPtu6tSpqlKliux2u0dP450+fVovvPCCqlWrpgIFCigkJEStWrXS1q1bnaa7ke1y48aNql+/vgIDA1WmTBl98sknTvNda59KTExUhw4dFBERoYCAAJUsWVJdunRRUlKS0/K/+uor1alTR/nz51ehQoXUuHFjff/991k+55o1axynQcuWLasvv/zSaXxO12G5ek2Iq+szO670l/T/+nrGjBl67bXXVKJECeXPn1/JycmSpNmzZzv2hyJFiuhf//qXDh8+fN3lX+ny5cvq0qWLFixYoPHjx+vxxx+/7jwLFixQ69atFRkZKbvdrpiYGI0YMULp6elO07myTpcuXaqGDRuqYMGCKlCggCpWrJhlf3V337ne905KSoqeffZZlS5dWna7XUWLFlXz5s21adMmSX+vn2+//VZ//PGHYzstXbq0JNf3i9KlS2vIkCGSpPDwcNlsNg0dOtQx/aJFi9SoUSMFBQUpODhYrVu31q+//nrdvvcGP28XcLvp1q2bvvjiC82aNUv9+/d3DD99+rSWLFmirl27KjAwUOfOnVNsbKwOHz6svn37qlSpUlq7dq0GDRqko0ePZjlkOGnSJF24cEF9+vSR3W7Xgw8+qJSUFA0ePFh9+vRRo0aNJEn169eXJC1fvlytWrVSzZo1NWTIEPn4+GjSpElq2rSpVq9erTp16uRaH/z1119q2bKl2rdvr06dOmnOnDl6+eWXVa1aNceRktTUVDVt2lRHjx7VM888o4iICE2bNk0rVqxwa1mpqalq1aqV1q9frzlz5rh1EeWaNWs0d+5cPfXUUwoODtZ//vMfdejQQQcOHHCc+vvll1/UokULhYeHa+jQobp8+bKGDBmiYsWKZWnvzTff1Ouvv65OnTrpscce08mTJ/Xhhx+qcePG2rx5s9P/ek6dOqVWrVqpS5cu+te//pVte5l+/fVXNWjQQCVKlNC///1vBQUFadasWWrXrp2+/vprPfjgg9f8nK6sj4yMDN1///1as2aN+vTpozvuuEO//PKL3n//ff3222+aP3++U5vLly93bONFihRxfInmJD09XX/++We2tV3t999/1/z58/XQQw+pTJkyOn78uCZMmKDY2Fjt2LFDkZGR11zWtfrhvvvuU6dOndS1a1fNmjVLTz75pPz9/dWrVy/dcccdGj58eLb71MWLFxUfH6+0tDQNGDBAEREROnz4sBYuXKgzZ84oNDRUkjRs2DANHTpU9evX1/Dhw+Xv76+ff/5Zy5cvV4sWLRy17NmzRx07dlTv3r3VvXt3ff755+rRo4dq1qypKlWq3NDnu5K76/NG+utKI0aMkL+/v1544QWlpaXJ399fkydPVs+ePVW7dm2NHDlSx48f1wcffKAff/wxy/6Qk8uXL6tr166aN2+exo0bp759+7r0+SdPnqwCBQpo4MCBKlCggJYvX67BgwcrOTlZ77zzjiS5tE5//fVXtWnTRtWrV9fw4cNlt9u1Z88ep/8QutvXrnzvPPHEE5ozZ4769++vypUr69SpU1qzZo127typGjVq6NVXX1VSUpIOHTqk999/X5JUoEABl/om09ixY/Xll19q3rx5Gj9+vAoUKKDq1atL+vsC4O7duys+Pl6jR4/WuXPnNH78eDVs2FCbN2++7v5+yxl41OXLl03x4sVNvXr1nIZ/8sknRpJZsmSJMcaYESNGmKCgIPPbb785Tffvf//b+Pr6mgMHDhhjjNm3b5+RZEJCQsyJEyecpl2/fr2RZCZNmuQ0PCMjw5QvX97Ex8ebjIwMx/Bz586ZMmXKmObNmzuGTZo0yUgy+/btcwyLjY01sbGx15zGGGNWrFhhJJkVK1Y4zSvJfPnll45haWlpJiIiwnTo0MEx7L333jOSzPz58x3Dzp8/bypVqpSlzexk1hQdHW3y5cvn1M7VhgwZYq7e1CUZf39/s2fPHsewrVu3Gknmww8/dAxr166dCQgIMH/88Ydj2I4dO4yvr69Tm/v37ze+vr7mzTffdFrOL7/8Yvz8/JyGZ/bRJ598cs3PmCkuLs5Uq1bNXLhwwTEsIyPD1K9f35QvX94x7GbWx5QpU4yPj49ZvXq107Izt9sff/zRMUyS8fHxMb/++qtL9WfWcK3XO++845j+woULJj093amNffv2GbvdboYPH+4YdiPb5XvvvefUD3fddZcpWrSouXjxojEm531q8+bNRpKZPXt2jp8zMTHR+Pj4mAcffDBL/Vfuh9HR0UaSWbVqlWPYiRMnjN1uN88//7xjWHbbbU6f++p91p31mR1X+yuzr8uWLWvOnTvnmPbixYumaNGipmrVqub8+fOO4QsXLjSSzODBg6+5/Mx2M/tq3LhxOU6bXX9cWUumvn37mvz58zv2I1fW6fvvv28kmZMnT+Y4jbv7jivfO6GhoaZfv345LtMYY1q3bm2io6OzDHdnv8jcxq78fCkpKaZgwYLm8ccfd5r
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# BEGIN SOLUTION\n",
"colors = [\"red\", \"blue\", \"green\", \"yellow\", \"pink\"]\n",
"plt.bar(sec_school.keys(), sec_school.values(), color=colors)\n",
"plt.xlabel(\"Klassenstufe\")\n",
"plt.ylabel(\"Anzahl Kinder\")\n",
"plt.title(\"Verteilung Kinder einer Hauptschule pro Klassenstufe\")\n",
"plt.show()\n",
"# END SOLUTION"
]
},
{
"cell_type": "markdown",
"id": "75b88cfc-ac01-4af4-9b90-ca3a3f522115",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-42bf44a09515d0fd",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Horizontales Bar Chart\n",
"\n",
"Analog zum Barchart erzeugt `plt.barh` einen Horizontales Barchart.\n",
"\n",
"Beispiel:"
]
},
{
"cell_type": "code",
"execution_count": 87,
"id": "43ec4deb-261a-43c7-ac88-8f43338420b8",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-54166820b406e29e",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAl8AAAGwCAYAAACXRQDXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA020lEQVR4nO3de1hVdd7//9cG5CTsLaImeADKU5aa4pjI1zESJdOUzMMwplmZzoSN5tVkjKnZVNrBUru7GzuM2sx4yvEwo2PJrYCmeBbSVDRTYBLFGxMEEwTW7w9/7nv2QA5st2sjPh/Xta/LvdZnf9Z77c80vK7P+qy1LYZhGAIAAIApPNxdAAAAwO2E8AUAAGAiwhcAAICJCF8AAAAmInwBAACYiPAFAABgIsIXAACAibzcXQAcVVZW6vTp0woMDJTFYnF3OQAAoAYMw9DFixcVGhoqD4/rz20RvuqY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T/Pz8FBwcrNjYWJWUlEi6ehmzR48eatiwoRo1aqTo6GhlZ2fbP7tu3Tp169ZNvr6+uvPOOzVr1iyVl5c7dU4AAKB+8XJ3AddUVFTo888/V0lJiaKiomr9+aysLP32t79V9+7dtWzZMvn4+Pxk28uXLysyMlJTp06V1WrVhg0bNHr0aN11113q0aOH8vLylJCQoLfeekuPPvqoLl68qG3btskwDJWXlys+Pl7PPPOMli1bprKyMu3evVsWi0WStG3bNo0ZM0YLFixQ7969deLECY0fP16SNHPmzCq
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"plt.barh(list(school.keys()), list(school.values()), color=\"maroon\") # barh statt bar\n",
"\n",
"plt.xlabel(\"Anzahl Kinder\") \n",
"plt.ylabel(\"Klassenstufen\") \n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "d5275062-b7f5-4193-9b5a-70f4e861c819",
"metadata": {
2024-11-14 19:06:50 +01:00
"jp-MarkdownHeadingCollapsed": true,
2024-10-25 13:28:49 +02:00
"nbgrader": {
"grade": false,
"grade_id": "cell-3adde3f53176bcb0",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Pie Chart <3\n",
"\n",
"Kommen wir als nächstes zu der besten, tollsten und schönsten Darstellung von Daten. Den KUCHENDIAGRAMMEN!\n",
"\n",
"![](https://flowingdata.com/wp-content/uploads/2014/12/Pie-Pyramid-620x311.png)\n",
"\n",
"Kuchendiagramme können mittels `plt.pie` erstellt werden. Nehmen wir dazu wieder das Beispiel aus voherigem Kapitel. Dabei verlangt das Pie Chart nur die Werte (`school.values`) des Datensets:"
]
},
{
"cell_type": "code",
"execution_count": 94,
"id": "0e4c5699-5710-4c32-b4cc-e275bec35cc8",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-46cde6d166912ad0",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAGbCAYAAAAr/4yjAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAA8k0lEQVR4nO3dd3hUVcIG8PfOZGbSe0JICAFCbyJRQIpITSLFgiBgoYkgfovu54rlYxddXfuCCrsiqIgVRWysSlFBivQmSAtdekIK6Zlyvj9C7hKSQMpMztx739/z5AlMprxT31vOnKsIIQSIiIgAmGQHICIi78FSICIiFUuBiIhULAUiIlKxFIiISMVSICIiFUuBiIhULAUiIlKxFIiISKXbUnjmmWegKIrsGIZ2yy234JZbblH/f+zYMSiKgvfff19aJnfia8y93n//fSiKgmPHjrn9uhVFwf/8z/+49TqbNGmCsWPHuvU6vYGmSqHsRbN169Zyp+fk5KBLly7w9fXFsmXLJKXTl++//x7PPPOM7BhUS8XFxZg9ezZ69uyJsLAwWK1WxMbGYujQofj000/hdDplRyQvpalSqMzFixcxcOBA/Pbbb/jqq6+QkpIiO5IufP/993j22WfrdB0rVqzAihUr3JTI+0yfPh2FhYWyY1SQnp6OHj16YOrUqQgMDMT06dPx9ttv409/+hPy8/MxevRovPDCC7JjkpfykR2gLnJzc5GcnIydO3fiyy+/RGpqquxImpefn4+AgAC3XJfVanXL9XgrHx8f+PjU/1uoqKgIVqsVJlPly3T33XcfduzYgSVLluDOO+8s97ennnoKW7duxYEDB+p0G6Rfmn3G8/LykJKSgu3bt2PJkiUYNGjQNS+zYMEC9O3bF9HR0bDZbGjbti3eeuutCufbunUrkpOTERkZCT8/PzRt2hTjx48vd55FixYhKSkJQUFBCA4ORocOHfDGG2+UO092djYeffRRxMfHw2azoXnz5nj55ZfhcrnU85RtZ3/ttdcwb948J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werGYUQWLJkCYYMGQIhRLnbSU5ORk5ODrZv317uOseMGVNhSboyZZuVLr/vADB37lxERUWpPz179qxw2erextW0bdtWfU4AICoqCq1atSr3Ov7+++/RrVu3cmusUVFR5TZpAdV7Ly5ZsgSKomDGjBkV/nbl5p5rPS91VdP3vLfSZCm8/fbbsFqtSElJueYOs8utX78e/fv3R0BAAEJDQxEVFYWnn34aANRS6N27N4YNG4Znn30WkZGRuO2227BgwQIUFxer1zNlyhS0bNkSqampaNSoEcaPH19h22RaWhqWLVtW7o0YFRWF/v37AyhdNb5c48aNy/2/7IPv8u30w4cPh8lkwmeffQag9MNl8eLFSE1NRXBwsHq7QOkb/Mrbfuedd1BcXKze1zJNmzat9mOYlpaGnJwcREdHV7j+vLy8CvfL3a71OJXtc2nevHmFy1Z22pXKHr++fftWuH8rVqyo1v27MmNZzrKM6enpyM7Oxrx58yrcxrhx4wBUfH1U9zkKCgoCULrP7XLDhg3DypUrsXLlSnTs2LHSy9bkdVCVa913oPQ5atGiRYXztWrVqtz/q/NePHz4MGJjYxEeHu6WbHVR0/e8t9LkPoW2bdvi+++/R79+/TBgwACsX7/+mmsNhw8fRr9+/dC6dWvMnDkT8fHxsFqt+P777zFr1ix16VlRFHzxxRfYuHEjli5diuXLl2P8+PH45z//iY0bNyIwMBDR0dHYuXMnli9fjh9++AE//PADFixYgPvvvx8LFy4EULrza8CAAZg2bVqleVq2bFnu/2azudL
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"plt.pie(school.values()) # Pie Chart\n",
"\n",
"plt.title(\"Klassenverteilung einer Grundschule\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "d44f2914-3a55-4f00-b580-498931891efa",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-aec08dc408437049",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Styling\n",
"\n",
"Alle Parameter wie `title`, `color`, `xlabel`, `ylabel`, etc. lassen sich auch für das Pie Chart setzen. Die Beschriftung der einzelnen Stücke jedoch Funktioniert etwas anders.\n",
"\n",
"Dazu wird der Parameter `label` mit den dazugehörigen Werten ausgestattet:"
]
},
{
"cell_type": "code",
"execution_count": 95,
"id": "130abb6f-9241-4d2f-8975-8baaf7df6482",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-c742155fd484b71b",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAGbCAYAAAAFuq0xAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABQiElEQVR4nO3dd1wT9/8H8NclJIQNMmQoCDgQxYW1KvpFBEUq7lVEEUe1VVttf63Vb+1wtfqttfrtsI6Kfuus1lGti1ZRHOAC3IoDcYAie0OS+/1BSUVQQwh8ktz7+XjwEMPl7pVA8srdfe6O43meByGEEKIBEesAhBBC9BeVCCGEEI1RiRBCCNEYlQghhBCNUYkQQgjRGJUIIYQQjVGJEEII0RiVCCGEEI1RiRBCCNEYlQiAL774AhzHsY4haL169UKvXr1U/09JSQHHcVi/fj2zTNpEf2PatX79enAch5SUFK3Pm+M4TJ8+XavzbNasGSIjI7U6T11hsCVS+Ud27ty5Krfn5uaiS5cukMlkOHjwIKN0hmX//v344osvWMcgGiotLcV3332HHj16wMbGBlKpFM7Ozhg4cCC2bNkChULBOiLRYQZbIjXJy8tD3759cfHiRezatQv9+vVjHckg7N+/H/PmzavTPA4fPozDhw9rKZHumTt3LoqLi1nHqCYjIwN+fn547733YG5ujrlz52LVqlV49913UVhYiNGjR+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45+50rGzszN69uyJX3/9Ff/+978RFxeH1NR
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"plt.pie(school.values(), labels=school.keys()) # Setzen der Labels\n",
"\n",
"plt.title(\"Klassenverteilung einer Grundschule\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "5a3a3264-e1af-4c7f-91f9-8bae4dfedb32",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-5336af155ef45527",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"Zum setzen von Prozentwerten wird der Parameter `autopct` verwendet. Dieser nutzt einen Format String oder eine Funktion zum definieren der Werte. Schaue dazu für mehr in die Dokumentation für [autpct](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pie.html#matplotlib-pyplot-pie), eine Dokumentation zu Formatstrings findest du [hier](https://www.geeksforgeeks.org/format-specifiers-in-c/).\n",
"\n",
"Beispiel für Prozentwerte:"
]
},
{
"cell_type": "code",
"execution_count": 96,
"id": "f575e892-bbe5-45ae-8df4-f1dfa54b1d1b",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-183044afa87a0492",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAGbCAYAAAAFuq0xAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABe90lEQVR4nO3deVxU9f7H8dfMMMOwgwgKKIq7KK5lGnnJFc01Lc3cl/Smtv6qm7fV9m7e0tuqdlNvpZaWleaSpbjvivuuiAsgsu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UvRktW7aMvn374unpWbxfKHpDuHnfX375JXl5ecWP9bqQkJByP4enT58mLS0Nf3//UtvPzMws9biq2p2ep+vHjJo0aVLqvmUtu9n156979+6lHt9vv/1Wrsd3c8brOa9nTExMJDU1lXnz5pXax/jx44HS/x/l/Rt5eHgARccMbzR06FDWr1/P+vXradOmTZn3rcj/wa3c6bFD0d+oadOmpdZr3rx5id/L81o8e/YsgYGB1KpVq0qyVUZFX/PWzO6PiYSGhrJ69Wp69OhBr1692LZt2x1bJWfPnqVHjx60aNGCDz/8kPr162MwGFi9ejUfffRR8adzjUbD8uXL2blzJytXrmTdunVMmDCBf//73+zcuRN3d3f8/f2Jjo5m3bp1rFmzhjVr1rBgwQLGjBnDokWLgKKDfb169eKFF14oM0+zZs1K/K7T6cpcT7nhSseBgYF07dqV77//nn/+85/s3LmT2NjY4uMy1/c
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"plt.pie(school.values(), labels=school.keys(), autopct='%1.1f%%') # Setzen von Prozentwerten\n",
"\n",
"plt.title(\"Klassenverteilung einer Grundschule\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "b53f5919-ed5a-4a68-9420-911098cf2491",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-430a11a7f58f4fa5",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"Pie Charts haben auch einen Parameter `shadow`. Dieser ist Standardmässig `False`. Setzt man den Wert auf `True` sieht man einen Schatten:"
]
},
{
"cell_type": "code",
"execution_count": 98,
"id": "f5f47060-123c-4b4f-b518-4fc0a795dfb0",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-408e63a1464d64ea",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
2024-11-14 19:06:50 +01:00
},
"scrolled": true
2024-10-25 13:28:49 +02:00
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZEAAAGbCAYAAAAFuq0xAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABvNklEQVR4nO3dd3hUZfrw8e/MZErapAdIIYRQA0EgimBgAQkEpAiiIFLEyq646u7rqqyuLpZVV9fVVde1/ER3FRuKXREVpHdCkQ4JAVJI75l2zvtHIBASIBmSnGRyf65rriRnnjnnPpOZuecp53l0qqqqCCGEEG7Qax2AEEKItkuSiBBCCLdJEhFCCOE2SSJCCCHcJklECCGE2ySJCCGEcJskESGEEG6TJCKEEMJtkkSEEEK4TZII8Ne//hWdTqd1GO3aiBEjGDFiRM3f6enp6HQ63nnnHc1iakryGmta77zzDjqdjvT09Cbft06n4+67727SfXbp0oW5c+c26T5bC49NIqdfZFu2bKm1vbi4mEGDBmGxWPj+++81is6zfPvtt/z1r3/VOgzhJpvNxssvv8zQoUMJCgrCZDIRERHBpEmT+OCDD3C5XFqHKFoxj00i9SkpKWHMmDHs3LmTpUuXMnbsWK1D8gjffvstCxcuvKR9/PDDD/zwww9NFFHr88gjj1BZWal1GHXk5uaSlJTEPffcg5+fH4888givv/46v//97ykvL+emm27ib3/7m9ZhilbMS+sAWkppaSkpKSmkpqby2WefMW7cOK1DavPKy8vx9fVtkn2ZTKYm2U9r5eXlhZdXy7/dqqqqMJlM6PX1f1+cPXs227dv59NPP+W6666rdd+CBQvYsmUL+/fvv6RjCM/WLv7rZWVljB07lm3btvHpp58yfvz4iz5m0aJFXH311YSHh2M2m4mPj+e1116rU27Lli2kpKQQGhqKt7c3sbGx3HrrrbXKfPjhhyQmJuLv74/VaiUhIYGXXnqpVpmioiLuu+8+oqOjMZvNdOvWjWeffRZFUWrKnO4neP7553njjTeIi4vDbDZzxRVXsHnz5ppyzz//PDqdjqNHj9aJd8GCBZhMJgoLC2u2bdy4kbFjxxIQEICPjw/Dhw9n7dq1tR53uk1/z5493HTTTQQFBTF06FDmzp3Lq6++ClS3JZ++naYoCi+++CJ9+vTBYrHQoUMH5s2bV+v4ULdPpD7nKzN37ly6dOnS6OfptE8++YT4+HgsFgt9+/Zl6dKldfZ5Id999x3Dhg3D19cXf39/xo8fz6+//lqrTH19Iqfb3j///HP69u2L2WymT58+9TaznjhxgltvvZUOHTrUlHv77bdrlVm5ciU6nY4PP/yQRx55hMjISHx8fCgpKak37vXr17Ns2TLuvPPOOgnktMsvv5yZM2c26Bjn6/epr/+iS5cuTJgwgTVr1tQ0L3ft2pX//ve/dR7/66+/cvXVV+Pt7U1UVBRPPvlkrffFaQ15LyqKwksvvURCQgIWi4WwsDDGjh1bp9kbuOj/5XyvkYb2fzXkPd8WeHxNpLy8nHHjxrF582aWLFnChAkTGvS41157jT59+jBp0iS8vLz46quvuOuuu1AUhfnz5wNw8uRJxowZQ1hYGA899BCBgYGkp6fz2Wef1exn+fLlzJgxg1GjRvHss88CsHfvXtauXcu9994LQEVFBcOHD+fEiRPMmzePzp07s27dOhYsWEBWVhYvvvhirdgWL15MaWkp8+bNQ6fT8fe//53rrruOI0eOYDQamTZtGg888AAff/wxf/rTn2o99uOPP2bMmDEEBQUB8PPPPzNu3DgSExN57LHH0Ov1NQl09erVDBo0qNbjb7jhBrp3787f/vY3VFVlwIABZGZmsnz5cv73v//VeR7nzZvHO++8wy233MI999xDWloar7zyCtu3b2ft2rUYjcYG/T/ccbHnCeCbb75h+vTpJCQk8PTTT1NYWMhtt91GZGRkg47xv//9j5tvvpmUlBSeffZZKioqeO211xg6dCjbt2+/aCJas2YNn332GXfddRf+/v7861//YurUqWRkZBASEgJATk4OgwcPrkk6YWFhfPfdd9x2222UlJRw33331drnE088gclk4v7778dms523lvfVV18BMGvWrAadqzvHuJBDhw5x/fXXc9ttt3HzzTfz9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zzXW+qdfndDPX2ecO8J///IewsLCa29ChQ+s8tqHHuJD4+Pia/wlAWFgYPXv2rPU6/vbbbxk8eHCtGnFYWFitJjZo2Hvx008/RafT8dhjj9W579zmp4v9Xy5VY9/zrZnHJ5HXX38dk8nE2LFjL9pBeLa1a9eSnJyMr68vgYGBhIWF8ec//xmgJokMHz6cqVOnsnDhQkJDQ7n22mtZtGgRNputZj933XUXPXr0YNy4cURFRXHrrbfWaVs9ePAg33//fa03blhYGMnJyUB1Vf1snTt3rvX36Q/Ks/sZbrjhBvR6PR999BFQ/WH0ySefMG7cOKxWa81xofoD4dxjv/XWW9hstppzPS02NrbBz+HBgwcpLi4mPDy8zv7LysrqnFdTu9jzdLrPqFu3bnUeW9+2c51+/q6++uo65/fDDz806PzOjfF0nKdjzM3NpaioiDfeeKPOMW655Rag7uujof8jf39/oLrP8GxTp05l+fLlLF++nH79+tX72Ma8Ds7nYucO1f+j7t271ynXs2fPWn835L14+PBhIiIiCA4ObpLYLkVj3/Otmcf3icTHx/Ptt98yatQoRo8ezdq1ay9aKzl8+DCjRo2iV69evPDCC0RHR2Mymfj222/55z//WfPtXKfTsWTJEjZs2MBXX33FsmXLuPXWW/nHP/7Bhg0b8PPzIzw8nNTUVJYtW8Z3333Hd999x6JFi5gzZw7vvvsuUN3ZN3r0aB544IF64+nRo0etvw0GQ73l1LNWOo6IiGDYsGF8/PHH/Pn
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"plt.pie(school.values(), labels=school.keys(), autopct='%1.1f%%', shadow=True) # Zeige einen Schatten\n",
"\n",
"plt.title(\"Klassenverteilung einer Grundschule\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "4dc1531b-4c95-4f39-8f47-209e0df9cdc8",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-376fc818f2a3d818",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"Zum herausnehmen von Kuchenstücken gibt es den Parameter `explode` dieser erwartet eine Liste mit Fließkommezahlen die zwischen 0.0 - Standardwert und 1.0 - absoluter Explode liegen.\n",
"\n",
"Beispiel Klasse 3 ist vom Ursprung 20% entfernt:"
]
},
{
"cell_type": "code",
"execution_count": 99,
"id": "5788aefe-5e4f-4430-b7a6-af82f3b1541b",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-e3921561732c3895",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAakAAAGbCAYAAAB+nm/9AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABiwklEQVR4nO3dd1gU59oG8Ht22UbvvQoKothILEEPwYY9doO9Rc+JJib5UjRdTWKMxqMxOYmaRE3sJZrYNSr2rqhYEAtgQaQsbSnb5vuDuIqALOzAzC7P77q4lNnZd+/ZZffZd+addxiWZVkQQgghAiTiOwAhhBBSFSpShBBCBIuKFCGEEMGiIkUIIUSwqEgRQggRLCpShBBCBIuKFCGEEMGiIkUIIUSwqEgRQggRLCpS9eTzzz8HwzB8x2jQXn75Zbz88suG31NSUsAwDFasWMFbJi7R3xi3VqxYAYZhkJKSwnnbDMNg6tSpnLYZGBiIsWPHctqmEFCRMsHjP+KzZ8+WW56Xl4e2bdtCLpdj9+7dPKWzLDt37sTnn3/OdwxSS6WlpVi8eDE6duwIJycnSKVSeHt7o1+/fli7di10Oh3fEYlAUZHiWH5+Prp3745Lly5hy5Yt6NGjB9+RLMLOnTsxc+ZMk9rYu3cv9u7dy1Ei4fn4449RXFzMd4wKMjMzERUVhTfffBO2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LixfvhyjR4/GypUrAZQdzO3WrRvef//9SvM0adKk3O9isbjS9ViWNfzf29sbnTp1woYNG/Dhhx/i5MmTSEt
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"school = { \n",
" \"1. Klasse\": 42,\n",
" \"2. Klasse\": 30,\n",
" \"3. Klasse\": 26,\n",
" \"4. Klasse\": 45,\n",
"}\n",
"\n",
"plt.pie(school.values(), labels=school.keys(), autopct='%1.1f%%', explode=[0, 0, 0.2, 0]) # Zeige einen Schatten\n",
"\n",
"plt.title(\"Klassenverteilung einer Grundschule\")\n",
"\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "cb2b8d52-cd07-4ed4-a4b6-46d90fd6b614",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-ed3d080835960776",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"## Aufgabe\n",
"\n",
"Ihnen ist ein Datenset `sec_school` einer Hauptschule gegeben, welches die Klassenstufen von 5 bis 9 auf die Anzahl ihrer Schüler im Jahrgang mappt. \n",
"\n",
"Definieren Sie einen Pieplot. Gehen Sie dabei wie folgt vor:\n",
"1. Definieren Sie ein geeignetes Farbschema zur Darstellung der Daten.\n",
"2. Extrahieren Sie die Schlüssel und Werte aus dem Datenset und übergeben Sie diese zusammen mit den Farbwerten an die Funktion `plt.pie`. (Nutzen Sie zum Anzeigen der Prozentwerte autopct='%1.1f%%')\n",
"3. Lassen Sie die 6. Klasse 25% und die 9. Klasse 40% explodieren.\n",
"4. Setzen Sie einen geeigneten Titel für den Plot.\n",
"5. Plotten Sie den Werte."
]
},
{
"cell_type": "code",
"execution_count": 104,
"id": "143c7633-8e06-45a5-9aff-864eb0dc21d3",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-bf48088c515caf5c",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [],
"source": [
"sec_school = {\n",
" '5. Klasse': 29,\n",
" '6. Klasse': 35,\n",
" '7. Klasse': 25,\n",
" '8. Klasse': 28,\n",
" '9. Klasse': 31\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 105,
"id": "32479818-10ee-4800-86b6-a811bc72cb03",
"metadata": {
"nbgrader": {
"grade": true,
"grade_id": "cell-d201bd3e919fcf1c",
"locked": false,
"points": 5,
"schema_version": 3,
"solution": true,
"task": false
2024-11-14 19:06:50 +01:00
},
"scrolled": true
2024-10-25 13:28:49 +02:00
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAeAAAAGbCAYAAAAcMUOXAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAAB6G0lEQVR4nO3dd3hTZfvA8W+SNt2bttBBaQu0jCJDkCkioyDIVBGRJSjvDxSV14Xi3oK+KiqKAxEU2QIiSxFk7z1LoayWtnTvkZzfH5VKbYG2NDlJen+uK5c2OTnPfUKSO8/WKIqiIIQQQgiz0qodgBBCCFEbSQIWQgghVCAJWAghhFCBJGAhhBBCBZKAhRBCCBVIAhZCCCFUIAlYCCGEUIEkYCGEEEIFkoCFEEIIFUgCNrPXXnsNjUajdhi12l133cVdd91V+ndcXBwajYbvv/9etZhqkrzHatb333+PRqMhLi6uxs+t0Wh4/PHHa/ScDRo0YPTo0TV6TmEakoBrwNUP6J49e8rcn5GRQbt27XB0dGTNmjUqRWdbfvvtN1577TW1wxDVVFBQwIwZM+jcuTNeXl7o9XoCAgLo378/8+fPx2AwqB2iEGYjCdhEMjMz6dWrF4cOHWLZsmX07t1b7ZBswm+//cbrr79+S+dYt24d69atq6GILM/UqVPJy8tTO4xykpOT6dSpE5MmTcLV1ZWpU6fy1Vdf8cQTT5CTk8NDDz3EO++8o3aYQpiNndoB2KKsrCyio6M5cOAAS5cupU+fPmqHZPVycnJwcXGpk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zPFDhw4trcECdOnSBYAzZ86UOWbv3r3ExsaW3rdgwQIcHBwYMGAAAAcOHCAmJoaHHnqIlJSU0nJzcnLo3r07f/31V7nmsP/85z/XvY6KrsvDw4OePXuWua42bdrg6urKn3/+WelzVcfNXqf4+HgOHz7MyJEjcXV1LT2ua9euREVF3fT869evJz09nWHDhpW5Pp1Oxx133FGp6+vRowfh4eGlf7do0QJ3d/fSGBVFYcmSJdx7770oilKmnOjoaDIyMti3b1+Zc44aNapcDbEiV5umr712gC+//BJfX9/SW+fOncs9t7Jl3EjTpk1L/00AfH19iYiIKPM+/u2332jfvn2ZlhhfX98yzeJQuc/ikiVL0Gg0vPrqq+Ue+3eT8c3+XW5VVT/zwnwkAdegr776Cr1eT+/evW86mORaW7dupUePHri4uODp6Ymvry8vvvgiQGkC7tq1K0OGDOH111+nTp06DBgwgNmzZ1NQUFB6ngkTJtC4cWP69OlDUFAQjzzySLm+pJiYGNasWVPmS8/X15cePXoAJc1r16pfv36Zv68mmWv7Ve+//360Wi0LFiwASr7IFy1aRJ8+fXB3dy8tF0q+TP9d9jfffENBQUHptV4VGhpa6dcwJiaGjIwM/Pz8yp0/Ozu73HXVtJu9Tlf7yBs2bFjuuRXd929XX7+777673PWtW7euUtf37xivxnk1xuTkZNLT05k1a1a5MsaMGQOUf39U9t/Izc0NKBkjca0hQ4awfv161q9fT4sWLSp8blXeB9dzs2uHkn+jRo0alTsuIiKizN+V+SzGxsYSEBCAt7d3jcR2K6r6mRfmI33ANahp06b89ttvdO/enZ49e7J169ab1oZjY2Pp3r07kZGRfPTRRwQHB6PX6/ntt9/43//+V1or1Gg0LF68mB07drBy5UrWrl3LI488wocffsiOHTtwdXXFz8+PAwcOsHbtWlavXs3q1auZPXs2I0eOZM6cOUDJwJCePXvy3HPPVRhP48aNy/yt0+kqPE5RlNL/DwgIoEuXLixcuJAXX3yRHTt
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"# BEGIN SOLUTION\n",
"plt.pie(\n",
" sec_school.values(),\n",
" labels=sec_school.keys(),\n",
" autopct='%1.1f%%',\n",
" explode=[0, 0.25, 0, 0, 0.4]\n",
")\n",
"\n",
"plt.title(\"Klassenverteilung einer Grundschule\")\n",
"\n",
"plt.show()\n",
"# END SOLUTION"
]
},
{
"cell_type": "markdown",
"id": "83c08253-bc04-4b87-b906-4002ff210bad",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-e189ada272b135b2",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"source": [
"---\n",
"\n",
"# Extra\n",
"\n",
"Das Meme:\n",
"\n",
"![](https://flowingdata.com/wp-content/uploads/2014/12/Pie-Pyramid-620x311.png)\n",
"\n",
"lässt sich mit folgendem Python Code replizieren:"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "0079d10b-26fb-4aaa-b925-c6e31e456c6c",
"metadata": {
"nbgrader": {
"grade": false,
"grade_id": "cell-1120f5b30213d9b5",
"locked": true,
"schema_version": 3,
"solution": false,
"task": false
}
},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAjcAAAGFCAYAAAABwtJNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/SrBM8AAAACXBIWXMAAA9hAAAPYQGoP6dpAABHcklEQVR4nO3deVxU5f4H8M+ZgWGAAYYdRMQNN1yCTFPL9bpmmhuZZWLKr3tbbL/3WmGWbVqamZVLCi6ZW8XVXLtezS3XRM1d0khFXNiXgVnO7w+DREC2mTlzznzer5cvazic84WRw+ec53ueRxBFUQQRERGRQqikLoCIiIjImhhuiIiISFEYboiIiEhRGG6IiIhIURhuiIiISFEYboiIiEhRGG6IiIhIURhuiIiISFEYboiIiEhRGG6IiIhIURhuiIiISFEYboiIiEhRGG6IiIhIURhuiIiISFEYboiIiEhRGG6IiIhIURhuiIiISFEYboiIiE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JRgyZlcbObTjkSKx3BzF6vP5yH5Ak+EREry9I4M5JXwgoVIyRhuqnDTYMbzu65JXQYRWVlavgn/3sfhKSIlY7ipwgu7ruEaF98jUqQvf83BziuFUpdBRDbCcFOJjb/n4+tzeVKXQUQ2IgKYuD0DRZy4ikiRGG7ukFtixtM7OBxFpHTncox468BNqcsgIhtguLnDP/fewKUCTtZH5AxmHc3CoWsGqcsgIitjuLnNvqtFWHAyR+oyiMhOzCLwfzsyIIpce4pISRhubvPazzfAUxyRczlyoxjLz7LHjkhJGG7+lPx
"text/plain": [
"<Figure size 640x480 with 1 Axes>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"data = {\n",
" \"Sky\": 0.77,\n",
" \"Sunny side of pyramid\": 0.17,\n",
" \"Shady side of pyramid\": 0.05\n",
"}\n",
"\n",
"colors = [\"#0095d9\", \"#f5e837\", \"#c4b633\"]\n",
"\n",
"plt.pie(data.values(), startangle=-50, colors=colors)\n",
"plt.legend(data.keys(), bbox_to_anchor=(1, 0, 0.5, 0.6))\n",
"plt.savefig(\"meme.png\", bbox_inches=\"tight\", transparent=True)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2024-11-14 19:06:50 +01:00
"version": "3.12.7"
2024-10-25 13:28:49 +02:00
}
},
"nbformat": 4,
"nbformat_minor": 5
}