{"id":3301,"date":"2023-07-18T05:04:24","date_gmt":"2023-07-18T05:04:24","guid":{"rendered":"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/"},"modified":"2023-07-18T05:04:24","modified_gmt":"2023-07-18T05:04:24","slug":"garis-kisi-horizontal-matplotlib","status":"publish","type":"post","link":"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/","title":{"rendered":"Cara memplot hanya kotak horizontal di matplotlib"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Anda dapat menggunakan sintaks dasar berikut untuk memplot kisi horizontal saja di Matplotlib:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\">ax. <span style=\"color: #3366ff;\">grid<\/span> (axis=' <span style=\"color: #ff0000;\">y<\/span> ')<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Contoh berikut menunjukkan cara menggunakan sintaksis ini dalam praktiknya.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Contoh: hanya memplot grid horizontal di Matplotlib<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Kode berikut menunjukkan cara membuat plot batang di Matplotlib dengan hanya kisi horizontal yang ditampilkan di plot:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd<\/span>\nimport<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#createDataFrame\n<span style=\"color: #000000;\">df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ':['Mavs', 'Nets', 'Spurs', 'Warriors'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ':[105, 99, 112, 100]})\n\n<span style=\"color: #008080;\">#defineplot\n<\/span>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> ()\n\n<span style=\"color: #008080;\">#create bar plot\n<\/span>df. <span style=\"color: #3366ff;\">plot<\/span> (kind=' <span style=\"color: #ff0000;\">bar<\/span> ', ax=ax)\n\n<span style=\"color: #008080;\">#add horizontal gridlines\n<\/span>ax. <span style=\"color: #3366ff;\">grid<\/span> (axis=' <span style=\"color: #ff0000;\">y<\/span> ')\n\n<span style=\"color: #008080;\">#displayplot\n<\/span>plt. <span style=\"color: #3366ff;\">show<\/span> ()\n<\/span><\/span><\/strong><\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-27926 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/horz0.jpg\" alt=\"\" width=\"509\" height=\"371\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Jangan ragu untuk menggunakan <strong>ax.set_axisbelow(True)<\/strong> untuk menampilkan garis kisi horizontal di belakang jeruji pada plot:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd<\/span>\nimport<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#createDataFrame\n<span style=\"color: #000000;\">df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ':['Mavs', 'Nets', 'Spurs', 'Warriors'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ':[105, 99, 112, 100]})\n\n<span style=\"color: #008080;\">#defineplot\n<\/span>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> ()\n\n<span style=\"color: #008080;\">#create bar plot\n<\/span>df. <span style=\"color: #3366ff;\">plot<\/span> (kind=' <span style=\"color: #ff0000;\">bar<\/span> ', ax=ax)\n\n<span style=\"color: #008080;\">#add horizontal gridlines behind bars in the plot\n<span style=\"color: #000000;\">ax. <span style=\"color: #3366ff;\">set_axisbelow<\/span> ( <span style=\"color: #008000;\">True<\/span> )\n<\/span><\/span>ax. <span style=\"color: #3366ff;\">grid<\/span> (axis=' <span style=\"color: #ff0000;\">y<\/span> ')\n\n<span style=\"color: #008080;\">#displayplot\n<\/span>plt. <span style=\"color: #3366ff;\">show<\/span> ()<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-27925\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/horz1-1.jpg\" alt=\"Matplotlib kisi horizontal\" width=\"473\" height=\"350\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Dan jangan ragu untuk menggunakan argumen <strong>color<\/strong> , <strong>linestyle<\/strong> dan <strong>linewidth<\/strong> dalam fungsi <strong>grid()<\/strong> untuk menyesuaikan tampilan grid:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd<\/span>\nimport<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #107d3f;\">as<\/span> plt\n\n<span style=\"color: #008080;\">#createDataFrame\n<span style=\"color: #000000;\">df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">team<\/span> ':['Mavs', 'Nets', 'Spurs', 'Warriors'],\n                   ' <span style=\"color: #ff0000;\">points<\/span> ':[105, 99, 112, 100]})\n\n<span style=\"color: #008080;\">#defineplot\n<\/span>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> ()\n\n<span style=\"color: #008080;\">#create bar plot\n<\/span>df. <span style=\"color: #3366ff;\">plot<\/span> (kind=' <span style=\"color: #ff0000;\">bar<\/span> ', ax=ax)\n\n<span style=\"color: #008080;\">#add horizontal gridlines with custom appearance<\/span>\nax. <span style=\"color: #3366ff;\">set_axisbelow<\/span> ( <span style=\"color: #008000;\">True<\/span> )\nax. <span style=\"color: #3366ff;\">grid<\/span> (axis=' <span style=\"color: #ff0000;\">y<\/span> ', color=' <span style=\"color: #ff0000;\">red<\/span> ', linestyle=' <span style=\"color: #ff0000;\">dashed<\/span> ', linewidth= <span style=\"color: #008000;\">3<\/span> )\n\n<span style=\"color: #008080;\">#displayplot\n<\/span>plt. <span style=\"color: #3366ff;\">show<\/span> ()<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-27927 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/horz2-1.jpg\" alt=\"\" width=\"502\" height=\"374\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Anda dapat menemukan daftar lengkap cara untuk menyesuaikan garis kisi di <a href=\"https:\/\/matplotlib.org\/stable\/api\/_as_gen\/matplotlib.pyplot.grid.html\" target=\"_blank\" rel=\"noopener noreferrer\">dokumentasi<\/a> Matplotlib.<\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Sumber daya tambahan<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Tutorial berikut menjelaskan cara melakukan tugas umum lainnya di Matplotlib:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/id\/matplotlib-menghilangkan-tanda-centang\/\" target=\"_blank\" rel=\"noopener noreferrer\">Cara menghilangkan centang dari plot Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/id\/ubah-ukuran-font-matplotlib\/\" target=\"_blank\" rel=\"noopener noreferrer\">Cara mengubah ukuran font pada plot Matplotlib<\/a><br \/> <a href=\"https:\/\/statorials.org\/id\/garis-rata-rata-matplotlib\/\" target=\"_blank\" rel=\"noopener\">Bagaimana cara menambahkan garis rata-rata ke plot di Matplotlib<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Anda dapat menggunakan sintaks dasar berikut untuk memplot kisi horizontal saja di Matplotlib: ax. grid (axis=&#8217; y &#8216;) Contoh berikut menunjukkan cara menggunakan sintaksis ini dalam praktiknya. Contoh: hanya memplot grid horizontal di Matplotlib Kode berikut menunjukkan cara membuat plot batang di Matplotlib dengan hanya kisi horizontal yang ditampilkan di plot: import pandas as pd [&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>Cara memplot hanya kisi horizontal di Matplotlib - Statorials<\/title>\n<meta name=\"description\" content=\"Tutorial ini menjelaskan cara menggambar kotak horizontal saja pada plot di Matplotlib, dengan beberapa contoh.\" \/>\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\/id\/garis-kisi-horizontal-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"id_ID\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Cara memplot hanya kisi horizontal di Matplotlib - Statorials\" \/>\n<meta property=\"og:description\" content=\"Tutorial ini menjelaskan cara menggambar kotak horizontal saja pada plot di Matplotlib, dengan beberapa contoh.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-18T05:04:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/horz0.jpg\" \/>\n<meta name=\"author\" content=\"Benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Ditulis oleh\" \/>\n\t<meta name=\"twitter:data1\" content=\"Benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimasi waktu membaca\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 menit\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/\",\"url\":\"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/\",\"name\":\"Cara memplot hanya kisi horizontal di Matplotlib - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/id\/#website\"},\"datePublished\":\"2023-07-18T05:04:24+00:00\",\"dateModified\":\"2023-07-18T05:04:24+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81\"},\"description\":\"Tutorial ini menjelaskan cara menggambar kotak horizontal saja pada plot di Matplotlib, dengan beberapa contoh.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/#breadcrumb\"},\"inLanguage\":\"id\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/statorials.org\/id\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Cara memplot hanya kotak horizontal di matplotlib\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/id\/#website\",\"url\":\"https:\/\/statorials.org\/id\/\",\"name\":\"Statorials\",\"description\":\"Panduan anda untuk kompetensi statistik!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/id\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"id\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81\",\"name\":\"Benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"id\",\"@id\":\"https:\/\/statorials.org\/id\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Benjamin anderson\"},\"description\":\"Halo, saya Benjamin, pensiunan profesor statistika yang menjadi guru Statorial yang berdedikasi. Dengan pengalaman dan keahlian yang luas di bidang statistika, saya ingin berbagi ilmu untuk memberdayakan mahasiswa melalui Statorials. Baca selengkapnya\",\"sameAs\":[\"http:\/\/statorials.org\/id\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Cara memplot hanya kisi horizontal di Matplotlib - Statorials","description":"Tutorial ini menjelaskan cara menggambar kotak horizontal saja pada plot di Matplotlib, dengan beberapa contoh.","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\/id\/garis-kisi-horizontal-matplotlib\/","og_locale":"id_ID","og_type":"article","og_title":"Cara memplot hanya kisi horizontal di Matplotlib - Statorials","og_description":"Tutorial ini menjelaskan cara menggambar kotak horizontal saja pada plot di Matplotlib, dengan beberapa contoh.","og_url":"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/","og_site_name":"Statorials","article_published_time":"2023-07-18T05:04:24+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/horz0.jpg"}],"author":"Benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Ditulis oleh":"Benjamin anderson","Estimasi waktu membaca":"2 menit"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/","url":"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/","name":"Cara memplot hanya kisi horizontal di Matplotlib - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/id\/#website"},"datePublished":"2023-07-18T05:04:24+00:00","dateModified":"2023-07-18T05:04:24+00:00","author":{"@id":"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81"},"description":"Tutorial ini menjelaskan cara menggambar kotak horizontal saja pada plot di Matplotlib, dengan beberapa contoh.","breadcrumb":{"@id":"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/#breadcrumb"},"inLanguage":"id","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/id\/garis-kisi-horizontal-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/statorials.org\/id\/"},{"@type":"ListItem","position":2,"name":"Cara memplot hanya kotak horizontal di matplotlib"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/id\/#website","url":"https:\/\/statorials.org\/id\/","name":"Statorials","description":"Panduan anda untuk kompetensi statistik!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/id\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"id"},{"@type":"Person","@id":"https:\/\/statorials.org\/id\/#\/schema\/person\/3d17a1160dd2d052b7c78e502cb9ec81","name":"Benjamin anderson","image":{"@type":"ImageObject","inLanguage":"id","@id":"https:\/\/statorials.org\/id\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/id\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Benjamin anderson"},"description":"Halo, saya Benjamin, pensiunan profesor statistika yang menjadi guru Statorial yang berdedikasi. Dengan pengalaman dan keahlian yang luas di bidang statistika, saya ingin berbagi ilmu untuk memberdayakan mahasiswa melalui Statorials. Baca selengkapnya","sameAs":["http:\/\/statorials.org\/id"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/posts\/3301"}],"collection":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/comments?post=3301"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/posts\/3301\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/media?parent=3301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/categories?post=3301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/id\/wp-json\/wp\/v2\/tags?post=3301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}