2022-10-10 11:13:41 +02:00
{
"cells": [
{
"cell_type": "markdown",
"id": "1a44722c-9586-4418-ad7f-8a3c964a9db8",
"metadata": {},
"source": [
"# Grafiken"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "d29042ce-7023-45f2-a389-e73d4ddfd7e8",
"metadata": {
"tags": [
"hide-input"
]
},
"outputs": [],
"source": [
"import random\n",
"def rand_numbers(n, start, end, digits=2):\n",
" \"\"\" Erzeugt einen Array mit Zufallszahlen mit 2 Nachkommastellen\n",
" n\n",
" Anzahl der erzeugten Zufallszahlen\n",
" \n",
" start\n",
" Kleinste mögliche Zahl (inklusiv)\n",
" \n",
" end\n",
" Größte mögliche Zahl (exklusiv)\n",
" \n",
" digits\n",
" Anzahl Nachkommastellen, Default: 2\n",
" \"\"\"\n",
" factor = 10 ** digits\n",
" result = []\n",
" for i in range(n):\n",
" result.append(random.randint(start * factor, end * factor) / factor)\n",
" \n",
" return result "
]
},
{
"cell_type": "markdown",
"id": "ab90ad44-8536-4445-8674-a451a9a4971f",
"metadata": {},
"source": [
"## Matplotlib\n",
"\n",
"Bisher haben wir nur mit Zahlen ein Texten gearbeitet.\n",
"Dafür haben wir die Packages `math` und `random` verwendet.\n",
"\n",
"Jetzt möchten wir Grafiken erzeugen. Dazu benötigen wir ein weiteres Package: `mathplotlib`,\n",
"genauer gesagt, davon erst einmal nur den Teil `pyplot`.\n",
"\n",
"Um uns Tipparbeit zu sparen sagen wir beim `import`, dass wir im Folgenden dieses Package `plt` nennen möchten."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "89b767d1-4305-492b-984f-960b322e89a6",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD4CAYAAAAEhuazAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABYQElEQV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3I2fki9tV7r6OYbmH/Eq+4REwbdD8pKMTDKKZCw8IJp/3dcHqMs+nfT6P3JhHYdmxrFvMimGAH2mV5n/axljxxhjx/XvfwPAQ4yxQwAe0r8fKVb04P/bb30BNksy/r/vzjdcv7BexNRYzDglNtMPW2eelV3bLnf1c8qyglgk5HmlYCIaFm/uDlDVuolaMhpGeSBaPeuOnoD2wR4Nk2fNv1pTcWJhAy+/aZf23MTrw1f6Jfu8DcBf6V//FYCf7NNxBMZyroJwiHDP0Rncd8sMPvadCw0v/vm1Ig7sSlnetx9L3OuZf3eyT0VWPev9gHamIIa8vFOs1gwTtVQsPBCyT3PmT0QdWTycurKFUlXBK/TgX1MZZEW8RvyiF8GfAfgaET1ORA/ol80yxq7pXy8BmG2+ExE9QEQniOjE6upqDw7TX5ZyEmbScYRChPfddxg5qYaPm7J/rcd/3PK+/ZB9eDHuWreaf9XbIhdOIhoSBb0OqA9UDY7sU6hoi1zMdOLs+cjz6yACXnpwl7AACYBeBP8fY4y9CMAbAfw8Ed1tvpJpxvUt5vWMsQcZY8cZY8enp6d7cJj+spyTjPa72/Zm8YYX7MEnvjuPzWIVpWoNSzkJB3fbZP7xcE+7fRhjRg92t5m/VFM89/gDmq2zeGN7xzxQlYq
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"numbers = rand_numbers(50, -100, 100)\n",
"plt.plot(numbers);\n",
"plt.show() # bei manchen Jupyter-Versionen nicht nötig, einfach mal ohne testen"
]
},
{
"cell_type": "markdown",
"id": "fa5231c5-7b2a-4d02-a0e3-69a8ee78d930",
"metadata": {},
"source": [
"## Aufgabe\n",
"Erklärt,\n",
"1. was das Programm tut\n",
"2. was auf der Grafik zu sehen ist\n",
"3. wozu das Semikolon in der vorletzten Zeile dient"
]
},
{
"cell_type": "markdown",
"id": "486f4398-0d21-411d-8f91-e57fc925d2b8",
"metadata": {},
"source": [
"## Lösung\n",
"1. Was tut Programm?\n",
" - es importiert die Bibliothek `mathplotlib.pyplot`. Diese enthält Funktionen zum Zeichnen von Grafiken\n",
" - diese Bibliothek nennen wir `plt` weil das schneller zu schreibenist als `mathplotlib.pyplot`\n",
" - 50 Zufallszahlen zwischen -100 und 100 erzeugt und diese im Array mit dem Namen `numbers` speichern\n",
" - die Zufallszahlen in `numbers` zeichnen\n",
"1. Was ist auf Grafik zu sehen?\n",
" - Der Wert der Zufallszahlen ist auf der y-Achse\n",
" - Die 0te Zufallszahl ist auf der x-Achse bei x=0, die 1te Zufallszahl bei x=1 usw.\n",
"1. Die Funktion plot() zeichnet die Grafik und liefert zusätzlich noch ein Ergebnis zurück. Das Semikolon sorgt dafür, dass das Ergebnis nicht angezeigt wird."
]
},
{
"cell_type": "markdown",
"id": "5feb449e-76c4-4ea9-b0e2-4912f100cc39",
"metadata": {},
"source": [
"## Aufgabe\n",
"Wie kann man erkennen, wie gleichmäßig die Zufallszahlen verteilt sind?"
]
},
{
"cell_type": "markdown",
"id": "7d02f67c-6395-42be-988d-e29d182d0bd5",
"metadata": {},
"source": [
"## Lösung\n",
"Die Zufallszahlen der Größe nach sortieren.\n",
"Je gleichmäßiger sie verteilt sind desto gerader ist die Linie im Graphen."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c3cd108d-ec9f-4570-b604-b18c07887f95",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD4CAYAAAAEhuazAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAiJUlEQVR4nO3deXhU5d3/8fc3IYQlQFjCTth3gSABd7QKilutS1HbutQ+gs9Tt2rr3trap0+LrVpbtS2iVVsrLmjdqeIKroQ1YSfsIYSEJSFAQpbv74+M/qKCAsnJmcx8Xtc118w5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ell1tZktNrNHzaztAT4zycyyzCyrsLCwIcoUkQD9/j8raNokgetO0WTr0SDw8DezFGAGcL27lwB/AfoCGdT8z+Ce/X3O3ae6e6a7Z6alqW1QpDGbt347r+dsYfLYvqS1Sg67HCHg8DezJGqC/0l3fx7A3Qvcvcrdq4GHgTFB1iAi4XJ3/u+15aS1SubKsb3DLkciguztY8AjwDJ3v7fW+i613nYukBNUDSISvv8sKWDe+h3cMH4ALZqqd3m0CPJf4jjgEiDbzBZG1t0GXGxmGYAD64DJAdYgIiGqqKpmyszl9OuYwndHdQ+7HKklyN4+c4D93br3WlD7FJHoMv3TDawt2s20SzM1OUuU0b+GiASitLySP85axVG923HK4I5hlyNfogY4Eal3y/JLuO2FbLbt3scjZwzW+D1RSOEvIvVmz75K7p+1imlz1tKmeRL3X5RBhqZljEoKfxGpF28tK+AXLy4hb+deLhrdg1tOH0RqCw3cFq0U/iJSJ+uKdjNl5nJez9l
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"numbers.sort()\n",
"plt.plot(numbers);\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "4866c521-8484-413b-80af-7bb129a5c2c5",
"metadata": {},
"source": [
"Das sieht schon nicht schlecht aus. Abweichungen von der Gerade sind aber deutlich zu sehen."
]
},
{
"cell_type": "markdown",
"id": "2f2ddb2c-d63e-4ee7-b5c1-1c148eea8787",
"metadata": {},
"source": [
"## Aufgabe\n",
"Welche Stelle im Programm muss geändert werden damit der erzeugte Graph viel näher an einer Gerade ist?"
]
},
{
"cell_type": "markdown",
"id": "7cc38c4b-8ff6-4549-9a26-df42bad9e42f",
"metadata": {},
"source": [
"## Lösung\n",
"Nach dem Gesetz der großen Zahlen müsste die Abweichung von der Gerade kleiner werden wenn man mehr Zufallszahlen zieht."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "aee05f91-0bbd-4c9e-a972-ff305167c974",
"metadata": {},
"outputs":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AdLRG6xMJVRsy9zPmvZ+I35ZNz1b1eHxId3q0rOt3WRGvLML/TOfcVjNrAsw3s8TiC51zzvvDwGHtk4HJALGxsb9aLiLlWyDgeOv7jTz1RSJVKlbQw9PLmaCHv3Nuq/c93cw+BvoBaWbW3Dm33cyaA+nBrkNEyk5WTj5j3v+JxesyOadTY54adooeslLOBDX8zawmUME5t9ebvhB4FJgF3Ag85X2fGcw6RKRs5BcGeGfJJiYtSmZ3Tj5PDO3Otf2idbZfDgX7zL8p8LF34CsB7znnvjCzpcCHZjYK2ARcHeQ6RCTINu/M4a5py1m6cTcD2jbkrgs7EhvTwO+y5CiCGv7OuRSg5xHadwLnB3PbIlI2nHN8sHQLj81OoKIZz/++J1f0itLZfjmnT/iKyEnbn1fAX6cuZ35CGqe3a8izV/Ukql51v8uS46DwF5GTkr43l5FTlpKwLZsHL+nCyDPaqN9+CFH4i8gJKQw43vxuIxMXriOvoJB//aEvg7rrISuhRuEvIsctOX0fj3waz+J1mZzZvhHjL+9K+ya1/S5LToLCX0R+U35hgCfnrGHKdxupXLECTw7twTX9WummbghT+IvIMSWn7+VP7/5MUtpehvWJYuzFXWhcu6rfZUkJKfxF5IgKA45XF6fw3Py11KxSkZev68Og7s39LktKicJfRH4lOX0f90xfwc+b93BRt6Y8fkUPne2HGYW/iPxXYcDx+jcbeHZeEjWqVNRgbGFM4S8iAKRk7OOe6StZtmk3A7s05clh3WlSW4OxhSuFv0iEy80v5Nm5Sbz1/UaqV66o4RkihMJfJIL9uGEX42fFs2Z
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"numbers = rand_numbers(10000, -100, 100)\n",
"numbers.sort()\n",
"plt.plot(numbers);\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "fcdd2a03-14b2-4424-a0a0-5bc1e73017ae",
"metadata": {},
"source": [
"## Matplotlib Dokumentation\n",
"\n",
"Dokumentation zu Matplotlib und anderen Python Packages findet man im unteren Teil des Hilfe-Menüs.\n",
"\n",
"![jupyter_help.png](jupyter_help.png)\n",
"\n",
"Falls diese fehlen:\n",
"* matplotlib: https://matplotlib.org/stable/api/index.html\n",
"* pandas: https://pandas.pydata.org/docs/reference/index.html"
]
},
{
"cell_type": "markdown",
"id": "95389da8-8526-4904-bc04-01a2104f1d1d",
"metadata": {},
"source": [
"## Aufgabe\n",
"Erzeuge einen Graph mit Sinus und Cosinus-Funktion."
]
},
{
"cell_type": "markdown",
"id": "34fcc9ed-61b0-483a-ae79-fb5faa25ac9b",
"metadata": {},
"source": [
"## Lösung"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "0c429b71-11b0-4a30-8710-61298f161185",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD4CAYAAADhNOGaAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABD9ElEQVR4nO3deVxU1f/H8deHXRFRFBVZXHHfJc3UxH3Jr1qaaZv1rWy3vbS+Lb/2zcz2zGxPs80stVzS3BfMXWR1QdxABFR2OL8/7lBEICAzc2eY83w85sHMnTtz347Ah3PPueeIUgpN0zTNdbmZHUDTNE0zly4EmqZpLk4XAk3TNBenC4GmaZqL04VA0zTNxXmYHeBiNGzYUDVv3tzsGJqmaU5l+/btqUqpwNLbnbIQNG/enKioKLNjaJqmORUROVzWdn1qSNM0zcXpQqBpmubidCHQNE1zcboQaJqmuThdCDRN01ycVQqBiMwTkVMisrec50VE3hKReBHZLSI9Sjw3RUTiLLcp1sijaZqmVZ61WgSfAiMu8PxIINxymwq8DyAiAcDTQG+gF/C0iNS3UiZN0zStEqxyHYFSaq2INL/ALmOBz5Ux5/VmEaknIkFAJLBCKZUGICIrMArKfGvk+pddCyD9CHj7gXddCGgBDduAb0ObHM7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HldyYD861wXOdUq57xF8X5VPjhVij655W0S3Yf5/NNh7mtfwuGdHDeccnWIiI8N7YTbRv7cf+CHRxLr1pnu6ZV29aPIHoxDH4aQnuZncYmrFEIgoGkEo+PWrb9i4g0A1oAv5fY7CMiUSKyWUTGlXcQEZlq2S8qJcXJ/zIM6gqjXoWE32H9rL82H0o9z2Pf76Z
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import math\n",
"\n",
"sins = []\n",
"coss = []\n",
"\n",
"for i in range(360):\n",
" sins.append(math.sin(math.radians(i)))\n",
" coss.append(math.cos(math.radians(i))) \n",
" \n",
"plt.plot(sins)\n",
"plt.plot(coss);\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"id": "6dda6efa-5540-4659-8f66-afd18b697f5c",
"metadata": {},
"source": [
"## Aufgabe\n",
"* Lest die Dokumentation zu `plt.plot` und verändert\n",
" * Farbe der Linie\n",
" * Dicke der Linie\n",
" * Beschriftung der x-Achse (Werte in Bogen- statt Gradmaß)\n",
"* Lest die Dokumentation zu `plot` und versucht den Graphen zu beschriften"
]
},
{
"cell_type": "markdown",
"id": "ba58416c-8104-468b-8a0b-88cf86e85879",
"metadata": {},
"source": [
"## Lösung"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "9e65731d-e81f-491a-ace5-46eaa6e208e6",
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAZAAAAEWCAYAAABIVsEJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAABUtElEQVR4nO3dd3hUZfbA8e+ZlpkUWugdpQiCoAQQKRZEUVGwV9a6uvxWwd5WRUBdu667lrWgsLqy9q6IAoKAQmhSFEERpQcQSJvJlPP7496EgAkpJLkzyft5njz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gP85PUu8kxFX9/0ljuTHyZ+VTsLgAAHdTN8kjkvE0j/eWVsOoHrGY8tRTi7njjjkEgxFatEjhoYcGc/HF3XDVwN9kIZNAqPkEAtZ/gGeeWcKtt84mPz9C27ZpvP32CDIymtdoHGXRAiX3o1zCK8MAeLt4ST41GVdqzY+SivwWIfeDXGI7Y+CC5JOT8fX21enh0kbds2NHPpdc8jGfffYLAJdeejhPPnk8DRrU/BdQk0BwJoEUWrPmdy655GMWLNiCz+fmX/8awlVX9YiLD8Xojig5b+YQy4qBD5KHJeM7wtkPbC1Q8r/IJ7QoBICvh4/k05KrpO/FMOLdokVbOPvsD1i/fg/p6QEmTTqZM87o6Fg8pSUQMwi/hnTq1JDZsy/g//6vFwUFUa6++nPGjJlBNBpzNK7wujDZL2UTy4rhauyi3hX1SOqZ5HhiE5+QfGoyKSNTwAsFywvInpxNLMfZ98swqtvbb//IwIFTWb9+D336NGfx4lGOJo8DMQmkBiUleXj66ROZPPkUuwpZwjnnfEB
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"import math\n",
"\n",
"sins = []\n",
"coss = []\n",
"rads = []\n",
"\n",
"for i in range(360):\n",
" r = math.radians(i)\n",
" rads.append(r)\n",
" sins.append(math.sin(r))\n",
" coss.append(math.cos(r))\n",
"\n",
"plt.plot(rads, sins, color='violet', linewidth=2)\n",
"plt.plot(rads, coss, color='darkblue', linewidth=2)\n",
"\n",
"plt.title('sin(x) und cos(x)')\n",
"plt.xlabel('x von 0 bis 2π')\n",
"plt.ylabel('y')\n",
"plt.legend(['sin(x)', 'cos(x)']);\n",
"plt.show()"
]
2023-07-17 17:50:02 +02:00
},
{
"cell_type": "markdown",
"id": "470cd36c-2758-4f6f-b359-3a6adfb127dc",
"metadata": {},
"source": [
"## Grafiken speichern/exportieren\n",
"\n",
"Bilder können nicht nur angezeigt sondern auch gespeichert werden. Dies muss *vor* dem Aufruf von `plt.show()` geschehen:\n",
"\n",
"```\n",
"plt.savefig('sin_cos.png');\n",
"plt.savefig('sin_cos.pdf');\n",
"plt.savefig('sin_cos.svg');\n",
"plt.savefig('sin_cos.png', dpi=300, transparent=True, bbox_inches='tight')\n",
"\n",
"plt.show()\n",
"```"
]
}
2022-10-10 11:13:41 +02:00
],
"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",
"version": "3.9.7"
}
},
"nbformat": 4,
"nbformat_minor": 5
}