Exportieren von Grafiken bei matplotlib & pandas hinzugefügt
parent
994e492ca9
commit
1e3d257985
|
@ -338,6 +338,25 @@
|
||||||
"plt.legend(['sin(x)', 'cos(x)']);\n",
|
"plt.legend(['sin(x)', 'cos(x)']);\n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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",
|
||||||
|
"```"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
|
@ -821,6 +821,22 @@
|
||||||
"d.groupby(\"Typ\")[\"Preis\"].sum().plot(kind=\"pie\");\n",
|
"d.groupby(\"Typ\")[\"Preis\"].sum().plot(kind=\"pie\");\n",
|
||||||
"plt.show()"
|
"plt.show()"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "e6c9a7fb-b374-4743-8b37-77fc8de79cbd",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Grafiken speichern/exportieren\n",
|
||||||
|
"\n",
|
||||||
|
"Zum speichern der Grafiken muss man sich zuerst mittels `get_figure()` einen Verweis auf die Grafik holen ",
|
||||||
|
"Danach kann man über diese Referenz die Grafik in verschiedenen Formaten speichern:\n",
|
||||||
|
"```\n",
|
||||||
|
"fig = d.groupby(\"Typ\")[\"Preis\"].sum().plot(kind=\"pie\").get_figure();\n",
|
||||||
|
"fig.savefig('pie.png');\n",
|
||||||
|
"fig.savefig('pie.pdf');\n",
|
||||||
|
"```"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
Loading…
Reference in New Issue