What is the value in matplotlib.pyplot in the upper left angle for almost equal values?

Question:

I have some dataset:

%matplotlib inline
import matplotlib.pyplot as plt

dataset = [28892147.7659855, 28892150.0913124, 28892148.7255983, 28892146.365328,
          28892148.101613, 28892147.0887403, 28892147.8564253, 28892146.8626385,
          28892146.480244, 28892146.8724146, 28892146.699191, 28892146.405013,
          28892146.225238, 28892146.434353, 28892146.3250017, 28892146.344571,
          28892146.494564, 28892146.36454, 28892146.8347917, 28892146.20861,
          28892146.222876]

plt.plot(dataset)

enter image description here

by what logic matplotlib.pyplot outputs the value of 2.8892100000e7?

Asked By: Curious

||

Answers:

By default the ScalarFormatter that is used to set the tick mark labels, will work out an offset value to try and make the tick labels "round" numbers. How the offset is worked out can be found in the _compute_offset method here. How to turn off the offset is shown in the examples here. One way being, e.g.,

plt.plot(dataset)

# get axes object
ax = plt.gca()

# turn off the offset
ax.ticklabel_format(useOffset=False)
Answered By: Matt Pitkin
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.