Skip to main content
Ctrl+K
You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Matplotlib 3.8.3 documentation - Home Matplotlib 3.8.3 documentation - Home
  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • Twitter
  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • Twitter

Section Navigation

  • Lines, bars and markers
  • Images, contours and fields
  • Subplots, axes and figures
  • Statistics
  • Pie and polar charts
  • Text, labels and annotations
  • Color
  • Shapes and collections
  • Style sheets
  • Module - pyplot
  • Module - axes_grid1
  • Module - axisartist
  • Showcase
  • Animation
  • Event handling
  • Miscellaneous
  • 3D plotting
  • Scales
    • Asinh Demo
    • Loglog Aspect
    • Custom scale
    • Log Bar
    • Log Demo
    • Logit Demo
    • Exploring normalizations
    • Scales
    • Log Axis
    • Symlog Demo
  • Specialty plots
  • Spines
  • Ticks
  • Units
  • Embedding Matplotlib in graphical user interfaces
  • Widgets
  • Userdemo
  • Examples
  • Scales
  • Log Axis

Note

Go to the end to download the full example code

Log Axis#

This is an example of assigning a log-scale for the x-axis using semilogx.

semilogx demo
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

dt = 0.01
t = np.arange(dt, 20.0, dt)

ax.semilogx(t, np.exp(-t / 5.0))
ax.grid()

plt.show()

Download Jupyter notebook: semilogx_demo.ipynb

Download Python source code: semilogx_demo.py

Download zipped: semilogx_demo.zip

Gallery generated by Sphinx-Gallery

© Copyright 2002–2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012–2025 The Matplotlib development team.

Created using Sphinx 8.1.3.

Built from 3.8.3.

Built with the PyData Sphinx Theme 0.16.1.