Is it possible to have a zero value in the pie-chart data in MATLAB 7.6 (R2008a)?

조회 수: 3 (최근 30일)
When plotting a pie-chart with any one of the data values as zero and a user-defined colormap,unexpected colors are skipped. I also get a warning message
"Warning: Ignoring non-positive data in pie chart."
With first value as 0, it skips green(second value on colormap)
Dat = [0 10 20 40]
t1col = [1 0 0]; %red
t2col = [0 1 0]; %green
t3col = [0 0 1]; %blue
t4col = [1 0 1]; %magenta
tilecolor = [t1col; t2col; t3col; t4col];
pie(Dat)
colormap(tilecolor)
With second value as 0, it skips green again
dat = [5 0 20 40]
t1col = [1 0 0]; %red
t2col = [0 1 0]; %green
t3col = [0 0 1]; %blue
t4col = [1 0 1]; %magenta
tilecolor = [t1col; t2col; t3col; t4col];
pie(dat)
colormap(tilecolor)

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 6월 27일
The ability to handle zero values in pie-chart is not available in MATLAB 7.6 (R2008a).
To work around this issue, use the attached function pie_modified(dat,tilecolor)
where variable 'Dat' is the data values for the pie chart and variable 'tilecolor' is the colormap for it. For example:
Dat = [0 10 20 40]
t1col = [1 0 0]; %red
t2col = [0 1 0]; %green
t3col = [0 0 1]; %blue
t4col = [1 0 1]; %magenta
tilecolor = [t1col; t2col; t3col; t4col];
pie_modified(Dat,tilecolor)

추가 답변 (1개)

KAE
KAE 2019년 11월 6일
If you are doing this to plot a pie which is missing a slice, see here ('Partial Pie').

카테고리

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

태그

아직 태그를 입력하지 않았습니다.

제품


릴리스

R2008a

Community Treasure Hunt

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

Start Hunting!

Translated by