Home > OS >  How to fix the additive shifts in matplotlib
How to fix the additive shifts in matplotlib

Time:06-21

Matplotlib, in its infinite wisdom, wants to set the limits of the plots to divulge as much information as possible. Thus, if I understood correctly, it locates the maximum and minimum points on the plot, determines ticks around this vicinity and prepares additive and/or multiplicative descriptions for these points.

enter image description here

However, when someone tries to verify a formula, i.e., would be very happy if the lines overlap, such plots might be misleading. In the above example, the difference is around the order of 1e-10.

What I would prefer is to have an additive fix easy to understand. For the example above, 5e7 would make well. Then, the yticks has to be all negative. The below figure shows the same relation after I manually subtract 5e7 from both functions. Much easier to understand.

enter image description here

So, is there an easy way to achieve this?

CodePudding user response:

You can get the offset by first drawing the plot (without actually rendering it) and then use enter image description here

  • Related