Search code examples
matlabmatlab-figure

Changing font size of colorbar TickLabels in Matlab automatically


How can I change font size of colorbar TickLabels in Matlab automatically? I know I can change the font using

c = colorbar;
c.Label.String = 'string';
c.Label.FontSize=16;

But couldn't find how to change the fontsize of ticks.

Font size of labels is increased but not the ticklables


Solution

  • You may be referring to the thickness of the ticks, which you can change with the property

    c.LineWidth
    

    or you can change the font size of the ticks with

    c.FontSize
    

    There are a lot of other properties you can play with, in 2018b specifically, these are the modifiable properties and their default values:

            AxisLocation: 'out'
        AxisLocationMode: 'auto'
            BeingDeleted: 'off'
                     Box: 'on'
              BusyAction: 'queue'
           ButtonDownFcn: ''
                Children: [0×0 GraphicsPlaceholder]
                   Color: [0.1500 0.1500 0.1500]
               CreateFcn: ''
               DeleteFcn: ''
               Direction: 'normal'
               FontAngle: 'normal'
                FontName: 'Helvetica'
                FontSize: 9
              FontWeight: 'normal'
        HandleVisibility: 'on'
                 HitTest: 'on'
           Interruptible: 'off'
                   Label: [1×1 Text]
                  Limits: [0 1]
              LimitsMode: 'auto'
               LineWidth: 0.5000
                Location: 'eastoutside'
                  Parent: [1×1 Figure]
           PickableParts: 'visible'
                Position: [0.8307 0.1095 0.0381 0.8167]
                Selected: 'off'
      SelectionHighlight: 'on'
                     Tag: 'Colorbar'
           TickDirection: 'in'
    TickLabelInterpreter: 'tex'
              TickLabels: {11×1 cell}
          TickLabelsMode: 'auto'
              TickLength: 0.0100
                   Ticks: [0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1]
               TicksMode: 'auto'
                    Type: 'colorbar'
           UIContextMenu: [1×1 ContextMenu]
                   Units: 'normalized'
                UserData: []
                 Visible: 'on'
    

    If its not here, you can not change it.