{"id":2226,"date":"2023-07-23T04:23:25","date_gmt":"2023-07-23T04:23:25","guid":{"rendered":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/"},"modified":"2023-07-23T04:23:25","modified_gmt":"2023-07-23T04:23:25","slug":"matplotlib-transparenter-hintergrund","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/","title":{"rendered":"So exportieren sie ein matplotlib-plot mit transparentem hintergrund"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Sie k\u00f6nnen die folgende grundlegende Syntax verwenden, um einen Matplotlib-Plot mit transparentem Hintergrund zu exportieren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong>savefig(' <span style=\"color: #ff0000;\">my_plot.png<\/span> ', transparent= <span style=\"color: #008000;\">True<\/span> )\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Beachten Sie, dass das Standardargument f\u00fcr <strong>savefig()<\/strong> <strong>transparent=False<\/strong> ist.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Durch die Angabe von <strong>transparent=True<\/strong> k\u00f6nnen wir eine Matplotlib-Figur mit transparentem Hintergrund speichern.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Das folgende Beispiel zeigt, wie diese Syntax in der Praxis verwendet wird.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel: Exportieren Sie einen Matplotlib-Plot mit transparentem Hintergrund<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie man in Matplotlib ein Liniendiagramm erstellt und das Diagramm mit einem transparenten Hintergrund speichert:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#define x and y\n<\/span>x = [1, 4, 10, 15]\ny = [5, 7, 21, 22]\n\n<span style=\"color: #008080;\">#create line plot\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, y)\n\n<span style=\"color: #008080;\">#add title and axis labels\n<\/span>plt. <span style=\"color: #3366ff;\">title<\/span> (' <span style=\"color: #ff0000;\">Title of Plot<\/span> ')\nplt. <span style=\"color: #3366ff;\">xlabel<\/span> (' <span style=\"color: #ff0000;\">XLabel<\/span> ')\nplt. <span style=\"color: #3366ff;\">ylabel<\/span> (' <span style=\"color: #ff0000;\">Y Label<\/span> ')\n\n<span style=\"color: #008080;\">#save plot with transparent background\n<\/span>plt. <span style=\"color: #3366ff;\">savefig<\/span> (' <span style=\"color: #ff0000;\">my_plot.png<\/span> ', transparent= <span style=\"color: #008000;\">True<\/span> )\n<\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Wenn ich zu dem Speicherort auf meinem Computer navigiere, an dem das Bild gespeichert ist, kann ich es anzeigen:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-20405 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/trans1-1.png\" alt=\"\" width=\"496\" height=\"388\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Allerdings wird dadurch der transparente Hintergrund nicht gut dargestellt.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dazu kann ich das Bild in Excel auf einen farbigen Hintergrund legen:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-20406 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/trans2-1.png\" alt=\"\" width=\"628\" height=\"480\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Beachten Sie, dass der Hintergrund vollst\u00e4ndig transparent ist.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Sie k\u00f6nnen dies mit genau demselben gespeicherten Bild vergleichen, ohne das <strong>transparente<\/strong> Argument zu verwenden:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#save plot without specifying transparent background<\/span>\nplt. <span style=\"color: #3366ff;\">savefig<\/span> (' <span style=\"color: #ff0000;\">my_plot2.png<\/span> ')\n<\/span><\/span><\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-20407 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/trans3-1.png\" alt=\"\" width=\"637\" height=\"514\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Der Hintergrund ist wei\u00df, die Standardhintergrundfarbe in Matplotlib.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Hinweis<\/strong> : Die vollst\u00e4ndige Online-Dokumentation f\u00fcr die Funktion <strong>savefig()<\/strong> finden Sie <a href=\"https:\/\/matplotlib.org\/stable\/api\/_as_gen\/matplotlib.pyplot.savefig.html\" target=\"_blank\" rel=\"noopener\">hier<\/a> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In den folgenden Tutorials wird erl\u00e4utert, wie Sie andere g\u00e4ngige Vorg\u00e4nge in Matplotlib ausf\u00fchren:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/matplotlib-abbildung-speichern\/\" target=\"_blank\" rel=\"noopener\">So speichern Sie eine Matplotlib-Figur in einer Datei<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/matplotlib-erhoht-die-tracegrosse\/\" target=\"_blank\" rel=\"noopener\">So erh\u00f6hen Sie die Plotgr\u00f6\u00dfe in Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/matplotlib-multiplot\/\" target=\"_blank\" rel=\"noopener\">So erstellen Sie mehrere Matplotlib-Plots auf einer einzelnen Figur<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sie k\u00f6nnen die folgende grundlegende Syntax verwenden, um einen Matplotlib-Plot mit transparentem Hintergrund zu exportieren: savefig(&#8218; my_plot.png &#8218;, transparent= True ) Beachten Sie, dass das Standardargument f\u00fcr savefig() transparent=False ist. Durch die Angabe von transparent=True k\u00f6nnen wir eine Matplotlib-Figur mit transparentem Hintergrund speichern. Das folgende Beispiel zeigt, wie diese Syntax in der Praxis verwendet wird. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>So exportieren Sie ein Matplotlib-Diagramm mit transparentem Hintergrund \u2013 Statistik<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Matplotlib-Plot mit transparentem Hintergrund exportiert wird.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So exportieren Sie ein Matplotlib-Diagramm mit transparentem Hintergrund \u2013 Statistik\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Matplotlib-Plot mit transparentem Hintergrund exportiert wird.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T04:23:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/trans1-1.png\" \/>\n<meta name=\"author\" content=\"Dr. Benjamin Anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. Benjamin Anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/\",\"url\":\"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/\",\"name\":\"So exportieren Sie ein Matplotlib-Diagramm mit transparentem Hintergrund \u2013 Statistik\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-23T04:23:25+00:00\",\"dateModified\":\"2023-07-23T04:23:25+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Matplotlib-Plot mit transparentem Hintergrund exportiert wird.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So exportieren sie ein matplotlib-plot mit transparentem hintergrund\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/de\/#website\",\"url\":\"https:\/\/statorials.org\/de\/\",\"name\":\"Statorials\",\"description\":\"Ihr Leitfaden f\u00fcr statistische Kompetenz !\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/de\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de-DE\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\",\"name\":\"Dr. Benjamin Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-DE\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. Benjamin Anderson\"},\"description\":\"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen\",\"sameAs\":[\"https:\/\/statorials.org\/de\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"So exportieren Sie ein Matplotlib-Diagramm mit transparentem Hintergrund \u2013 Statistik","description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Matplotlib-Plot mit transparentem Hintergrund exportiert wird.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/","og_locale":"de_DE","og_type":"article","og_title":"So exportieren Sie ein Matplotlib-Diagramm mit transparentem Hintergrund \u2013 Statistik","og_description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Matplotlib-Plot mit transparentem Hintergrund exportiert wird.","og_url":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/","og_site_name":"Statorials","article_published_time":"2023-07-23T04:23:25+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/trans1-1.png"}],"author":"Dr. Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr. Benjamin Anderson","Gesch\u00e4tzte Lesezeit":"1 Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/","url":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/","name":"So exportieren Sie ein Matplotlib-Diagramm mit transparentem Hintergrund \u2013 Statistik","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-23T04:23:25+00:00","dateModified":"2023-07-23T04:23:25+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie ein Matplotlib-Plot mit transparentem Hintergrund exportiert wird.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/matplotlib-transparenter-hintergrund\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So exportieren sie ein matplotlib-plot mit transparentem hintergrund"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/de\/#website","url":"https:\/\/statorials.org\/de\/","name":"Statorials","description":"Ihr Leitfaden f\u00fcr statistische Kompetenz !","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/de\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de-DE"},{"@type":"Person","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0","name":"Dr. Benjamin Anderson","image":{"@type":"ImageObject","inLanguage":"de-DE","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","caption":"Dr. Benjamin Anderson"},"description":"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen","sameAs":["https:\/\/statorials.org\/de"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/2226"}],"collection":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/comments?post=2226"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/2226\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=2226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=2226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=2226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}