Reputation: 627
I would like to do a scatter plot with two populations A and B. I am currently using zeros and ones to generate the scatter plot. So A is line up at x=0 and B and x=1. Is it possible to delete numbers from the x-axis and just add a string? So that it looks like a histogram?
Upvotes: 2
Views: 3929
Reputation: 14939
Something like this should do the trick:
scatter(x,y);
labels = {'A', 'B'}
set(gca,'XTick',0:1)
set(gca,'XTickLabel',labels)
set(gca,'XTick',0:1)
is used to only place ticks on 0 and 1. Similarly, for all integers within range: 0:max(x)
.
set(gca,'XTickLabel',labels)
is used to change the name of the ticks. Note that the length of labels
must be equal to the number of ticks.
Upvotes: 2
Reputation: 20914
Yes. if you get a handle to the axes you can use the XTick
and XTickLabel
properties e.g.
set(gca, 'XTick', [], 'XTickLabel', []);
to remove them entirely, or
set(gca, 'XTick', [0 1], 'XTickLabel', {'this one', 'that one'});
Or just play with properties until you find something you like ;)
(you can also fiddle with things via the figure property editor in the GUI if you don't want to do it programmatically)
Upvotes: 3