Dữ liệu tôi đang hiển thị chỉ có ý nghĩa nếu đó là số nguyên.cách buộc matplotlib chỉ hiển thị số nguyên trên trục Y
I.e. 0,2 bản ghi không có ý nghĩa về ngữ cảnh của thông tin tôi đang phân tích.
Làm cách nào để buộc matplotlib chỉ sử dụng số nguyên trên trục Y. I E. 1, 100, 5 vv? không phải 0.1, 0.2 vv
for a in account_list:
f = plt.figure()
f.set_figheight(20)
f.set_figwidth(20)
f.sharex = True
f.sharey=True
left = 0.125 # the left side of the subplots of the figure
right = 0.9 # the right side of the subplots of the figure
bottom = 0.1 # the bottom of the subplots of the figure
top = 0.9 # the top of the subplots of the figure
wspace = 0.2 # the amount of width reserved for blank space between subplots
hspace = .8 # the amount of height reserved for white space between subplots
subplots_adjust(left=left, right=right, bottom=bottom, top=top, wspace=wspace, hspace=hspace)
count = 1
for h in headings:
sorted_data[sorted_data.account == a].ix[0:,['month_date',h]].plot(ax=f.add_subplot(7,3,count),legend=True,subplots=True,x='month_date',y=h)
#set bottom Y axis limit to 0 and change number format to 1 dec place.
axis_data = f.gca()
axis_data.set_ylim(bottom=0.)
from matplotlib.ticker import FormatStrFormatter
axis_data.yaxis.set_major_formatter(FormatStrFormatter('%.0f'))
#This was meant to set Y axis to integer???
y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
axis_data.yaxis.set_major_formatter(y_formatter)
import matplotlib.patches as mpatches
legend_name = mpatches.Patch(color='none', label=h)
plt.xlabel("")
ppl.legend(handles=[legend_name],bbox_to_anchor=(0.,1.2,1.0,.10), loc="center",ncol=2, mode="expand", borderaxespad=0.)
count = count + 1
savefig(a + '.png', bbox_inches='tight')
Không chắc chắn lý do bạn bị giảm giá. Đó là một câu hỏi hay, rõ ràng với một câu trả lời không rõ ràng (ngoài việc thiết lập thủ công các dấu tích, không linh hoạt). –