{"id":2406,"date":"2023-07-22T10:17:48","date_gmt":"2023-07-22T10:17:48","guid":{"rendered":"https:\/\/statorials.org\/nl\/matplotlib-online\/"},"modified":"2023-07-22T10:17:48","modified_gmt":"2023-07-22T10:17:48","slug":"matplotlib-online","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/matplotlib-online\/","title":{"rendered":"Hoe \u201c%matplotlib online\u201d te gebruiken (met voorbeelden)"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende code gebruiken om <a href=\"https:\/\/matplotlib.org\/\" target=\"_blank\" rel=\"noopener\">Matplotlib-<\/a> plots weer te geven en op te slaan in een Python Jupyter-notebook:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #800080;\">%<\/span> matplotlib inline\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Hier ziet u hoe deze code wordt beschreven op de <a href=\"https:\/\/ipython.readthedocs.io\/en\/stable\/interactive\/plotting.html\" target=\"_blank\" rel=\"noopener\">documentatiepagina<\/a> :<\/span><\/p>\n<blockquote>\n<p> <span style=\"color: #000000;\">\u201cMet deze backend wordt het resultaat van traceringsopdrachten <em>inline<\/em> weergegeven in frontends zoals de Jupyter-notebook, direct onder de codecel die deze heeft geproduceerd. De resulterende plots worden dan ook opgeslagen in het notebookdocument.<\/span><\/p>\n<\/blockquote>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze code in de praktijk kunt gebruiken.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld: %matplotlibe online gebruiken<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Stel dat we de volgende code proberen te gebruiken om een Matplotlib-lijnplot in een Jupyter-notebook te maken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><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, 6, 10]\ny = [5, 13, 27]\n\n<span style=\"color: #008080;\">#attempt to create line plot of x and y\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, y)\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Zo ziet het resultaat eruit in het Jupyter-notebook:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-21656 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/en-ligne1.png\" alt=\"\" width=\"611\" height=\"207\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">De code wordt zonder fouten uitgevoerd, maar er wordt geen lijndiagram inline met de code weergegeven.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Om dit probleem op te lossen, kunnen we de <strong>%matplotlib inline<\/strong> opdracht gebruiken voordat we de lijnplot maken:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\"><span style=\"color: #000000;\"><span style=\"color: #800080;\">%<\/span> matplotlib inline<\/span>\n\nimport<\/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, 6, 10]\ny = [5, 13, 27]\n\n<span style=\"color: #008080;\">#create scatter plot of x and y\n<\/span>plt. <span style=\"color: #3366ff;\">plot<\/span> (x, y)<\/span><\/span><\/strong>\n<\/pre>\n<p> <span style=\"color: #000000;\">Zo ziet het resultaat eruit in het Jupyter-notebook:<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-21657 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/en-ligne2.png\" alt=\"\" width=\"656\" height=\"535\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Merk op dat de code opnieuw zonder fouten wordt uitgevoerd en dat de plot inline in Kladblok wordt weergegeven.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Houd er rekening mee dat zodra we <strong>%matplotlib inline<\/strong> gebruiken, alle Matplotlib-plots die we in toekomstige notebookcellen maken, ook in notebook zullen worden weergegeven en opgeslagen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende bewerkingen in Python uitvoert:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/pandas-sleutelfout\/\" target=\"_blank\" rel=\"noopener\">Hoe KeyError in Panda&#8217;s te repareren<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/valueerror-kan-float-nan-niet-omzetten-in-geheel-getal\/\" target=\"_blank\" rel=\"noopener\">Oplossing: ValueError: Kan float NaN niet naar int converteren<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/de-operanden-konden-niet-met-de-formulieren-worden-uitgezonden\/\" target=\"_blank\" rel=\"noopener\">Oplossing: ValueError: Operanden konden niet worden uitgezonden met vormen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende code gebruiken om Matplotlib- plots weer te geven en op te slaan in een Python Jupyter-notebook: % matplotlib inline Hier ziet u hoe deze code wordt beschreven op de documentatiepagina : \u201cMet deze backend wordt het resultaat van traceringsopdrachten inline weergegeven in frontends zoals de Jupyter-notebook, direct onder de codecel die [&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":[],"class_list":["post-2406","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe &quot;%matplotlib inline&quot; te gebruiken (met voorbeelden) - Statorials<\/title>\n<meta name=\"description\" content=\"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u de functie &quot;%matplotlib inline&quot; in Python Jupyter-notebooks gebruikt.\" \/>\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\/nl\/matplotlib-online\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe &quot;%matplotlib inline&quot; te gebruiken (met voorbeelden) - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u de functie &quot;%matplotlib inline&quot; in Python Jupyter-notebooks gebruikt.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/matplotlib-online\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-22T10:17:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/en-ligne1.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\u00a0Minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/matplotlib-online\/\",\"url\":\"https:\/\/statorials.org\/nl\/matplotlib-online\/\",\"name\":\"Hoe &quot;%matplotlib inline&quot; te gebruiken (met voorbeelden) - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-22T10:17:48+00:00\",\"dateModified\":\"2023-07-22T10:17:48+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u de functie &quot;%matplotlib inline&quot; in Python Jupyter-notebooks gebruikt.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/matplotlib-online\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/matplotlib-online\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/matplotlib-online\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe \u201c%matplotlib online\u201d te gebruiken (met voorbeelden)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe &quot;%matplotlib inline&quot; te gebruiken (met voorbeelden) - Statorials","description":"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u de functie &quot;%matplotlib inline&quot; in Python Jupyter-notebooks gebruikt.","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\/nl\/matplotlib-online\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe &quot;%matplotlib inline&quot; te gebruiken (met voorbeelden) - Statorials","og_description":"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u de functie &quot;%matplotlib inline&quot; in Python Jupyter-notebooks gebruikt.","og_url":"https:\/\/statorials.org\/nl\/matplotlib-online\/","og_site_name":"Statorials","article_published_time":"2023-07-22T10:17:48+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/en-ligne1.png"}],"author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"1\u00a0Minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/matplotlib-online\/","url":"https:\/\/statorials.org\/nl\/matplotlib-online\/","name":"Hoe &quot;%matplotlib inline&quot; te gebruiken (met voorbeelden) - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-22T10:17:48+00:00","dateModified":"2023-07-22T10:17:48+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze zelfstudie wordt aan de hand van een voorbeeld uitgelegd hoe u de functie &quot;%matplotlib inline&quot; in Python Jupyter-notebooks gebruikt.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/matplotlib-online\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/matplotlib-online\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/matplotlib-online\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe \u201c%matplotlib online\u201d te gebruiken (met voorbeelden)"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=2406"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2406\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=2406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=2406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=2406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}