how to remove border and percentages from pie chart?

12 ビュー (過去 30 日間)
Minka Califf
Minka Califf 2018 年 5 月 19 日
コメント済み: Ameer Hamza 2018 年 5 月 19 日
Hello, I am trying to remove the black border outside the pie chart and remove those percentages as well. I am a beginner so any advice would be greatly appreciated.
%create pie chart
X = [1 5]
pie(X);
%add legend
labels = {'Does not resemble Pacman','Resembles Pacman'};
L = legend(labels, 'location', 'east');
set(L, 'position', get(L, 'position') + [.3 0 0 0], ...
'fontsize', 12, 'box', 'off');
%rotate axis
ax = gca;
ax.View = [120 90];

採用された回答

Ameer Hamza
Ameer Hamza 2018 年 5 月 19 日
The patches and text are Children of axis object. You can view them using
ax.Children
ans =
4×1 graphics array:
Text (83%)
Patch (Resembles Pacman)
Text (17%)
Patch (Does not resemble Pacman)
To achieve the result you want, add these lines to the end of your code
ax.Children(2).EdgeAlpha = 0; % index 2 and 4 corrosponds to the ptaches in ax.Children . If the order is different in your case change it accordingly
ax.Children(4).EdgeAlpha = 0;
delete(ax.Children([1, 3])) . % delete the text object according to index from ax.Children
  2 件のコメント
Minka Califf
Minka Califf 2018 年 5 月 19 日
Thanks Ameer!
Ameer Hamza
Ameer Hamza 2018 年 5 月 19 日
You are welcome.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by