Changeset 1878


Ignore:
Timestamp:
08/25/09 12:02:53 (16 years ago)
Author:
Mathieu Morlighem
Message:

improved quiverplot

Location:
issm/trunk/src/m/classes/public/plot
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/plot/parse_options.m

    r1744 r1878  
    3131else
    3232        options_struct.scaling=NaN;
     33end
     34
     35%autoscale
     36autoscalevalues=findarg(optionstring,'autoscale');
     37if ~isempty(autoscalevalues),
     38        options_struct.autoscale=autoscalevalues(1).value;
     39else
     40        options_struct.autoscale=NaN;
    3341end
    3442
  • issm/trunk/src/m/classes/public/plot/plot_quiver.m

    r1780 r1878  
    1010%      plot_quiver(md.x,md.y,md.vx,md.vy,options_structure);
    1111
     12%keep only non NaN elements
     13pos=find(~isnan(x) & ~isnan(y) & ~isnan(u) & ~isnan(v));
     14x=x(pos); y=y(pos);
     15u=u(pos); v=v(pos);
     16
    1217%get norm Min and Max
    1318Norm=sqrt(u.^2+v.^2);
     
    1722%process options: scaling factor?
    1823if isnan(options_structure.scaling),
    19         arrow=0.40;
     24        scalingfactor=0.40;
    2025elseif isnumeric(options_structure.scaling),
    21         arrow=options_structure.scaling;
    22 elseif ischar(options_structure.scaling) & strcmpi(options_structure.scaling,'off'),
    23         arrow=NaN;
     26        scalingfactor=options_structure.scaling;
    2427else
    2528        error('plot_quiver error message: scaling option other than scalaer or ''off'' not supported yet')
     
    5861
    5962%Scale data
    60 if ~isnan(arrow),
     63if ~isnan(options_structure.autoscale) & strcmpi(options_structure.autoscale,'off'),
    6164        delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
    62         u=arrow*sqrt(delta)*u./Norm;
    63         v=arrow*sqrt(delta)*v./Norm;
     65        u=scalingfactor*sqrt(delta)*u./Norm;
     66        v=scalingfactor*sqrt(delta)*v./Norm;
     67else
     68        delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
     69        u=scalingfactor*sqrt(delta)*u./max(Norm);
     70        v=scalingfactor*sqrt(delta)*v./max(Norm);
    6471end
    6572
  • issm/trunk/src/m/classes/public/plot/plot_quiver3.m

    r1744 r1878  
    1010%      plot_quiver(md.x,md.y,md.z,md.vx,md.vy,md.vz,options_structure);
    1111
     12%keep only non NaN elements
     13pos=find(~isnan(x) & ~isnan(y) & ~isnan(z) & ~isnan(u) & ~isnan(v) & ~isnan(w));
     14x=x(pos); y=y(pos); z=z(pos);
     15u=u(pos); v=v(pos); w=w(pos);
     16
    1217%get norm Min and Max
    1318Norm=sqrt(u.^2+v.^2+w.^2);
     
    1722%process options: scaling factor?
    1823if isnan(options_structure.scaling),
    19         arrow=0.40;
     24        scalingfactor=0.40;
     25elseif isnumeric(options_structure.scaling),
     26        scalingfactor=options_structure.scaling;
    2027else
    21         arrow=options_structure.scaling;
     28        error('plot_quiver error message: scaling option other than scalaer or ''off'' not supported yet')
    2229end
    2330
     
    5461
    5562%Scale data
    56 delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
    57 u=arrow*sqrt(delta)*u./Norm;
    58 v=arrow*sqrt(delta)*v./Norm;
    59 w=arrow*sqrt(delta)*w./Norm;
     63if ~isnan(options_structure.autoscale) & strcmpi(options_structure.autoscale,'off'),
     64        delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
     65        u=scalingfactor*sqrt(delta)*u./Norm;
     66        v=scalingfactor*sqrt(delta)*v./Norm;
     67else
     68        delta=((min(x)-max(x))^2+(min(y)-max(y))^2)/numel(x);
     69        u=scalingfactor*sqrt(delta)*u./max(Norm);
     70        v=scalingfactor*sqrt(delta)*v./max(Norm);
     71end
    6072
    6173%loop over the number of colors
     
    6981
    7082%take care of colorbar
    71 if  0 & ~strcmpi(options_structure.colorbar,'off'),
     83if  ~strcmpi(options_structure.colorbar,'off'),
     84
     85        %build ticks
     86        hcb=colorbar('peer',gca,'location','EastOutside');
     87        ticklabel=cell(1,length(levels));
    7288        for i=1:length(levels),
    73                 scalevalues(i)=levels(i);
    74                 scalestring=[scalestring; sprintf('%8.4g',levels(i))];
     89                ticklabel{i}=num2str(round_ice(levels(i),3));
    7590        end
    76         set(colorbar,'YTickLabel',scalestring,'YTick',scalevalues);
    77         error('debug')
     91        tickpos=1:numcolors+1;
     92
     93        %remove ticks if to many have been created
     94        proportion=round(length(levels)/10);
     95        if proportion>1,
     96                ticklabel=ticklabel(1:proportion:end);
     97                tickpos=tickpos(1:proportion:end);
     98        end
     99
     100        %draw colorbar
     101        set(hcb,'YTickLabel',ticklabel,'YTick',tickpos);
     102        %position
     103        if ~isnan(options_structure.colorbarpos),
     104                set(hcb,'Position',options_structure.colorbarpos);
     105        end
     106        %fontsize
     107        if ~isnan(options_structure.fontsize),
     108                fontsize=options_structure.fontsize;
     109        else
     110                fontsize=14;
     111        end
     112        set(hcb,'FontSize',fontsize);
    78113end
  • issm/trunk/src/m/classes/public/plot/plotdoc.m

    r1805 r1878  
    8383disp('       ''alpha'': transparency coefficient (the higher, the more transparent). Default is 1.5');
    8484disp('       ''scaling'': scaling factor used by quiver plots. Default is 0.4');
     85disp('       ''autoscale'': set to ''off'' to have all the quivers with the same size. Default is ''on''');
    8586disp('       ''expdisp'': plot exp file on top of a data plot. provide exp file as an argument (use a cell of strings if more than one)');
    8687disp('       ''expstyle'': marker style for expdisp plot (use a cell of strings if more than one)');
Note: See TracChangeset for help on using the changeset viewer.