%something to plot clear(); close all; %this function sets the grid and the font size function h=setGrid (varargin) if length (varargin)==1 %use the axis handle passed to the function h=varargin{1}; else h=gca; %get axis handle end %set a black grid and font 20 set(h,'GridLineStyle','-','GridAlpha',1,'GridColor',[0,0,0]) set(h,'MinorGridLineStyle','-','MinorGridAlpha',1,'MinorGridColor',[0,0,0]) set(h, 'FontSize', 20); %set global font grid on; endfunction function xs2svg(handle,name) %now save the figure LX="-S1200,800"; %this is the saved size which is important to have correct text sizes print(handle, name, LX,"-dsvg"); endfunction x = 1:1000:100000; hf = figure (1); %set figure size XMIN=20; YMIN=200; WIDTH=800; HEIGTH=500; figure(hf, 'position',[XMIN,YMIN,WIDTH,HEIGTH]); %do the plots DO_LIN=0; if DO_LIN==1 s1=sin(x/1000); s2=cos(x/1000); subplot(211) plot(x,s1,"LineWidth",2,"Color","green") subplot(212) plot(x,s2,"LineWidth",2,"Color","blue") subplot(211) hu=setGrid(); ylabel ("|Z|"); %,"FontSize",20); subplot(212) hd=setGrid(); ylabel ("Phase"); %,"FontSize",20); xlabel ("Freq (Hz)"); %,"FontSize",20) else s1=(1.01+sin(x/1000))*1e7.*exp(-x/10000); s1R=(1.01+cos(x/1000))*1e7.*exp(-x/10000); s2=1.01+cos(x/1000); subplot(211) loglog(x,s1,"LineWidth",2,"Color","green") hold on loglog(x,s1R,"LineWidth",2,"Color","blue") subplot(212) semilogx(x,s2,"LineWidth",2,"Color","green") %adjust the aspect upper plot subplot(211) hu=setGrid(); ylabel ("|Z|"); %optionally change some aspects of the plot %change the axix bounds bounds=axis(hu); %bounds xmin xmax ymin ymax bounds(1)=0.1; bounds(2)=100000; bounds(3)=0.1; bounds(4)=1e8; axis(bounds); %remove some labels pl=yticks(); lb=yticklabels(); nl=size(pl,2); id=[1:2:nl]; plh=pl(id); lbh=lb(id); yticks(plh); yticklabels(lbh); % we can also change the labels ll=lbh; ll(1)="10^{0}"; %use this notation to have exponents ll(2)="100"; ll(3)="10k"; ll(4)="1M"; ll(5)="100M"; yticklabels(ll); %add a legend the size is critical hl=legend ("D1","D2xxxxx"); legend (hl,"location", "northeastoutside"); %on the second plot subplot(212) hd=setGrid(); ylabel ("Phase"); xlabel ("Freq (Hz)"); bounds=axis(); %bounds xmin xmax ymin ymax bounds(1)=0.1; bounds(2)=100000; bounds(3)=-2; bounds(4)=3; axis(bounds); %beware the legend is required to have the same plot size hl=legend ("D1xxxxx"); legend (hl,"location", "northeastoutside"); end %of do lin %now save the figure xs2svg(hf,"test.svg");