Using string as data for plotting
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I have a code that plot data on 4 subplots
I have problem with the labels head_val= {a,b,c,a,b,c,b,c,c}
I need them to be on tick marks as follows:
Subplot (1): a b c ,(3 bars)
Subplot (2): a b c,(3 bars)
Subplot (3): b c,(2 bars)
Subplot (4): c,(1 bar)
------------------------------------------
This code: set(gca, 'XTick', 1:9, 'XTickLabel', (valhead));
distributes the ticks as follows Subplot (1): a b c , Subplot (2): a b c, Subplot (3): a b, Subplot (4): a,
It seems that the gca line loops over the first three strings only
Thanks ---UPDATE---- This is a display to show the difference between what's needed and what I get http://imageshack.us/photo/my-images/13/displayz.jpg/
Answers (1)
Sean de Wolski
on 7 Dec 2011
If you only want the labels replicated once, it appears you're going to have issues since you have nine ticks:
From the (doc axes -> axes properties): XTickLabel, YTickLabel, ZTickLabel string Tick labels. A matrix of strings to use as labels for tick marks along the respective axis. These labels replace the numeric labels generated by MATLAB. If you do not specify enough text labels for all the tick marks, MATLAB uses all of the labels specified, then reuses the specified labels
Else just use a cell array to group the labels, something similar to:
head_val= {'a,b,c','a,b,c','b,c','c'};
figure;
for ii = 1:4;
subplot(2,2,ii)
plot(rand(1,10));
set(gca, 'XTick', 1:9, 'XLabel', head_val{ii});
end
Or is the 1:9 not constant as an xtick?
1 Comment
Mariam Osmann
on 9 Dec 2011
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!