Reputation: 307
I have plenty of subplots I have to load and put all together using Matlab. I want to add personalized Ticks but my approach does not seem to work. My mwe is the following:
x = 1:1:1000;
r = rand(1000,1);
my1 = subplot(2,3,1);
my1 = bar(x,sort(r));
title ('This works')
xlabel ('This works too')
xlim ([0 1000])
my = get(gca);
my.XTick = [1 200 499]
And this last point does not work. Why? How can I fix it?
Upvotes: 1
Views: 243
Reputation: 65430
get(gca)
returns a struct
of all graphics properties of the current axes, not the axes handle itself. Any changes made to this struct
of properties are not mirrored in your actual axes
. You need to modify the properties of the axes
directly using set
set(gca, 'XTick', [1 200 499])
Or if you're on 2014b
% Don't use get(gca) to get the handle
ax = gca;
% Set the XTick property
ax.XTick = [1 200 499];
Upvotes: 2