How can I assign multiple colors to tick labels in plots in MATLAB? -
is possible color single number (or set of numbers) on 1 of axes in matlab?
suppose have plot:
plot(1:10, rand(1,10))
now, can e.g. make number 3 on x-axis red?
unfortunately, cannot have multiple colors tick labels in 1 axes object. however, there's solution (inspired this page mathworks support site) achieves same effect. overlays existing axes axes has 1 red tick.
here's example:
figure plot(1:10, rand(1,10)) ax2 = copyobj(gca, gcf); %// create copy axes set(ax2, 'xtick', 3, 'xcolor', 'r', 'color', 'none') %// keep 1 red tick ax3 = copyobj(gca, gcf); %// create copy set(ax3, 'xtick', [], 'color', 'none') %// keep gridline
the result is:
Comments
Post a Comment