# %% buses, special_buses, lines = get_coordinates() titlet = 'SLG-IEEE10M39B' plt.close(titlet) fig = plt.figure(titlet,figsize=(8,6)) fig.clf() Drawer = plot_10m39b_basic(fig=fig,return_drawer=True,scale=25) Drawer.plot_legend(offset=[40,0]) ax = fig.gca() ax.set_xlim([80,880]) ax.set_ylim([20,620]) fig.show() fig.tight_layout() mysavefig(fig,postfix='.pdf') # %% titlet = 'SLG-SMIB' plt.close(titlet) fig = plt.figure(titlet,figsize=(7,3)) fig.clf() Drawer = plot_SMIB_basic(fig=fig,return_drawer=True) Drawer.plot_legend(loc='center lower',orientation='horizontal',scale_amp=0.32) ax = fig.gca() #ax.set_xlim([80,880]) ax.set_ylim([-70,50]) #fig.show() fig.tight_layout()
if color_t: special_buses[k][KEY_COLOR] = color_t for k in range(len(lines)): if diff_color_line: color_t = np.array([func_get_c_t() for ii in range(2)]) else: color_t = func_get_c_t() lines[k][KEY_COLOR] = color_t # %% ax = figt.add_subplot(1, 2, i + 1) ax.set_xlim([80, 680]) ax.set_ylim([20, 620]) # ax.plot([0,500],[0,500],lw=10) Drawer = SLGdrawer(buses, special_buses, lines, ax) Drawer.spec_color = True Drawer.text_bus = True Drawer.plot_slg(scale=25) sc = cm.ScalarMappable(cmap=cmap_t) sc.set_array([1, 0]) #cax = figt.colorbar(sc,orientation='horizontal') cax = figt.colorbar(sc) #cax.set_position([0.05,0.05,0.9,0.05]) ax.set_title(subtitles[i], fontname='Simhei') #%% figt.tight_layout(pad=1) figt.show() mysavefig(figt)
ACCs + 0.004, c=cacc, linewidth=1, marker='d', markersize=2.5, linestyle='--') yticks = np.linspace(0.985, 0.995, 5) yticklabels = [('%.1f%%' % (yt * 100)) for yt in yticks] ax_acc.set_yticks(yticks) ax_acc.set_yticklabels(yticklabels) ax_acc.set_ylim([np.min(yticks), np.max(yticks)]) ax_acc.set_ylabel('MAR') ltt, = axt.plot(Ds, TTs, marker='o', markersize=5, c=ctt) # axt.plot(Ds, para1*(Ds**para2), c='r', linestyle='--', linewidth=0.5) if not change_label: axt.set_xlabel('dimension') axt.set_ylabel('training time of %d epochs (sec)' % Nepoch) else: axt.set_xlabel('$D$') axt.set_ylabel('迭代%d次所需的训练时间 (s)' % Nepoch, fontname='Simhei') axt.legend([ltt, lacc], ['训练时间', '准确率'], prop={'family': 'Simhei'}) axt.set_xlim([0, np.max(Ds) + np.min(Ds)]) axt.set_position((0.1, 0.1, 0.75, 0.88)) # %% if change_label: mysavefig(figt, titlet)
def plot_pdf_r(plot_mean=True, ch=False, save=False): if ch: legends = ['PDF', '期望值'] else: legends = ['PDF', 'expectation'] ypts = make_pdf_single() yptd = make_pdf_double() YPs = [ypts, yptd] title1 = 'PDF-examples' title2 = 'Ycon-examples' figsizet = (8, 4) plt.close(title1) plt.close(title2) figt = plt.figure(title1, figsize=figsizet) figt.clf() figtt = plt.figure(title2, figsize=figsizet) figtt.clf() count_t = 1 start_b = 0.08 width_b = 0.4 Np = len(YPs) for i in range(Np): ytt, ptt = YPs[i] dy = np.mean(np.diff(ytt)) cdft = np.cumsum(ptt) * dy axt = figt.add_subplot(1, Np, count_t) axtt = figtt.add_subplot(1, Np, count_t) ftt = ptt > 0.05 axt.plot(ytt[ftt], ptt[ftt], lw=2, c='r') axt.set_xlabel(r'$y$ (s)') axt.set_ylabel('PDF') axt.set_title(r'${\rm PDF}\left(x_%d, y\right)$' % count_t) axt.set_position([start_b + (count_t - 1) / Np, 0.15, width_b, 0.75]) if plot_mean: xlimt = axt.get_xlim() ylimt = axt.get_ylim() ymean = np.sum(ytt * ptt * dy) / np.sum(ptt * dy) axt.plot([ymean, ymean], ylimt, c='k', linestyle='--', linewidth=0.5) axt.set_xlim(xlimt) axt.set_ylim(ylimt) axt.legend(legends, loc='upper left', prop={'family': 'Simhei'}) axtt.plot(1 - cdft[ftt], ytt[ftt], lw=2, c='b') axtt.set_xlabel(r'$\sigma$') axtt.set_ylabel('CCT (s)') axtt.set_title(r'$\hat{Y}^{\rm c}(x_%d, \sigma)$' % count_t) axtt.set_position([start_b + (count_t - 1) / Np, 0.15, width_b, 0.75]) xticks = np.linspace(0, 1, 6) xticklabels = [('%d%%' % (xt * 100)) for xt in xticks] axtt.set_xticks(xticks) axtt.set_xticklabels(xticklabels) count_t += 1 for fig in [figt, figtt]: #fig.tight_layout() fig.show() if save: mysavefig(fig)
import sys sys.path.append('F:\Programs\PythonWorks\PowerSystem\CCT_10m39b') sys.path.append('F:\Programs\PythonWorks\PowerSystem\MDKernelEstimator') from CCT_10m39b.Simulation.plotfuncs import mysavefig from CCT_10m39b.Plot10m39b.plot10m39b import plot_10m39b_basic from CCT_10m39b.Plot10m39b.plotSMIB import plot_SMIB_basic import matplotlib.pyplot as plt if __name__ == '__main__': postfixt = '.eps' fig_10m39b = plt.figure('10M39B', figsize=(8, 8)) fig_smib = plt.figure('SMIB', figsize=(5.4, 2)) plt.close(fig_10m39b) plt.close(fig_smib) plot_10m39b_basic(fig_10m39b) plot_SMIB_basic(fig_smib) mysavefig(fig_10m39b, 'SLG-IEEE10M39B', postfix=postfixt) mysavefig(fig_smib, 'SLG-SMIB', postfix=postfixt)
plt.close(title_t) fig_t = plt.figure(title_t, figsize=(8, 4)) fig_t.clf() nC = len(cutset_no) buses, special_buses, lines = get_coordinates() colors = ['orange', 'cyan'] label_cs = ['I', 'II'] for i in range(nC): csnt = cutset_no[i] ax_t = fig_t.add_subplot(1, nC, i + 1) slgt = SLGdrawer(buses, special_buses, lines, ax_t) slgt.plot_slg() KK = [] for K in csnt: coort = (buses[K[0]][KEY_COOR] + buses[K[1]][KEY_COOR]) / 2 #ax_t.scatter(buses[K[0]][KEY_COOR][0],buses[K[0]][KEY_COOR][1]) KK.append(coort) KK = np.array(KK) lt, = ax_t.plot(KK[:, 0], KK[:, 1], linestyle='--', marker='v', c=colors[i], linewidth=2) ax_t.legend([lt], [('输电断面%s' % label_cs[i])], prop={'family': 'SimHei'}, loc='right center') fig_t.tight_layout() mysavefig(fig_t)
if bs>=128: xt = np.array(list(ACCs[bs].keys())) yt = np.array(list(ACCs[bs].values())) + offset lt, = axt.plot(xt, yt, linewidth=0.125+0.0125*(1.6**np.log2(bs))) lst.append(lt) legends.append(('%s=%d' % (bssym, bs))) yticklabels = ['%.1f%%' % (t*100) for t in yticks] axt.set_yticks(yticks) axt.set_yticklabels(yticklabels) axt.set_ylim(ylimt) axt.set_xlim([0,50]) axt.set_position((0.12,0.22,0.86,0.75)) if xlabelfont is not None: axt.set_xlabel(xylabel[0],fontname=xlabelfont) else: axt.set_xlabel(xylabel[0]) axt.set_ylabel(xylabel[1]) axt.legend(lst,legends,loc='lower center',bbox_to_anchor=(0,-0.3,1,0.8),ncol=3) figt.show() if change_label: mysavefig(figt,title_t)