Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1020621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:11:22+00:00 2026-05-16T11:11:22+00:00

In matplotlib , I can set the axis scaling using either pyplot.xscale() or Axes.set_xscale()

  • 0

In matplotlib, I can set the axis scaling using either pyplot.xscale() or Axes.set_xscale(). Both functions accept three different scales: 'linear' | 'log' | 'symlog'.

What is the difference between 'log' and 'symlog'? In a simple test I did, they both looked exactly the same.

I know the documentation says they accept different parameters, but I still don’t understand the difference between them. Can someone please explain it? The answer will be the best if it has some sample code and graphics! (also: where does the name ‘symlog’ come from?)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:11:22+00:00Added an answer on May 16, 2026 at 11:11 am

    I finally found some time to do some experiments in order to understand the difference between them. Here’s what I discovered:

    • log only allows positive values, and lets you choose how to handle negative ones (mask or clip).
    • symlog means symmetrical log, and allows positive and negative values.
    • symlog allows to set a range around zero within the plot will be linear instead of logarithmic.

    I think everything will get a lot easier to understand with graphics and examples, so let’s try them:

    import numpy
    from matplotlib import pyplot
    
    # Enable interactive mode
    pyplot.ion()
    
    # Draw the grid lines
    pyplot.grid(True)
    
    # Numbers from -50 to 50, with 0.1 as step
    xdomain = numpy.arange(-50,50, 0.1)
    
    # Plots a simple linear function 'f(x) = x'
    pyplot.plot(xdomain, xdomain)
    # Plots 'sin(x)'
    pyplot.plot(xdomain, numpy.sin(xdomain))
    
    # 'linear' is the default mode, so this next line is redundant:
    pyplot.xscale('linear')
    

    A graph using 'linear' scaling

    # How to treat negative values?
    # 'mask' will treat negative values as invalid
    # 'mask' is the default, so the next two lines are equivalent
    pyplot.xscale('log')
    pyplot.xscale('log', nonposx='mask')
    

    A graph using 'log' scaling and nonposx='mask'

    # 'clip' will map all negative values a very small positive one
    pyplot.xscale('log', nonposx='clip')
    

    A graph using 'log' scaling and nonposx='clip'

    # 'symlog' scaling, however, handles negative values nicely
    pyplot.xscale('symlog')
    

    A graph using 'symlog' scaling

    # And you can even set a linear range around zero
    pyplot.xscale('symlog', linthreshx=20)
    

    A graph using 'symlog' scaling, but linear within (-20,20)

    Just for completeness, I’ve used the following code to save each figure:

    # Default dpi is 80
    pyplot.savefig('matplotlib_xscale_linear.png', dpi=50, bbox_inches='tight')
    

    Remember you can change the figure size using:

    fig = pyplot.gcf()
    fig.set_size_inches([4., 3.])
    # Default size: [8., 6.]
    

    (If you are unsure about me answering my own question, read this)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when using matplotlib, how can I set the text to be below other objects,
How can I set a default set of colors for plots made with matplotlib?
I'm currently using Matplotlib to create a histogram: import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as
Can you draw the grid lines in a plot with parasitic axes in matplotlib?
How can I create some gradient color in matplotlib and then set the parameter
For the life of me, I can not get matplotlib to display graphs in
With, say, 3 rows of subplots in matplotlib, xlabels of one row can overlap
I am using Python matplotlib. i want to superimpose scatter plots. I know how
I'm using matplotlib to plot data as a function of time in hh:mm:ss.ms format
I am using matplotlib in a django app and would like to directly return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.