Scale the matplotlib plot to show small / large positive / negative differences

enter image description here

This graph should show differences over time, which can be either negative or positive. 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 roughly farther away from x = 0? Is it possible for the logarithmic scale to go outward from x = 0?

EDIT:

As @Evert suggested, this solves the problem for me:

ax = gca()
...
ax.set_xscale("symlog")

      

and creates this graph:

enter image description here

+3


source to share


2 answers


You can use the parameter symlog

at xscale()

: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.xscale

It scales logarithmically (also negatively), except for the bounded section around zero (which can be specified using other keywords, see the documentation): this section scales linearly, avoiding all the problems log(0)

.



See here for an example.

+7


source


I would make two subplots: draw positive tenses in the right subplot and draw abs (negative times) in the left subplot with the x-axis reversed .

Is it possible for the logarithmic scale to deviate from x = 0?



No, since the log plot does not show zero --- when you get close to the "left edge" of the log-x axis, you go to negative infinity in log space, so you cannot cross zero to get to truly negative values. You have to trim the null somehow.

+3


source







All Articles