Code:
import matplotlib.pyplot as plt
x = [1, 2]
y = [3, 2]
plt.errorbar(x, y, c='red')
plt.scatter(x, y, c='red')
plt.tick_params(rotation = 45)
plt.title("Points")
plt.xlabel("X")
plt.ylabel("Y")
plt.show()
I don't want any float numbers so I just want 1,2,3
CodePudding user response:
Use xticks
and yticks
to modify your the x and y tick labels
for example,
plt.xticks(range(1, 3))
plt.yticks(range(3, 5))
Anyways, your data have very short range (range of 1-3). It gonna be weird if not using float number.
CodePudding user response:
CodePudding user response:
You can try using xticks and yticks to set the range of x- and y-axes; here is the full code:
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
x = [1, 2]
y = [3, 2]
plt.errorbar(x, y, c='red')
plt.scatter(x, y, c='red')
plt.tick_params(rotation = 45)
plt.title("Points")
plt.xlabel("X")
plt.ylabel("Y")
plt.xticks(range(1, 3))
plt.yticks(range(3, 5))
plt.show()
enjoy!