PINN discover代码学习 作图部分
PINNs-master\appendix\continuous_time_identification (Burgers)
make_axes_locatable 为了使colorbar与图像高度一样
from mpl_toolkits.axes_grid1 import make_axes_locatable
divider = make_axes_locatable(ax) # 获取ax定位
cax = divider.append_axes("right", size="5%", pad=0.05) # 在ax右侧加宽度为5%的colorbar,宽度0.05inch
fig.colorbar(h, cax=cax) # fig中显示colorbar
ax.xxx()作图
ax = plt.subplot(gs1[0, 1])
ax.plot(x,Exact[50,:], 'b-', linewidth = 2, label = 'Exact')
ax.plot(x,U_pred[50,:], 'r--', linewidth = 2, label = 'Prediction')
ax.set_xlabel('$x$')
ax.set_ylabel('$u(t,x)$')
ax.axis('square')
ax.set_xlim([-1.1,1.1])
ax.set_ylim([-1.1,1.1])
ax.set_title('$t = 0.50$', fontsize = 10)
ax.legend(loc='upper center', bbox_to_anchor=(0.5, -0.35), ncol=5, frameon=False)
-
ax.legend
显示图例-
loc
为坐标在图例中定位; -
bbox_to_anchor
提供坐标点
*ncol
图例中的列数 -
frameon
是否显示图例边框
-
网友评论