Scatter‐plot marker edge color turns black when copying to PowerPoint

조회 수: 2 (최근 30일)
Anna Ipata
Anna Ipata 2025년 6월 20일
편집: Matt J 2025년 6월 20일
Hi everyone,
I’m running into a strange issue when I copy my MATLAB figure into PowerPoint and then ungroup the graphic objects. Although I explicitly set both the marker face and edge colors to red, after ungrouping in PowerPoint the marker edges always appear black. Before ungrouping in PowerPoint: markers are solid red circles (face and edge).This happens whether I use scatter or plot. Trying all of the different Copy Figure e options in the MATLAB figure window, none of these preserve the red edge color once ungrouped.
scatter(x, y, 50, 'MarkerFaceColor', 'r', 'MarkerEdgeColor', 'r');
xlabel('X');
ylabel('Y');
title('Scatter Plot with Red Markers');
or
plot(x, y, 'o', ...
'MarkerSize', 8, ...
'MarkerFaceColor', 'r', ...
'MarkerEdgeColor', 'r', ...
'LineStyle', 'none');
Thanks in advance for any tips!
  댓글 수: 1
Matt J
Matt J 2025년 6월 20일
Do you not see the following warning? It seems like a Microsoft thing, not a Matlab thing.

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

답변 (1개)

Matt J
Matt J 2025년 6월 20일
편집: Matt J 2025년 6월 20일
If you download export_fig,
and if you are on Windows, then you can copy an axes and its children as separate components to an open PowerPoint slide, like in the following.
x=rand(1,10); y=rand(1,10);
scatter(x, y, 50, 'MarkerFaceColor', 'r', 'MarkerEdgeColor', 'r');
xlabel('X');
ylabel('Y');
title('Scatter Plot with Red Markers');
copyComponents()
function copyComponents()
h=[gca;gca().Children];
axcol=h(1).Color;
axlims=axis;
h(1).Color='none';
for n=1:numel(h)
set(h,'Visible','off');
h(n).Visible='on';
axis(axlims);
drawnow
export_fig(gca,'-transparent','-clipboard','-nocrop')
% Attach to running PowerPoint session
ppt = actxGetRunningServer('PowerPoint.Application');
% Get the active presentation
presentation = ppt.ActivePresentation;
% Get the current view and current slide index
view = ppt.ActiveWindow.View;
currentSlideIndex = view.Slide.SlideIndex;
% Access the current slide object
slide = presentation.Slides.Item(currentSlideIndex);
% Select it
slide.Select;
% Paste from clipboard
ppt.CommandBars.ExecuteMso('Paste');
end
set(h,'Visible','on');
h(1).Color=axcol;
end

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by