plot using with characters which are cell and numeric data.

data=[1;2;3;4;5;6];
ids={'12.1a';'1.2b';'1.3c';'1.4d';'1.7e';'1.8f'}
%I wanna plot the data and ids like, plot(ids,data,'b') but Conversion to double from cell is not possible error occurs.
%How I can handle this cellarray for plot?

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 25 日
編集済み: Azzi Abdelmalek 2014 年 12 月 25 日

0 投票

data=[1;2;3;4;5;6]
ids={'12.1a';'1.2b';'1.3c';'1.4d';'1.7e';'1.8f'}
plot(data,'b')
set(gca,'XTick',1:numel(ids))
set(gca,'XTickLabel',ids)

4 件のコメント

sermet
sermet 2014 年 12 月 25 日
Thank you for your answer. I need to rotate ids (to write vertically), how can I do that?
sermet
sermet 2014 年 12 月 25 日
sometimes ids would be very large (hundreds) so they cannot be easily readable.
Azzi Abdelmalek
Azzi Abdelmalek 2014 年 12 月 25 日
If you have the latest version of Matlab add this
h=gca,
h. XTickLabelRotation=90
If not, reduce the number of ticks
ids={'12.1a';'1.2b';'1.3c';'1.4d';'1.7e';'1.8f'}
data=1:24
ids=repmat({'12.1a';'1.2b';'1.3c';'1.4d';'1.7e';'1.8f'},4,1)
plot(data,'b')
NumTick=8 % number of ticks
xticks=linspace(1,numel(data),NumTick)
set(gca,'XTick',xticks)
set(gca,'XTickLabel',ids)
sermet
sermet 2014 年 12 月 25 日
I downloaded Rotate Tick Label and applied it. It worked well but I'm still having difficulty for scale. Hunderds of ids seem very close. Can I seperate them a little bit to reading more easily?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

質問済み:

2014 年 12 月 25 日

コメント済み:

2014 年 12 月 25 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by