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?)
symlog is like log but allows you to define a range of values near zero within which the plot is linear, to avoid having the plot go to infinity around zero.
From http://matplotlib.sourceforge.net/api/axes_api.html#matplotlib.axes.Axes.set_xscale
In a log graph, you can never have a zero value, and if you have a value that approaches zero, it will spike down way off the bottom off your graph (infinitely downward) because when you take "log(approaching zero)" you get "approaching negative infinity".
symlog would help you out in situations where you want to have a log graph, but when the value may sometimes go down towards, or to, zero, but you still want to be able to show that on the graph in a meaningful way. If you need symlog, you'd know.
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
orclip
).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:
Just for completeness, I've used the following code to save each figure:
Remember you can change the figure size using:
(If you are unsure about me answering my own question, read this)