How do I get single-stroke MarkerEdges?

4 views (last 30 days)
Maaike van Boven
Maaike van Boven on 23 Mar 2021
Answered: Alexandre Plourde on 15 Oct 2021
Since updating to 2020b, I have the following problem: when I export a plot to a graphics program, the marker edge is a 'compound path' (a filled area between two paths' instead of a single path/stroke.
This applies both to markers generated with scatter() and with plot(). I've tried different ways of exporting the plot, which had no effect, and now I'm wondering whether this is due to irrational behaviour by the graphics program, or might perhaps be caused by some of my own settings.
Is anyone familiar with this problem, and/or has any ideas on how to fix it?
%generate some data
data1=randn(12,1);
data2=randn(12,1);
figure;
s1=scatter(ones(size(data1,1),1),data1,45,[1 0 0]); %scatterplot data1 in red (at x=1.0)
hold on
p1=plot(1.1*ones(size(data2,1),1),data2,'og'); %plot marker data2 in green (at x=1.1)
ax1=gca;
ax1.XLim=[0.95 1.15]
%try different ways of exporting
copygraphics(ax1,'ContentType','vector');
print('-painters','-dpdf','Test_Print_painters');
exportgraphics(gca, 'Test_export.pdf');

Answers (1)

Alexandre Plourde
Alexandre Plourde on 15 Oct 2021
This has annoyed me too. Here are two options I know of:
1) Use the Convert to Shape - Ellipse tool in illustrator. This will let you set the stroke weight and color as if it was a simple circle. However, illustrator will still track the 8 vertices per marker (instead of 4), which could be annoying if you have a lot of markers.
2) Export the markers as 'filled' circles from Matlab, then you can easily add a stroke in Illustrator. Note that this tended to cause issues in pre-2020 Matlab, but works well now.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!