Die Daten, die ich visualisiere, sind nur sinnvoll, wenn es sich um ganze Zahlen handelt.Wie man matplotlib erzwingt, um nur ganze Zahlen auf der Y-Achse anzuzeigen
I.e. 0.2 eines Datensatzes macht keinen Sinn in Bezug auf den Kontext der Informationen, die ich analysiere.
Wie erzwinge ich Matplotlib, nur ganze Zahlen auf der Y-Achse zu verwenden. I.e. 1, 100, 5 usw.? nicht 0.1, 0.2 etc.
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')
Nicht sicher, warum Sie downvoted werden. Es ist eine gute, klare Frage mit einer nicht ganz offensichtlichen Antwort (abgesehen von der manuellen Einstellung der Ticks, die unflexibel ist). –