graph1D_jd

PURPOSE ^

SYNOPSIS ^

function [ax] = graph1D_jd(x,y,logx,logy,xlab,ylab,tit,leg,xlim,ylim,style,marker,color,width,font,ax,red,lspace,bspace,eym,eyp,exm,exp)

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [ax] = graph1D_jd(x,y,logx,logy,xlab,ylab,tit,leg,xlim,ylim,style,marker,color,width,font,ax,red,lspace,bspace,eym,eyp,exm,exp)
0002 %
0003 if nargin < 22
0004     exm = NaN;
0005     exp = NaN;
0006 end
0007 if nargin < 23
0008    exp = exm;
0009 end
0010 if nargin < 20
0011     eym = NaN;
0012     eyp = NaN;
0013 end
0014 if nargin < 21
0015     eyp = eym;
0016 end
0017 if nargin < 19
0018     bspace = NaN;
0019 end
0020 if nargin < 18
0021     lspace = NaN;
0022 end
0023 if nargin < 17
0024     red = 1;
0025 end
0026 if nargin < 16
0027     ax = gca;
0028 end
0029 if nargin < 15
0030     font.fontsize = 20+14i;
0031     font.fontname = 'Times';%'Courier';
0032 elseif ~isstruct(font),
0033     fontsize = font;
0034     font = struct;
0035     font.fontsize = fontsize;
0036     font.fontname = 'Times';%'Courier';
0037 else
0038     if ~isfield(font,'fontsize'),
0039         font.fontsize = 20+14i;
0040     end
0041     if ~isfield(font,'fontname'),
0042         font.fontname = 'Times';%'Courier';
0043     end
0044 end
0045 if nargin < 14
0046     width = 0.5;
0047 end
0048 if nargin < 13
0049     color = NaN;
0050 end
0051 if nargin < 12
0052     marker = 'none';
0053 end
0054 if nargin < 11
0055     style = '-';
0056 end
0057 if nargin < 10
0058     ylim = NaN;
0059 end
0060 if nargin < 9
0061     xlim = NaN;
0062 end
0063 if nargin < 8
0064     leg = NaN;
0065 end
0066 if nargin < 7
0067     tit = '';
0068 end
0069 if nargin < 6
0070     ylab = '';
0071 end
0072 if nargin < 5
0073     xlab = '';
0074 end
0075 if nargin < 4
0076     logy = 0;
0077 end
0078 if nargin < 3
0079     logx = 0;
0080 end
0081 if nargin < 2
0082     y = x(:);
0083     x = 1:length(y);
0084 end
0085 if nargin == 0
0086     error('no argument')
0087 end
0088 %
0089 if imag(font.fontsize) == 0,
0090     font.fontsize = font.fontsize+i*font.fontsize;
0091 end
0092 %
0093 hold(ax,'on');
0094 % if logx == 1 & logy ~= 1
0095 %     set(ax,'xscale','log');
0096 %     gcl = semilogx(x,y,'parent',ax);
0097 % elseif logx ~= 1 & logy == 1
0098 %     set(ax,'yscale','log');
0099 %     gcl = semilogy(x,y,'parent',ax);
0100 % elseif logx == 1 & logy == 1
0101 %     set(ax,'xscale','log');
0102 %     set(ax,'yscale','log');
0103 %     gcl = loglog(x,y,'parent',ax);
0104 % else
0105     if ~all(isnan(eym(:))) || ~all(isnan(eyp(:)))
0106         gcl = errorbar(real(x),real(y),real(eym),real(eyp),'parent',ax);
0107     else        
0108         if iscell(marker),
0109             if size(y,1) == length(x)
0110                 nplot = size(y,2);
0111                 y = y';
0112             else
0113                 nplot = size(y,1);
0114             end
0115             for ii = 1:nplot,
0116                 plotmarker = marker;
0117                 plotcolor = color;
0118                 if iscell(marker),
0119                     %plotmarker = marker{ceil(length(marker)*rand)};
0120                     plotmarker = marker{max(1,rem(ii,length(marker)))};
0121                 end
0122                 if size(color,2) == 3,
0123                     %plotcolor = color(ceil(length(color)*rand),:);
0124                     plotcolor = color(max(1,rem(ii,size(color,1))),:);
0125                 end
0126                 %
0127                 gcl = plot(x,y(ii,:),'parent',ax);hold on
0128                 if iscell(marker)
0129                     set(gcl,'marker',plotmarker)
0130                 end
0131                 if size(color,2) == 3,
0132                     set(gcl,'color',plotcolor)
0133                 end
0134                 %
0135                 set(gcl,'linestyle',style);
0136                 if ~iscell(marker),
0137                     set(gcl,'marker',marker);
0138                 end
0139                 %if ~strcmp(style,'none'),
0140                     set(gcl,'linewidth',real(width));
0141                 %else
0142                 if imag(width) == 0,
0143                     set(gcl,'markersize',8);
0144                 else
0145                     set(gcl,'markersize',imag(width));
0146                 end
0147             end
0148             %
0149             color = NaN;
0150             %
0151             if length(marker) >= 3,
0152                 for im = 1:(length(marker)-1)/2,
0153                     set(gcl,marker{2*im},marker{2*im+1});
0154                 end
0155             end
0156         else
0157             gcl = plot(x,y,'parent',ax);
0158         end
0159     end
0160     %
0161     if ~all(isnan(exm)) || ~all(isnan(exp))
0162         gcxp = plot([x(:).';x(:).' + exp(:).'],[y(:).';y(:).'],'parent',ax);
0163         gcxm = plot([x(:).';x(:).' - exm(:).'],[y(:).';y(:).'],'parent',ax);
0164         set(gcxp,'marker','+','color',color);
0165         set(gcxm,'marker','+','color',color);
0166     end
0167 % end
0168 %
0169 hold(ax,'off');
0170 %
0171 if logx == 1,
0172     set(ax,'xscale','log');
0173 else
0174     set(ax,'xscale','linear');
0175 end
0176 %
0177 if logy == 1,
0178     set(ax,'yscale','log');
0179 else
0180     set(ax,'yscale','linear');
0181 end
0182 %
0183 if ~iscell(marker),
0184     set(gcl,'linestyle',style);
0185     %
0186     set(gcl,'marker',marker);
0187 
0188     %if ~strcmp(style,'none'),
0189         set(gcl,'linewidth',real(width));
0190     %else
0191     if imag(width) == 0,
0192         set(gcl,'markersize',8);
0193     else
0194         set(gcl,'markersize',imag(width));
0195     end
0196     %end
0197     if ~isnan(color)
0198         if size(color,2) < 3
0199             set(gcl,'color',color);
0200         end
0201     end
0202 end
0203 %
0204 if ~isnan(xlim)
0205     if length(xlim) == 1
0206         xlim_old = get(ax,'xlim');
0207         if xlim_old(2) > xlim
0208             set(ax,'xlim',[xlim,xlim_old(2)]);
0209         else
0210             set(ax,'xlim',[xlim_old(1),xlim]);
0211         end            
0212     else
0213         set(ax,'xlim',xlim);
0214     end
0215 end
0216 if ~isnan(ylim)
0217     if length(ylim) == 1
0218         ylim_old = get(ax,'ylim');
0219         if ylim_old(2) > ylim
0220             set(ax,'ylim',[ylim,ylim_old(2)]);
0221         else
0222             set(ax,'ylim',[ylim_old(1),ylim]);
0223         end            
0224     else
0225         set(ax,'ylim',ylim);
0226     end
0227 end
0228 %
0229 if ~isempty(xlab),
0230     xl = xlabel(ax,xlab,'fontsize',real(font.fontsize),'fontname',font.fontname);
0231 end
0232 if ~isempty(ylab),
0233     yl = ylabel(ax,ylab,'fontsize',real(font.fontsize),'fontname',font.fontname);
0234 end
0235 if ~isempty(tit),
0236     tl = title(ax,tit,'fontsize',real(font.fontsize),'fontname',font.fontname);
0237 end
0238 %
0239 if iscell(leg) | ~any(isnan(leg)),
0240     Nleg = length(leg);
0241     if iscell(leg) && Nleg > 2 && strcmp(leg(Nleg - 1),'Location'),
0242         lg = legend(ax,leg(1:Nleg - 2),'location',leg{Nleg});
0243     else
0244         lg = legend(ax,leg,'location','best');
0245     end
0246     set(lg,'fontsize',imag(font.fontsize),'fontname',font.fontname);
0247 end
0248 %
0249 set(ax,'fontsize',real(font.fontsize),'fontname',font.fontname);
0250 %
0251 set(gcf,'PaperPositionMode','auto');
0252 %
0253 [lspace_out,bspace_out,apos_new] = resizejd(ax,red);
0254 if isnan(lspace)
0255     lspace = lspace_out;
0256 end
0257 if isnan(bspace)
0258     bspace = bspace_out;
0259 end
0260 %
0261 [lspace_out,bspace_out,apos_new] = resizejd(ax,1,lspace,bspace);
0262 %
0263 box(ax,'on');
0264 grid(ax,'on');

Community support and wiki are available on Redmine. Last update: 18-Apr-2019.