{"id":5961,"date":"2020-12-09T16:24:02","date_gmt":"2020-12-09T10:54:02","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=5961"},"modified":"2026-07-13T12:29:19","modified_gmt":"2026-07-13T06:59:19","slug":"matplotlib-log-scale","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/","title":{"rendered":"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data"},"content":{"rendered":"<p><strong>Quick answer:<\/strong> Use ax.set_xscale(&#8216;log&#8217;) or ax.set_yscale(&#8216;log&#8217;) for positive data spanning orders of magnitude. Choose symlog or another scale when zero or negative values are meaningful, and set locators, formatters, and limits deliberately.<\/p>\n<figure class=\"pythonpool-article-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-domain.png\" alt=\"Matplotlib log scale infographic comparing linear and logarithmic transforms, positive domain, symlog, ticks, labels, and export checks\" width=\"1536\" height=\"1024\" loading=\"lazy\" decoding=\"async\"><figcaption>A log chart clarifies multiplicative structure only when its domain and tick semantics are visible.<\/figcaption><\/figure>\n<p>A Matplotlib log scale displays axis values by powers instead of equal linear steps. This is useful when data spans several orders of magnitude, such as growth curves, frequencies, execution times, file sizes, population counts, model loss values, or scientific measurements.<\/p>\n<p>The official Matplotlib documentation for <a href=\"https:\/\/matplotlib.org\/stable\/gallery\/scales\/log_demo.html\">log scale examples<\/a> shows how logarithmic axes change tick spacing. The API references for <a href=\"https:\/\/matplotlib.org\/stable\/api\/_as_gen\/matplotlib.axes.Axes.set_xscale.html\">set_xscale()<\/a>, <a href=\"https:\/\/matplotlib.org\/stable\/api\/_as_gen\/matplotlib.axes.Axes.set_yscale.html\">set_yscale()<\/a>, and <a href=\"https:\/\/matplotlib.org\/stable\/api\/_as_gen\/matplotlib.pyplot.loglog.html\">loglog()<\/a> cover the main calls.<\/p>\n<p>Use a log axis when ratios matter more than absolute differences. On a linear y-axis, the change from 10 to 20 looks the same size as the change from 1000 to 1010. On a log y-axis, multiplicative growth is easier to compare because equal visual gaps represent equal ratios.<\/p>\n<p>The most important rule is that ordinary logarithmic axes need positive values. Zero and negative values cannot be shown on a standard log scale. Filter, transform, or choose a different scale before plotting those values.<\/p>\n<p>Matplotlib gives you several entry points. <code>semilogx()<\/code> applies a log scale to the x-axis. <code>semilogy()<\/code> applies it to the y-axis. <code>loglog()<\/code> applies it to both axes. You can also create a normal plot and then call <code>set_xscale(\"log\")<\/code> or <code>set_yscale(\"log\")<\/code>.<\/p>\n<p>A log chart should not be used to hide important differences. It is best when it makes a wide range readable while the caption, axis labels, and surrounding text make the transformed scale obvious to the reader.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Plot_A_Log_Y-Axis\" >Plot A Log Y-Axis<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Set_Axis_Scale_Manually\" >Set Axis Scale Manually<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Use_loglog_For_Both_Axes\" >Use loglog For Both Axes<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Change_The_Log_Base\" >Change The Log Base<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Use_Log_Scale_With_Histograms\" >Use Log Scale With Histograms<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Filter_Nonpositive_Values\" >Filter Nonpositive Values<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Apply_A_Log_Scale_To_An_Axis\" >Apply A Log Scale To An Axis<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Choose_The_Scale_From_The_Data_Domain\" >Choose The Scale From The Data Domain<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Make_Ticks_And_Labels_Readable\" >Make Ticks And Labels Readable<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#Frequently_Asked_Questions\" >Frequently Asked Questions<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Plot_A_Log_Y-Axis\"><\/span>Plot A Log Y-Axis<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Use <code>semilogy()<\/code> when the y-values cover a wide range and the x-values are ordinary positions, steps, or labels.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">try:\n    import matplotlib.pyplot as plt\nexcept ModuleNotFoundError:\n    print(\"Install matplotlib to run this example.\")\nelse:\n    days = [1, 2, 3, 4, 5]\n    counts = [10, 100, 1000, 10000, 100000]\n\n    plt.semilogy(days, counts, marker=\"o\")\n    plt.xlabel(\"day\")\n    plt.ylabel(\"count\")\n    plt.title(\"Log-scaled counts\")\n    plt.close()\n<\/code><\/pre>\n<\/div>\n<p>The y-axis tick positions show powers rather than evenly spaced linear values. This makes exponential growth readable without the smaller values flattening against the bottom of the chart.<\/p>\n<p>For reports, label the axis clearly so readers know they are seeing a logarithmic view, not a normal linear scale.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Set_Axis_Scale_Manually\"><\/span>Set Axis Scale Manually<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>You can create a normal figure and then set the scale on an axis object. This style works well in larger plotting functions.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">try:\n    import matplotlib.pyplot as plt\nexcept ModuleNotFoundError:\n    print(\"Install matplotlib to run this example.\")\nelse:\n    sizes = [1, 10, 100, 1000]\n    times = [0.02, 0.12, 1.4, 18.0]\n\n    fig, ax = plt.subplots()\n    ax.plot(sizes, times, marker=\"s\")\n    ax.set_xscale(\"log\")\n    ax.set_yscale(\"log\")\n    ax.set_xlabel(\"input size\")\n    ax.set_ylabel(\"seconds\")\n    plt.close(fig)\n<\/code><\/pre>\n<\/div>\n<p>This is the most explicit form because the axis object owns the scale setting. It is also easier to combine with custom ticks, labels, grid lines, and multiple subplots.<\/p>\n<p>If a chart has several axes, set the scale on each axis intentionally rather than relying on a global pyplot call.<\/p>\n<p><!-- Python Pool visual layout repair 2026-07-13 --><\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/log-scale-scale-b152.png\" alt=\"Python Pool infographic showing positive data, logarithmic axis, decades, ticks, and transformed distance\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Log scale: Positive data, logarithmic axis, decades, ticks, and transformed distance.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Use_loglog_For_Both_Axes\"><\/span>Use loglog For Both Axes<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><code>loglog()<\/code> is a shortcut for a plot where both axes use logarithmic scaling.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">try:\n    import matplotlib.pyplot as plt\nexcept ModuleNotFoundError:\n    print(\"Install matplotlib to run this example.\")\nelse:\n    x_values = [1, 10, 100, 1000]\n    y_values = [2, 20, 200, 2000]\n\n    plt.loglog(x_values, y_values, marker=\"o\")\n    plt.xlabel(\"x\")\n    plt.ylabel(\"y\")\n    plt.title(\"Both axes are logarithmic\")\n    plt.close()\n<\/code><\/pre>\n<\/div>\n<p>This is useful for power laws, algorithm scaling, and measurements where both dimensions span wide ranges.<\/p>\n<p>A straight-looking line on a log-log chart often means a multiplicative relationship. It should still be interpreted carefully because the scale changes visual perception.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Change_The_Log_Base\"><\/span>Change The Log Base<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The default base is 10, but you can choose another base. Base 2 is common for memory sizes, tree depths, and binary growth.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">try:\n    import matplotlib.pyplot as plt\nexcept ModuleNotFoundError:\n    print(\"Install matplotlib to run this example.\")\nelse:\n    sizes = [1, 2, 4, 8, 16, 32]\n    memory = [64, 128, 256, 512, 1024, 2048]\n\n    fig, ax = plt.subplots()\n    ax.plot(sizes, memory, marker=\"o\")\n    ax.set_xscale(\"log\", base=2)\n    ax.set_yscale(\"log\", base=2)\n    ax.set_xlabel(\"workers\")\n    ax.set_ylabel(\"memory MB\")\n    plt.close(fig)\n<\/code><\/pre>\n<\/div>\n<p>The base affects tick placement and labels. Choose the base that matches the story in the data rather than using base 10 by habit.<\/p>\n<p>If the audience expects powers of two, a base-2 axis can make the chart easier to scan.<\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/log-scale-api-b152.png\" alt=\"Python Pool infographic comparing set_xscale log, set_yscale log, loglog, and axis methods\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Set log axis: Set_xscale log, set_yscale log, loglog, and axis methods.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Use_Log_Scale_With_Histograms\"><\/span>Use Log Scale With Histograms<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Histograms often have a few very tall bins and many small bins. A log-scaled count axis can make the smaller bars visible.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">try:\n    import matplotlib.pyplot as plt\nexcept ModuleNotFoundError:\n    print(\"Install matplotlib to run this example.\")\nelse:\n    values = [1, 1, 1, 2, 2, 3, 10, 30, 100, 300]\n\n    fig, ax = plt.subplots()\n    ax.hist(values, bins=5)\n    ax.set_yscale(\"log\")\n    ax.set_xlabel(\"value\")\n    ax.set_ylabel(\"frequency\")\n    plt.close(fig)\n<\/code><\/pre>\n<\/div>\n<p>This does not change the data; it changes how bin counts are displayed. Always mention the log scale when presenting the chart.<\/p>\n<p>For distributions with zero-count bins, check how the chart renders and whether a different binning strategy communicates the data more honestly.<\/p>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/log-scale-symlog-b152.png\" alt=\"Python Pool infographic comparing log, symlog, linear threshold, negative values, and zero\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Signed data: Log, symlog, linear threshold, negative values, and zero.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Filter_Nonpositive_Values\"><\/span>Filter Nonpositive Values<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Before using a standard log axis, remove or transform zero and negative values. The right choice depends on the meaning of the data.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">try:\n    import matplotlib.pyplot as plt\nexcept ModuleNotFoundError:\n    print(\"Install matplotlib to run this example.\")\nelse:\n    pairs = [(1, 10), (2, 0), (3, 30), (4, -5), (5, 100)]\n    positive_pairs = [(x, y) for x, y in pairs if y &gt; 0]\n    x_values = [x for x, y in positive_pairs]\n    y_values = [y for x, y in positive_pairs]\n\n    plt.semilogy(x_values, y_values, marker=\"o\")\n    plt.title(\"Only positive values on a log axis\")\n    plt.close()\n<\/code><\/pre>\n<\/div>\n<p>Filtering is clear when nonpositive values are invalid for the analysis. If zero has a real meaning, consider a different visualization, a symmetric log scale, or a carefully documented transformation.<\/p>\n<p>In short, use <code>semilogx()<\/code> for log x-values, <code>semilogy()<\/code> for log y-values, <code>loglog()<\/code> for both axes, and axis methods when building reusable plotting code. Check positivity first, label the scale clearly, and choose a base that matches the data.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Apply_A_Log_Scale_To_An_Axis\"><\/span>Apply A Log Scale To An Axis<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>A logarithmic axis changes the coordinate transform so multiplicative differences become easier to compare. It requires positive values for the ordinary log scale. Set the scale on the Axes object so the intent is tied to the specific plot.<\/p>\n<div class=\"pythonpool-code-scroll\" style=\"max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch;\">\n<pre><code class=\"language-python\">import matplotlib.pyplot as plt\n\nsizes = [1, 10, 100, 1000]\ntimes = [3, 5, 12, 30]\n\nfig, ax = plt.subplots()\nax.plot(sizes, times, marker=\"o\")\nax.set_xscale(\"log\", base=10)\nax.set_xlabel(\"Input size\")\nax.set_ylabel(\"Time\")\nfig.tight_layout()<\/code><\/pre>\n<\/div>\n<figure class=\"pythonpool-article-visual pythonpool-supporting-visual\"><img src=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/log-scale-check-b152.png\" alt=\"Python Pool infographic testing nonpositive data, tick labels, limits, grids, and annotations\" width=\"1536\" height=\"1054\" loading=\"lazy\" decoding=\"async\"><figcaption>Scale checks: Nonpositive data, tick labels, limits, grids, and annotations.<\/figcaption><\/figure>\n<h2><span class=\"ez-toc-section\" id=\"Choose_The_Scale_From_The_Data_Domain\"><\/span>Choose The Scale From The Data Domain<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Ordinary log scales cannot represent zero or negative values. symlog provides a linear region around zero with logarithmic behavior outside it; its threshold must match the data&#8217;s meaningful range. Do not replace zeros with a tiny positive number without documenting how that changes the analysis.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Make_Ticks_And_Labels_Readable\"><\/span>Make Ticks And Labels Readable<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Log ticks represent powers and multiples, not equal linear distances. Use appropriate locators and formatters, label the units, and inspect the saved figure at its final size. A log transform can clarify a trend while still misleading readers if the base, limits, or invalid-value policy is hidden.<\/p>\n<p data-pythonpool-link-set=\"2026-07-13-priority\">For readable log axes, compare Matplotlib tick positioning with current Axes control. Read <a href=\"https:\/\/www.pythonpool.com\/matplotlib-xticks\/\">matplotlib xticks<\/a> and <a href=\"https:\/\/www.pythonpool.com\/matplotlib-gca\/\">matplotlib gca<\/a> for the related workflow.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Frequently_Asked_Questions\"><\/span>Frequently Asked Questions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3>How do I set a logarithmic axis in Matplotlib?<\/h3>\n<p>Call ax.set_xscale(&#8216;log&#8217;) or ax.set_yscale(&#8216;log&#8217;), optionally specifying the base, on the Axes you want to transform.<\/p>\n<h3>Can a Matplotlib log scale show zero or negative values?<\/h3>\n<p>An ordinary log scale requires positive values; choose symlog or another domain-appropriate transform when zero or negative values matter.<\/p>\n<h3>Why do log-axis ticks look different?<\/h3>\n<p>Log ticks represent powers and multiples rather than equal linear intervals, so use suitable locators, formatters, and labels.<\/p>\n<h3>Should I replace zero with a tiny value for a log plot?<\/h3>\n<p>Only with a documented analytical reason; replacing zero changes the data and can create a misleading visual conclusion.<\/p>\n<p><script type=\"application\/ld+json\">{\"@context\":\"https:\/\/schema.org\",\"@type\":\"FAQPage\",\"mainEntity\":[{\"@type\":\"Question\",\"name\":\"How do I set a logarithmic axis in Matplotlib?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Call ax.set_xscale('log') or ax.set_yscale('log'), optionally specifying the base, on the Axes you want to transform.\"}},{\"@type\":\"Question\",\"name\":\"Can a Matplotlib log scale show zero or negative values?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"An ordinary log scale requires positive values; choose symlog or another domain-appropriate transform when zero or negative values matter.\"}},{\"@type\":\"Question\",\"name\":\"Why do log-axis ticks look different?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Log ticks represent powers and multiples rather than equal linear intervals, so use suitable locators, formatters, and labels.\"}},{\"@type\":\"Question\",\"name\":\"Should I replace zero with a tiny value for a log plot?\",\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Only with a documented analytical reason; replacing zero changes the data and can create a misleading visual conclusion.\"}}]}<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Make Matplotlib log charts honest by matching the transform to the data domain and labeling the base, limits, ticks, and invalid values.<\/p>\n","protected":false},"author":1,"featured_media":34202,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2071],"tags":[2664,2666,2668,2667],"class_list":["post-5961","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-matplotlib","tag-log-scale-matplotlib","tag-matplotlib-histogram-log-scale","tag-matplotlib-log-scale","tag-matplotlib-set-log-scale","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v28.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Matplotlib Log Scale: log, symlog, Ticks, and Positive Data<\/title>\n<meta name=\"description\" content=\"Use Matplotlib log and symlog scales for axes, choose a valid domain, set ticks and formatters, and avoid hiding zero or negative data.\" \/>\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.pythonpool.com\/matplotlib-log-scale\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data\" \/>\n<meta property=\"og:description\" content=\"Make Matplotlib log charts honest by matching the transform to the data domain and labeling the base, limits, ticks, and invalid values.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2020-12-09T10:54:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-13T06:59:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-domain.png\" \/>\n<meta name=\"author\" content=\"Python Pool\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Python Pool\" \/>\n<meta name=\"twitter:description\" content=\"Practical Python tutorials, error fixes, code examples, and project guides.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-domain.png\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Python Pool\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/\"},\"author\":{\"name\":\"Python Pool\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/person\\\/f87448ee54c0ffd2889fbf2408c18998\"},\"headline\":\"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data\",\"datePublished\":\"2020-12-09T10:54:02+00:00\",\"dateModified\":\"2026-07-13T06:59:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/\"},\"wordCount\":1045,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/matplotlib-log-scale-guide-pythonpool.png\",\"keywords\":[\"log scale matplotlib\",\"matplotlib histogram log scale\",\"matplotlib log scale\",\"matplotlib set log scale\"],\"articleSection\":[\"Matplotlib\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/\",\"name\":\"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/matplotlib-log-scale-guide-pythonpool.png\",\"datePublished\":\"2020-12-09T10:54:02+00:00\",\"dateModified\":\"2026-07-13T06:59:19+00:00\",\"description\":\"Use Matplotlib log and symlog scales for axes, choose a valid domain, set ticks and formatters, and avoid hiding zero or negative data.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/matplotlib-log-scale-guide-pythonpool.png\",\"contentUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2026\\\/07\\\/matplotlib-log-scale-guide-pythonpool.png\",\"width\":1350,\"height\":650,\"caption\":\"Matplotlib log scale axes guide\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/matplotlib-log-scale\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pythonpool.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#website\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/\",\"name\":\"Python Pool\",\"description\":\"Practical Python tutorials, error fixes, code examples, and project guides.\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pythonpool.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/aa.png\",\"contentUrl\":\"https:\\\/\\\/www.pythonpool.com\\\/wp-content\\\/uploads\\\/2020\\\/08\\\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/x.com\\\/pythonpool\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.pythonpool.com\\\/#\\\/schema\\\/person\\\/f87448ee54c0ffd2889fbf2408c18998\",\"name\":\"Python Pool\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g\",\"caption\":\"Python Pool\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data","description":"Use Matplotlib log and symlog scales for axes, choose a valid domain, set ticks and formatters, and avoid hiding zero or negative data.","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.pythonpool.com\/matplotlib-log-scale\/","og_locale":"en_US","og_type":"article","og_title":"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data","og_description":"Make Matplotlib log charts honest by matching the transform to the data domain and labeling the base, limits, ticks, and invalid values.","og_url":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/","og_site_name":"Python Pool","article_published_time":"2020-12-09T10:54:02+00:00","article_modified_time":"2026-07-13T06:59:19+00:00","og_image":[{"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-domain.png","type":"","width":"","height":""}],"author":"Python Pool","twitter_card":"summary_large_image","twitter_title":"Python Pool","twitter_description":"Practical Python tutorials, error fixes, code examples, and project guides.","twitter_image":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-domain.png","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Python Pool","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/"},"author":{"name":"Python Pool","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998"},"headline":"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data","datePublished":"2020-12-09T10:54:02+00:00","dateModified":"2026-07-13T06:59:19+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/"},"wordCount":1045,"commentCount":4,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-guide-pythonpool.png","keywords":["log scale matplotlib","matplotlib histogram log scale","matplotlib log scale","matplotlib set log scale"],"articleSection":["Matplotlib"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/","url":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/","name":"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-guide-pythonpool.png","datePublished":"2020-12-09T10:54:02+00:00","dateModified":"2026-07-13T06:59:19+00:00","description":"Use Matplotlib log and symlog scales for axes, choose a valid domain, set ticks and formatters, and avoid hiding zero or negative data.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/matplotlib-log-scale\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-guide-pythonpool.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2026\/07\/matplotlib-log-scale-guide-pythonpool.png","width":1350,"height":650,"caption":"Matplotlib log scale axes guide"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/matplotlib-log-scale\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"Matplotlib Log Scale: log, symlog, Ticks, and Positive Data"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Practical Python tutorials, error fixes, code examples, and project guides.","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/f87448ee54c0ffd2889fbf2408c18998","name":"Python Pool","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/fdd3cb9ad7f560324dfd481989550aa8ffce84388fd253c42beca35c999d3108?s=96&d=wavatar&r=g","caption":"Python Pool"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/5961","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=5961"}],"version-history":[{"count":21,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/5961\/revisions"}],"predecessor-version":[{"id":41474,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/5961\/revisions\/41474"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/34202"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=5961"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=5961"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=5961"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}