Answers for "significant figures on axes plot matplotlib"

-1

significant figures on axes plot matplotlib

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

fig, ax = plt.subplots()

ax.yaxis.set_major_formatter(FormatStrFormatter('%g'))
ax.yaxis.set_ticks(np.arange(-2, 2, 0.25))

x = np.arange(-1, 1, 0.1)
plt.plot(x, x**2)
plt.show()
Posted by: Guest on April-06-2020

Code answers related to "significant figures on axes plot matplotlib"

Python Answers by Framework

Browse Popular Code Answers by Language