⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fm_plot.m

📁 电力系统的psat
💻 M
📖 第 1 页 / 共 3 页
字号:
    end    fprintf(fid,'\n');    if tipoplot == 3 | tipoplot == 6       fm_disp('MTV format does not support numbered plots.')    end                for i = 1:size(Y,2)      labelmtv = strrep(legenda{i},'{','');      labelmtv = strrep(labelmtv,'}','');      labelmtv = strrep(labelmtv,'_',' ');      labelmtv = strrep(labelmtv,'\','');      fprintf(fid,'%% linelabel="%s"\n',labelmtv);      switch tipoplot       case 2        linetype = rem(i-1,10)+1;        linecolor = 1;        markertype = 0;        markercolor = 1;               case 4        linetype = 1;        linecolor = 1;        markertype = rem(i-1,13)+1;        markercolor = 1;                       case 5        linetype = 1;        linecolor = rem(i-1,10)+1;        markertype = rem(i-1,13)+1;        markercolor = linecolor;                               otherwise        linetype = 1;        linecolor = rem(i-1,10)+1;        markertype = 0;        markercolor = 1;        end      fprintf(fid,'%% linetype=%d linecolor=%d markertype=%d markercolor=%d\n', ...              linetype,linecolor,markertype,markercolor);      fprintf(fid,'%8.5f %8.5f\n',[X,Y(:,i)]');      fprintf(fid,'\n');          end        fclose(fid);     fm_disp(['Data exported to MTV plot file "',plainfile,'.mtv"'])      end    if out_matlab    plainfile = fm_filenum('m');    fid = fopen([Path.data,plainfile,'.m'],'wt');    if fid == -1      fm_disp('Cannot open file. Data not saved.')      return    end    fprintf(fid,'x_label = ''%s'';\n',Settings.xlabel);    fprintf(fid,'\nvar_legend = {');    for i = 1:size(Y,2)-1      fprintf(fid,'''%s'', ',legenda{i});    end    fprintf(fid,'''%s''};\n',legenda{end});    fprintf(fid,'\noutput_data = [ ...\n');    fprintf(fid,[repmat('%8.5f  ',1,1+size(Y,2)),';\n'], ...            [X(1:end-1),Y(1:end-1,:)]');    fprintf(fid,[repmat('%8.5f  ',1,1+size(Y,2)),'];\n'], ...            [X(end),Y(end,:)]');    fclose(fid);     fm_disp(['Data exported to plain text file "',plainfile,'.m"'])      end   if ~isempty(OPF.varout)    set(gcf,'DefaultAxesColorOrder',Settings.color)    simboli = {'o';'s';'d';'v';'^';'<';'>';'x'};    set(Fig.plot,'CurrentAxes',hdlfig);    h = plot(X,Y(:,Varname.po));    for i = 1:numero,      set(h(i),'Marker',simboli{rem(i-1,8)+1}, ...               'MarkerFaceColor',AxesColor, ...               'MarkerSize',6);    end    %tipoplot = get(Hdl_tipoplot,'Value');    if tipoplot == 2      set(h,'Color','k')    end  else    set(Fig.plot,'CurrentAxes',hdlfig);    plot(X(snap_idx),Y(snap_idx,Varname.po));  end  if AbValue == 1    xlabel(Settings.xlabel);  else    xlabel(Stringa(AbValue-1));  end  if min(X) < max(X)    set(hdlfig,'XLim',[min(X),max(X)])  end  %legend  if leg_value == 1 | Settings.hostver >= 7    hleg = legend(legenda,0);    Hdl.legend = hleg;    set(hleg,'Color',AxesColor)    hchild = get(hleg,'Child');    set(hchild(end), ...        'FontName',AxesFont, ...        'FontWeight',AxesWeight, ...        'FontAngle',AxesAngle)  end  %tipoplot = get(Hdl_tipoplot,'Value');    if ~isempty(Varout.t) & isempty(OPF.varout)    if tipoplot == 3 | tipoplot == 6            [quanti,tanti] = size(Y);      passo = (quanti-rem(quanti,8))/8;      colori = get(gcf,'DefaultAxesColorOrder');            for i = 1:tanti        if plot_snap          sequenza = snap_idx;        else          tmin = min(Varout.t);          tmax = max(Varout.t);          deltat = (tmax-tmin)/5;          tmin = tmin + i*(tmax-tmin)/43;          seqt = tmin:deltat:tmax;          for j = 1:length(seqt),            [valt, sequenza(j)] = min(abs(Varout.t-seqt(j)));          end        end        hdl = text(Varout.t(sequenza), ...                   Y(sequenza,i),num2str(Varname.po(i)));        if tipoplot == 6,          set(hdl,'Color',colori(rem(i-1,7)+1,:));        end      end      if leg_value == 1 | Settings.hostver >= 7        hdl = findobj(Fig.plot,'Tag','legend');        oldh = gca;        set(gca,'HandleVisibility','off')        set(hdl,'Interruptible','on')        h = findobj(hdl,'Type','line');               for i = 1:tanti          j = i*2;          xdata = get(h(j),'XData');          ydata = get(h(j),'YData');          htext = text((xdata(2)-xdata(1))/2,ydata(1), ...                       int2str(tanti-i+1));          set(htext,'Color',get(h(j),'Color'));        end        set(oldh,'HandleVisibility','on')        set(Fig.plot,'CurrentAxes',oldh);      end    elseif tipoplot == 4 | tipoplot == 5            [quanti,tanti] = size(Y);      passo = (quanti-rem(quanti,8))/8;      hold on      simboli = {'o';'s';'d';'v';'^';'<';'>';'x'};      colori = get(Fig.plot,'DefaultAxesColorOrder');            for i = 1:tanti        if plot_snap          sequenza = snap_idx;        else          tmin = min(Varout.t);          tmax = max(Varout.t);          deltat = (tmax-tmin)/5;          tmin = tmin + i*(tmax-tmin)/43;          seqt = tmin:deltat:tmax;          for j = 1:length(seqt),            [valt, sequenza(j)] = min(abs(Varout.t-seqt(j)));          end        end        set(hdlfig,'LineStyle',simboli{rem(i-1,8)+1});        hmarker = plot(Varout.t(sequenza), ...                       Y(sequenza,Varname.po(i)));        set(hmarker,'MarkerSize',7, ...                    'MarkerFaceColor',AxesColor);        if tipoplot == 5,          set(hmarker,'Color',colori(rem(i-1,7)+1,:));        end      end      hold off;            if leg_value == 1 | Settings.hostver >= 7        hdl = findobj(Fig.plot,'Tag','legend');        set(Fig.plot,'CurrentAxes',hdl);        h = findobj(hdl,'Type','line');        for i = 1:tanti          j = i*2;          xdata = get(h(j),'XData');          ydata = get(h(j),'YData');          set(hdl,'LineStyle',simboli{rem(tanti-i,8)+1});          if Settings.hostver >= 7            hmarker = plot(hdl,(xdata(2)-xdata(1))/1.2,ydata(1));          else            hmarker = plot((xdata(2)-xdata(1))/1.2,ydata(1));          end          set(hmarker,'MarkerSize',7, ...                      'Color',get(h(j),'Color'), ...                      'MarkerFaceColor',AxesColor);        end        set(Fig.plot,'CurrentAxes',hdlfig);      end               end  end      if get(Hdl_grid,'Value'); grid on; end  if ~get(Hdl_legend,'Value') & Settings.hostver >= 7    legend(Hdl.axesplot,'hide')  end  set(get(hdlfig,'XLabel'), ...      'FontName',AxesFont, ...      'FontWeight',AxesWeight, ...      'FontAngle',AxesAngle, ...      'FontSize',AxesSize, ...      'FontUnits',AxesUnits)  set(hdlfig, ...      'FontName',AxesFont, ...      'Color',AxesColor, ...      'FontWeight',AxesWeight, ...      'FontAngle',AxesAngle, ...      'FontSize',AxesSize, ...      'FontUnits',AxesUnits)    %set(hdlfig,'FontName',Theme.font01)  if Fig.line > 0, fm_plot(19), end  if get(hdl_x, 'Value'), fm_plot(9), end  if get(hdl_y, 'Value'), fm_plot(7), end  if get(hdl_xy,'Value'), fm_plot(10), end   % --------------------------------------------------------------------- case 2 % Export the figure to file % ---------------------------------------------------------------------  tag = get(gcbo,'Tag');  SSize = get(0,'ScreenSize');  Sratio = SSize(3)/SSize(4);    axs_pos = get(Hdl.axesplot,'Position');  fig_pos = get(Fig.plot,'Position');  pap_pos = get(Fig.plot,'PaperPosition');  pap_siz = get(Fig.plot,'PaperSize');  leg_value = get(Hdl_legend,'Value');  if leg_value    pos_leg = get(Hdl.legend,'Position');  end    shrink = 0.8; % axes scale factor    set(Hdl.axesplot,'Position',[0.13 0.11 0.855 0.875])  set(Fig.plot,'Position',[fig_pos(1), fig_pos(2), ...                      fig_pos(3)*shrink, fig_pos(4)*shrink])  if leg_value    pos_leg2(1) = 0.13 + 0.855*(pos_leg(1) - axs_pos(1))/axs_pos(3);    pos_leg2(2) = 0.11 + 0.875*(pos_leg(2) - axs_pos(2))/axs_pos(4);    pos_leg2(3) = pos_leg(3)*0.855/axs_pos(3);    pos_leg2(4) = pos_leg(4)*0.875/axs_pos(4);    set(Hdl.legend,'Position',pos_leg2);        if pos_leg2(1)+pos_leg2(3) > 0.985      Resize = (pos_leg2(1)+pos_leg2(3))/0.985;      fig_pos2 = [0.13 0.11 0.855 0.875];      fig_pos2(3) = fig_pos2(3)/Resize;      fig_pos2(1) = fig_pos2(1)/Resize;      pos_leg2(3) = pos_leg2(3)/Resize;      pos_leg2(1) = pos_leg2(1)/Resize;      set(Hdl.axesplot,'Position',fig_pos2)      set(Hdl.legend,'Position',pos_leg2)    end  end    if Settings.hostver > 5.3,    set(Fig.plot,'PaperSize',[pap_siz(1)*shrink, pap_siz(2)*shrink])  end  ppos(3) = pap_pos(3)*shrink;  ppos(4) = pap_pos(4)*shrink;  ppos(1) = (pap_siz(1)-ppos(3))/2;  ppos(2) = (pap_siz(2)-ppos(4))/2;  set(Fig.plot,'PaperPosition',ppos) ax2_pos = get(Hdl.axeslogo,'Position'); set(Hdl.axeslogo,'Position',[10 10 0.2 0.2]); Hdl_all = get(Fig.plot,'Children'); idx = find(Hdl_all==Hdl.axesplot); if idx, Hdl_all(idx) = []; end idx = find(Hdl_all==Hdl.axeslogo); if idx, Hdl_all(idx) = []; end if leg_value,   idx = find(Hdl_all==Hdl.legend);   if idx, Hdl_all(idx) = []; end end set(Hdl_all,'Visible','off'); warning off lastwarn('') switch tag  case 'PushEPS'   nomefile = fm_filenum('eps');   print(Fig.plot,'-depsc',[Path.data,nomefile])   set(hdlfig,'Position',axs_pos);   set(hdlfig2,'Position',ax2_pos);   set(Fig.plot,'Position',fig_pos)   set(Fig.plot,'PaperPosition',pap_pos)   if Settings.hostver > 5.3,     set(Fig.plot,'PaperSize',pap_siz)   end   set(Hdl_all,'Visible','on');   if leg_value     set(Hdl.legend,'Position',pos_leg);   end  case 'PushMeta'   print(Fig.plot,'-dmeta')   set(hdlfig,'Position',axs_pos);   set(hdlfig2,'Position',ax2_pos);   set(Fig.plot,'Position',fig_pos)   set(Fig.plot,'PaperPosition',pap_pos)   if Settings.hostver > 5.3,     set(Fig.plot,'PaperSize',pap_siz)   end   set(Hdl_all,'Visible','on');   if leg_value     set(Hdl.legend,'Position',pos_leg);   end  case 'PushFig'   figplot = Fig.plot;   Fig.plot = 0;   set(figplot, ...       'Position',[0.2265 0.2265 0.5469 0.5469], ...       'Menubar','figure', ...       'Name','', ...       'NumberTitle','on', ...       'CreateFcn','', ...       'DeleteFcn','', ...       'UserData',[], ...       'FileName','')   delete(Hdl_all)   delete(hdlfig2)   fm_plotfig   figure(figplot) end if ~isempty(lastwarn) & ~strcmp(lastwarn,'File not found or permission denied')   fm_disp(lastwarn,2), end warning oncase 3 tipoplot = get(Hdl_tipoplot,'Value'); switch tipoplot  case 1,   set(Fig.plot, ...       'DefaultAxesColorOrder',Settings.color, ...       'DefaultAxesLineStyle','-');  case 2,   set(Fig.plot, ...       'DefaultAxesColorOrder',[ 0 0 0 ], ...       'DefaultAxesLineStyleOrder','-|-.|--|:');  case 3,   set(Fig.plot, ...       'DefaultAxesColorOrder',[ 0 0 0 ], ...       'DefaultAxesLineStyle','-');  case 4,   set(Fig.plot, ...       'DefaultAxesColorOrder',[ 0 0 0 ], ...       'DefaultAxesLineStyle','-');  otherwise,   set(Fig.plot, ...       'DefaultAxesColorOrder',Settings.color, ...       'DefaultAxesLineStyle','-'); endcase 4 value =  get(Hdl_listplot,'Value'); if ~isempty(get(Hdl_listplot,'String'))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -