{"id":13253,"date":"2024-03-15T06:41:54","date_gmt":"2024-03-15T06:41:54","guid":{"rendered":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/"},"modified":"2025-08-05T14:52:08","modified_gmt":"2025-08-05T14:52:08","slug":"what-is-the-usage-of-the-figure-function-in-matplotlib","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/","title":{"rendered":"Matplotlib Figure Function Guide"},"content":{"rendered":"<p>In matplotlib, the figure function is used to create a new figure window and return a Figure object. Some common parameters for this function include:<\/p>\n<ol>\n<li>num: Specifies the number of the graphic window, with the default being None, indicating that a new number will be automatically assigned.<\/li>\n<li>figsize: specifies the size of the graphical window in inches, with the default being (6.4, 4.8).<\/li>\n<li>DPI refers to the resolution of the graphic window in dots per inch, with a default of 100.<\/li>\n<li>facecolor: specifies the background color of the graphic window, with the default being &#8216;w&#8217; representing white.<\/li>\n<li>Edgecolor: specifies the color of the border of the plot window, with the default being None, indicating no border will be displayed.<\/li>\n<\/ol>\n<p>After creating a new figure window by invoking the figure function, various types of graphics can be drawn on this window, such as line graphs, scatter plots, bar graphs, etc. Additionally, other functions can be used to set various properties of the figure window, such as title, axis labels, legend, etc.<\/p>\n<p>For example, the following code demonstrates how to use the figure function to create a new plot window and draw a simple line graph on it.<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> matplotlib.pyplot <span class=\"hljs-keyword\">as<\/span> plt\r\n\r\n<span class=\"hljs-comment\"># \u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u56fe\u5f62\u7a97\u53e3<\/span>\r\nfig = plt.figure()\r\n\r\n<span class=\"hljs-comment\"># \u5728\u56fe\u5f62\u7a97\u53e3\u4e0a\u7ed8\u5236\u4e00\u4e2a\u6298\u7ebf\u56fe<\/span>\r\nx = [<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">2<\/span>, <span class=\"hljs-number\">3<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">5<\/span>]\r\ny = [<span class=\"hljs-number\">1<\/span>, <span class=\"hljs-number\">4<\/span>, <span class=\"hljs-number\">9<\/span>, <span class=\"hljs-number\">16<\/span>, <span class=\"hljs-number\">25<\/span>]\r\nplt.plot(x, y)\r\n\r\n<span class=\"hljs-comment\"># \u8bbe\u7f6e\u56fe\u5f62\u7a97\u53e3\u7684\u6807\u9898\u548c\u5750\u6807\u8f74\u6807\u7b7e<\/span>\r\nplt.title(<span class=\"hljs-string\">'Simple Line Plot'<\/span>)\r\nplt.xlabel(<span class=\"hljs-string\">'x'<\/span>)\r\nplt.ylabel(<span class=\"hljs-string\">'y'<\/span>)\r\n\r\n<span class=\"hljs-comment\"># \u663e\u793a\u56fe\u5f62\u7a97\u53e3<\/span>\r\nplt.show()\r\n<\/code><\/pre>\n<p>Running the above code will prompt a new graphic window to appear, displaying a line graph on the window.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In matplotlib, the figure function is used to create a new figure window and return a Figure object. Some common parameters for this function include: num: Specifies the number of the graphic window, with the default being None, indicating that a new number will be automatically assigned. figsize: specifies the size of the graphical window [&hellip;]<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","footnotes":""},"categories":[1],"tags":[66,17614,902,12991,1403],"class_list":["post-13253","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-data-visualization","tag-figure-function","tag-matplotlib","tag-python-plotting","tag-tutorial"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Matplotlib Figure Function Guide - Blog - Silicon Cloud<\/title>\n<meta name=\"description\" content=\"Learn how to create and customize Matplotlib figures with figsize, dpi, and key parameters for effective data visualization.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Matplotlib Figure Function Guide\" \/>\n<meta property=\"og:description\" content=\"Learn how to create and customize Matplotlib figures with figsize, dpi, and key parameters for effective data visualization.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-15T06:41:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-05T14:52:08+00:00\" \/>\n<meta name=\"author\" content=\"Noah Thompson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:site\" content=\"@SiliCloudGlobal\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Noah Thompson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\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\":\"Article\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/\"},\"author\":{\"name\":\"Noah Thompson\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a\"},\"headline\":\"Matplotlib Figure Function Guide\",\"datePublished\":\"2024-03-15T06:41:54+00:00\",\"dateModified\":\"2025-08-05T14:52:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/\"},\"wordCount\":216,\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"keywords\":[\"data visualization\",\"figure function\",\"matplotlib\",\"Python plotting\",\"tutorial\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/\",\"name\":\"Matplotlib Figure Function Guide - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\"},\"datePublished\":\"2024-03-15T06:41:54+00:00\",\"dateModified\":\"2025-08-05T14:52:08+00:00\",\"description\":\"Learn how to create and customize Matplotlib figures with figsize, dpi, and key parameters for effective data visualization.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.silicloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Matplotlib Figure Function Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"name\":\"Silicon Cloud Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#organization\",\"name\":\"Silicon Cloud Blog\",\"url\":\"https:\/\/www.silicloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"contentUrl\":\"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png\",\"width\":1024,\"height\":1024,\"caption\":\"Silicon Cloud Blog\"},\"image\":{\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/SiliCloudGlobal\/\",\"https:\/\/twitter.com\/SiliCloudGlobal\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a\",\"name\":\"Noah Thompson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g\",\"caption\":\"Noah Thompson\"},\"url\":\"https:\/\/www.silicloud.com\/blog\/author\/noahthompson\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Matplotlib Figure Function Guide - Blog - Silicon Cloud","description":"Learn how to create and customize Matplotlib figures with figsize, dpi, and key parameters for effective data visualization.","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:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/","og_locale":"en_US","og_type":"article","og_title":"Matplotlib Figure Function Guide","og_description":"Learn how to create and customize Matplotlib figures with figsize, dpi, and key parameters for effective data visualization.","og_url":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/","og_site_name":"Blog - Silicon Cloud","article_publisher":"https:\/\/www.facebook.com\/SiliCloudGlobal\/","article_published_time":"2024-03-15T06:41:54+00:00","article_modified_time":"2025-08-05T14:52:08+00:00","author":"Noah Thompson","twitter_card":"summary_large_image","twitter_creator":"@SiliCloudGlobal","twitter_site":"@SiliCloudGlobal","twitter_misc":{"Written by":"Noah Thompson","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/#article","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/"},"author":{"name":"Noah Thompson","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a"},"headline":"Matplotlib Figure Function Guide","datePublished":"2024-03-15T06:41:54+00:00","dateModified":"2025-08-05T14:52:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/"},"wordCount":216,"publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"keywords":["data visualization","figure function","matplotlib","Python plotting","tutorial"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/","url":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/","name":"Matplotlib Figure Function Guide - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/blog\/#website"},"datePublished":"2024-03-15T06:41:54+00:00","dateModified":"2025-08-05T14:52:08+00:00","description":"Learn how to create and customize Matplotlib figures with figsize, dpi, and key parameters for effective data visualization.","breadcrumb":{"@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/blog\/what-is-the-usage-of-the-figure-function-in-matplotlib\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.silicloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Matplotlib Figure Function Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/blog\/#website","url":"https:\/\/www.silicloud.com\/blog\/","name":"Silicon Cloud Blog","description":"","publisher":{"@id":"https:\/\/www.silicloud.com\/blog\/#organization"},"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.silicloud.com\/blog\/#organization","name":"Silicon Cloud Blog","url":"https:\/\/www.silicloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","contentUrl":"https:\/\/www.silicloud.com\/blog\/wp-content\/uploads\/2023\/11\/EN-SILICON-Full.png","width":1024,"height":1024,"caption":"Silicon Cloud Blog"},"image":{"@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/SiliCloudGlobal\/","https:\/\/twitter.com\/SiliCloudGlobal"]},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/2e83cc6ab9f60d36921c2d0f9f280f4a","name":"Noah Thompson","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.silicloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/350e537e1530ede2762ee0237e877d6693f4f7163ab4f303202cc9a6b27b6cb4?s=96&d=mm&r=g","caption":"Noah Thompson"},"url":"https:\/\/www.silicloud.com\/blog\/author\/noahthompson\/"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/13253","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/comments?post=13253"}],"version-history":[{"count":3,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/13253\/revisions"}],"predecessor-version":[{"id":157187,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/posts\/13253\/revisions\/157187"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/media?parent=13253"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/categories?post=13253"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/blog\/wp-json\/wp\/v2\/tags?post=13253"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}