Reputation: 21
not getting expected values in y axis ,is there any problem in my code ? plot i m getting, plot expected
import matplotlib.pyplot as plt
x_values = list(range(1,1001))
y_values = [ x**2 for x in x_values]
plt.scatter(x_values,y_values,s=40)
plt.title("scattered squares 2",fontsize=15)
plt.xlabel("value",fontsize=14)
plt.ylabel("square of value",fontsize=15)
# Set the range for each axis.
plt.axis([0,1100,0,1100000])
plt.show()
not getting expected values in y axis ,is there any problem in my code ?
Upvotes: 2
Views: 92
Reputation: 19989
using plot is much cleanrer :
import matplotlib.pyplot as plt
x_values = list(range(1,1001))
y_values = [ x**2 for x in x_values]
plt.ticklabel_format(style='plain') #< ---- here
plt.title("scattered squares 2",fontsize=15)
plt.xlabel("value",fontsize=14)
plt.ylabel("square of value",fontsize=15)
# Set the range for each axis.
plt.plot(x_values,y_values)
plt.show()
Output:
Upvotes: 1
Reputation: 13349
Use plt.ticklabel_format(style='plain')
to disable scientific notation.
import matplotlib.pyplot as plt
x_values = list(range(1,1001))
y_values = [ x**2 for x in x_values]
plt.scatter(x_values,y_values,s=40)
plt.ticklabel_format(style='plain') #< ---- here
plt.title("scattered squares 2",fontsize=15)
plt.xlabel("value",fontsize=14)
plt.ylabel("square of value",fontsize=15)
# Set the range for each axis.
plt.axis([0,1100,0,1100000])
plt.show()
Upvotes: 0