diff --git a/examples/liddrivencavity/run_and_plot.py b/examples/liddrivencavity/run_and_plot.py index e7b43699f5518386c439993b887cf82322e93108..fbef0083053066ede2b9aebd0f9709b9e2b0d6e8 100755 --- a/examples/liddrivencavity/run_and_plot.py +++ b/examples/liddrivencavity/run_and_plot.py @@ -47,39 +47,44 @@ jurjevicexpx = jurjevicexpx/2.0 + 0.5 #################################################### #### plotting ###################################### #################################################### -import matplotlib.pyplot as plt +try: + import matplotlib + import matplotlib.pyplot as plt -fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize = (9,4)) -ax1.plot(vx['1'], y['1'] , color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) -ax1.plot(jurjevicnumvx, jurjevicnumy, '--', markerfacecolor='white', color='black', label=u"R.Jurjevic et al., num") -ax1.plot(jurjevicexpvx, jurjevicexpy, 'o', markerfacecolor='white', color='black', label=u"R.Jurjevic et al., exp") -ax1.set_xlabel(r"$v_x$[m/s]") -ax1.set_ylabel(u"y [m]") + fig, (ax1, ax2, ax3, ax4) = plt.subplots(1, 4, figsize = (9,4)) + ax1.plot(vx['1'], y['1'] , color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) + ax1.plot(jurjevicnumvx, jurjevicnumy, '--', markerfacecolor='white', color='black', label=u"R.Jurjevic et al., num") + ax1.plot(jurjevicexpvx, jurjevicexpy, 'o', markerfacecolor='white', color='black', label=u"R.Jurjevic et al., exp") + ax1.set_xlabel(r"$v_x$[m/s]") + ax1.set_ylabel(u"y [m]") -ax2.plot(x['1'], vy['1'], color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) -ax2.plot(jurjevicnumx, jurjevicnumvy, '--', markerfacecolor='white', color='black', label=u"R.Jurjevic, num") -ax2.plot(jurjevicexpx, jurjevicexpvy, 'o', markerfacecolor='white', color='black', label=u"R.Jurjevic, exp") -ax2.set_xlabel(u"x [m]") -ax2.set_ylabel(r"$v_y$[m/s]",labelpad=1) -ax2.set_xlabel(u"x [m]") -ax2.set_ylabel(r"$v_y$[m/s]",labelpad=1) + ax2.plot(x['1'], vy['1'], color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) + ax2.plot(jurjevicnumx, jurjevicnumvy, '--', markerfacecolor='white', color='black', label=u"R.Jurjevic, num") + ax2.plot(jurjevicexpx, jurjevicexpvy, 'o', markerfacecolor='white', color='black', label=u"R.Jurjevic, exp") + ax2.set_xlabel(u"x [m]") + ax2.set_ylabel(r"$v_y$[m/s]",labelpad=1) + ax2.set_xlabel(u"x [m]") + ax2.set_ylabel(r"$v_y$[m/s]",labelpad=1) -handles, labels = ax2.get_legend_handles_labels() -fig.legend(handles, labels, bbox_to_anchor=(0.51, 1.0), ncol=3, labelspacing=0.) + handles, labels = ax2.get_legend_handles_labels() + fig.legend(handles, labels, bbox_to_anchor=(0.51, 1.0), ncol=3, labelspacing=0.) -ax3.plot(vx['1000'], y['1000'], color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) -ax3.plot(ghiavx, ghiay, 'o', markerfacecolor='white', color='black', label=u"Ghia et al.") -ax3.set_xlabel(r"$v_x$[m/s]") -ax3.set_ylabel(u"y [m]") + ax3.plot(vx['1000'], y['1000'], color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) + ax3.plot(ghiavx, ghiay, 'o', markerfacecolor='white', color='black', label=u"Ghia et al.") + ax3.set_xlabel(r"$v_x$[m/s]") + ax3.set_ylabel(u"y [m]") -ax4.plot(x['1000'], vy['1000'], color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) -ax4.plot(ghiax, ghiavy, 'o', markerfacecolor='white', color='black', label=u"Ghia et al.") -ax4.set_xlabel(u"x [m]") -ax4.set_ylabel(r"$v_y$[m/s]",labelpad=1) + ax4.plot(x['1000'], vy['1000'], color='black', label=u"DuMu$^\mathrm{x}$",linewidth=2) + ax4.plot(ghiax, ghiavy, 'o', markerfacecolor='white', color='black', label=u"Ghia et al.") + ax4.set_xlabel(u"x [m]") + ax4.set_ylabel(r"$v_y$[m/s]",labelpad=1) -handles, labels = ax4.get_legend_handles_labels() -fig.legend(handles, labels, bbox_to_anchor=(0.92, 1.0), ncol =2, labelspacing=0.) -fig.tight_layout(rect=[0.03, 0.07, 1, 0.9], pad=0.4, w_pad=2.0, h_pad=1.0) + handles, labels = ax4.get_legend_handles_labels() + fig.legend(handles, labels, bbox_to_anchor=(0.92, 1.0), ncol =2, labelspacing=0.) + fig.tight_layout(rect=[0.03, 0.07, 1, 0.9], pad=0.4, w_pad=2.0, h_pad=1.0) -plt.savefig("lidverification.png", dpi= 300) -if not args['noplotwindow']: plt.show() + plt.savefig("lidverification.png", dpi= 300) + if not args['noplotwindow']: plt.show() + +except ImportError: + print("Skipping plot: matplotlib has not been found.")