У меня есть этот код:
# Modules I import
import matplotlib
if os.environ.get('DISPLAY','') == '':
print('no display found. Using non-interactive Agg backend')
matplotlib.use('Agg')
import matplotlib.pyplot as plt
from matplotlib.ticker import ScalarFormatter
from pylab import *
# My Variables to plot
ideal_walltime_list = [135.82, 67.91, 33.955, 16.9775, 8.48875]
cores_plotting = [16, 32, 64, 128, 256]
time_plotting = [135.82, 78.69, 50.62, 46.666, 42.473]
# My plotting part
plt.figure()
plt.scatter(cores_plotting, time_plotting, c='r', label='System wall time')
plt.plot(cores_plotting, ideal_walltime_list, c='k', label='Ideal Wall time')
plt.title('109bEdec_test')
plt.ylabel('Wall time (s)')
plt.xlabel('Cores')
plt.legend(loc='upper right')
plt.yscale('log')
plt.xscale('log')
ax = gca().xaxis
ax.set_major_formatter(ScalarFormatter())
ax.set_minor_formatter(ScalarFormatter())
ay = gca().yaxis
ay.set_major_formatter(ScalarFormatter())
ay.set_minor_formatter(ScalarFormatter())
plt.savefig('109bEdec_test' + '.png',dpi=1800)
plt.show()
Когда я запускаю этот код, мой график выглядит так:

Однако мне нужны оси x и y для отображения галочек, соответствующих моей переменной cores_plotting, а не всех тех чисел, которые имеют плохое форматирование.
Я пытался использовать:
plt.xticks(cores_plotting)
plt.yticks(cores_plotting)
Но безуспешно.
Также я попробовал:
plt.xticks(cores_plotting, ('16', '32', '64', '128', '256'))
plt.yticks(cores_plotting, ['16', '32', '64', '128', '256'])
Но успеха тоже нет. Прямо сейчас мне просто нужно иметь элементы cores_plotting в качестве моих тиков X и Y.
Моя версия на python 3.6.5 и моя версия Matplotlib 3.0.2.
Спасибо!