Scale a matplotlib plot so that small/large positive/negative differences can be shown
jupyter-notebook, matplotlib, plot, python
Solution
You can use the `symlog` setting in `xscale()`: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xscale
It scales logarithmically (also on the negative side), apart from a limited section around zero (which can be set using further keywords, see the documentation): that section is scaled linearly, thus avoiding all `log(0)` problems.
See here for an example.
Problem
This plot is supposed to show differences in time, which can be both negative and positive values. Some differences are very small, while others are very large. Can I scale the x-axis so that the resolution is very fine near x = 0 and coarse farther away from x = 0? Is it possible to have a logarithmic scale going outward from x = 0? EDIT: As suggested by @Evert, this solves the problem for me: ``` ax = gca() ... ax.set_xscale("symlog") ``` and produces this plot: