legend pie chart

조회 수: 3 (최근 30일)
franz
franz 2012년 1월 19일
Hi i'm new to matlab and i have a question. for example if i have a vector with some ascii numbers, like
x=[65 65 67 68 68 68 68]
and i then want to draw a pie chart with the most frequent letter.
x=[65 65 67 68 68 68 68]
char(x)
y=unique(x)
counts=histc(x,y)
pie(counts,cellstr(num2str(counts(:))))
but my problem is that i want to have a legend witch will say what letter the different coulors represents, is that possible?
  댓글 수: 1
the cyclist
the cyclist 2012년 1월 19일
Really an aside to your question, but you would probably want to use hist() rather than hist(), because you are specifying the bins, not the edges between the bins.
Also, I would recommend against a pie chart here. A bar chart will most likely allow the consumer to better judge the relative letter frequency.

댓글을 달려면 로그인하십시오.

채택된 답변

Sean de Wolski
Sean de Wolski 2012년 1월 19일
Like this?
x=[65 65 67 68 68 68 68];
y=unique(x);
counts=histc(x,y);
pie(counts,cellstr(char((y')))')
Note transpose for num2str()
  댓글 수: 11
Sean de Wolski
Sean de Wolski 2012년 1월 19일
legend(cellstr(char((y')))')
franz
franz 2012년 1월 19일
Yes that worked thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Pie Charts에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by