79120695

Date: 2024-10-24 06:57:46
Score: 0.5
Natty:
Report link

You can set an offset like that manually or by using matplotlib.ticker:

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker


T     = np.arange(0, 101, 0.01)

R_e   = 1.68799673810490
R     = np.sin(T) + R_e

fig, ax = plt.subplots(1, 1)
ax.plot(T, R)

formatter = ticker.ScalarFormatter(useOffset=True, useMathText=True)
formatter.set_scientific(True)
formatter.set_powerlimits((1, 1))  # defines when to apply scientific notation

ax.xaxis.set_major_formatter(formatter)
ax.yaxis.set_major_formatter(formatter)

plt.show()

enter image description here

If this answer solves your problem, you can accept it.

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Márton Horváth