Issue
I am making a bot which tracks discord server stats and makes a graph of them.
While making the bot, I faced a problem. The bot shows floating point numbers in the graph which are not supposed to be there.
Is it possible to disable the float numbers and show only 12
, 13
, 14
instead of 12
, 12.25
, 12.50
, etc?
Solution
Answer
I suppose your data are in a y
list. In this case you can use ax.set_yticks()
as here:
yticks = range(min(y), max(y) + 1)
ax.set_yticks(yticks)
Code
import matplotlib.pyplot as plt
plt.style.use('dark_background')
x = ['14.09', '15.09', '16.09', '17.09', '18.09']
y = [12, 13, 13, 14, 14]
fig, ax = plt.subplots()
ax.plot(x, y, color = 'green', linestyle = '-', marker = 'o', markerfacecolor = 'red')
ax.set_facecolor('white')
ax.set_ylabel('Member count')
ax.set_title("Member count for 'СПГ'")
plt.setp(ax.xaxis.get_majorticklabels(), rotation = 90)
yticks = range(min(y), max(y) + 1)
ax.set_yticks(yticks)
plt.show()
Output
Answered By - Zephyr
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.