Changeset 1746


Ignore:
Timestamp:
08/18/09 14:10:04 (15 years ago)
Author:
Mathieu Morlighem
Message:

improved number of ticks

File:
1 edited

Legend:

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

    r1745 r1746  
    1818if isnan(options_structure.scaling),
    1919        arrow=0.40;
     20elseif isnumeric(options_structure.scaling),
     21        arrow=options_structure.scaling;
     22elseif ischar(options_structure.scaling) & strcmpi(options_structure.scaling,'off'),
     23        arrow=NaN;
    2024else
    21         arrow=options_structure.scaling;
     25        error('plot_quiver error message: scaling option other than scalaer or ''off'' not supported yet')
    2226end
    2327
     
    5458
    5559%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;
     60if ~isnan(arrow),
     61        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;
     64end
    5965
    6066%loop over the number of colors
     
    6975%take care of colorbar
    7076if  ~strcmpi(options_structure.colorbar,'off'),
     77
     78        %build ticks
    7179        hcb=colorbar('peer',gca,'location','EastOutside');
    72         tickn=cell(1,length(levels));
     80        ticklabel=cell(1,length(levels));
    7381        for i=1:length(levels),
    74                 tickn{i}=num2str(levels(i));
     82                ticklabel{i}=num2str(levels(i));
    7583        end
    76         set(hcb,'YTickLabel',tickn,'YTick',1:numcolors+1);
     84        tickpos=1:numcolors+1;
     85
     86        %remove ticks if to many have been created
     87        proportion=round(length(levels)/10);
     88        if proportion>1,
     89                ticklabel=ticklabel(1:proportion:end);
     90                tickpos=tickpos(1:proportion:end);
     91        end
     92
     93        %draw colorbar
     94        set(hcb,'YTickLabel',ticklabel,'YTick',tickpos);
    7795        %position
    7896        if ~isnan(options_structure.colorbarpos),
     
    87105        set(hcb,'FontSize',fontsize);
    88106end
    89 
    90 %Now no colorbar done by
Note: See TracChangeset for help on using the changeset viewer.