0
我創建了一個圖,但是您可以看到x軸具有重疊的條目,我希望不同的x軸標記之間的跨度很明顯,以查看數字1,5 ,10個不同。Matplotlib具有不同的x跨度和較小的標記
此外,繪製值的標記稍重一些。我怎樣才能減小尺寸?
import matplotlib.pyplot as plt;
import numpy as np;
from matplotlib import rc;
filename = 'plot.pdf';
fig, ax1 = plt.subplots(frameon=False);
rc('mathtext', default='regular');
rc('lines',lw=2);
rc('lines',mew=2);
rc('text', usetex=True);
x = np.array([1,5,10,50,100,250,500]);
t_err = np.array([106.50, 99.53, 94.70, 94.65, 93.40, 93.38, 92.81]);
c_err = np.array([ 66.48, 65.11, 62.08, 60.09, 59.36, 60.32, 61.17]);
lns1 = ax1.plot(x,t_err,'bs:', label="T");
lns2 = ax1.plot(x,c_err,'bs-',label="C");
ax1.set_ylabel('Error',color='b',size=12);
ax1.set_ylim([50,100]);
ax1.set_xlim([1,500]);
ax1.set_xticks(x);
ax1.tick_params(axis='y', which=u'both', length=0, labelsize=10, colors='b');
ax1.tick_params(axis='x', which=u'both', length=0, labelsize=10);
lns = lns1 + lns2;
labs = [l.get_label() for l in lns];
ax1.set_xlabel('# of Iterations',size=14);
ax1.legend(lns, labs, bbox_to_anchor=(1.02,1.0), loc=2, borderaxespad=2.5, ncol = 1);
fig.savefig(filename,format='pdf',transparent=True, bbox_inches='tight');
我非常清楚這一點。但這是我習慣的風格。來自C/C++時代。 – Shew
嘗試一個日誌規模?例如'ax.set_xscale('log',basex = 2)' – GWW