How do you make the values displayed along the x-axis of a graph in python display as floats?
So far my normal distribution graph will display but the values on the x-axis stay as integers. My current code is below:
import matplotlib.pyplot as plt
import math
import numpy as np
def main():
"""Plot a standard normal distribution."""
axes = plt.axes()
x_values = np.linspace(-4.0, 4.0, 400)
y_values=[((1/(math.sqrt(2*math.pi)))*(math.exp(-1*((x
2)/2)))) for x in
x_values]
axes.plot(x_values, y_values)
axes.set_title("A normal distribution, f(x), with mean = 0, variance = 1")
axes.set_xlabel("x")
axes.set_ylabel("f(x)")
axes.set_xlim(-4.0, 4.0)
plt.xticks([-4.0, -2.0, 0.0, 2.0, 4.0])
axes.set_major_formatter(FormatStrFormatter('%d'))
axes.grid(True)
plt.show()
main()