学习python笔记——matplotlib绘图使用小技巧

学习python笔记——matplotlib绘图使用小技巧

    学习python小白一只,在这记录下学习python的心得笔记,还往多多
    指教。
    话不多说,直接上学习matplotlib绘图小技巧相关代码。如下:

visualization data

# define image size
fig = plt.figure(figsize=(10, 8))
# create image form
ax1 = fig.add_subplot(111)
# title the image and define the font fammilies & size
ax1.set_title('Iteration of batch_64_Zer_36', fontdict={'family': 'Times New Roman', 'size': 18})
# title of x&y label and define the font fammilies & size
ax1.set_xlabel('Times of iteration', fontdict={'family': 'Times New Roman', 'size': 18})
ax1.set_ylabel('Value of iteration', fontdict={'family': 'Times New Roman', 'size': 18})
# difine axis size & font
plt.xticks(fontproperties='Times New Roman', size=16)
plt.yticks(fontproperties='Times New Roman', size=16)
# setting the spacing of axis
tick_spacing_x = 25000
tick_spacing_y = 0.025
ax1.xaxis.set_major_locator(ticker.MultipleLocator(tick_spacing_x))
# setting the scale of axis
plt.xlim(0, 100000)
plt.ylim(0.01, 0.1)
loss_t = ea.scalars.Items('loss_t_1')
# define the font color and label
ax1.plot([i.step for i in loss_t], [i.value for i in loss_t], label='loss_t', c='red')
# save image to folder
plt.savefig(r'D:\optimizer_1\batch_64_Zer_36_200520\IterOfBatch64Zer36.ps', dpi=1000)

还望大家多多交流指教!!!

你可能感兴趣的:(学习python笔记——matplotlib绘图使用小技巧)