circle marker weird filling

17 views (last 30 days)
The circle marker is doing something weird. How can I fix this? Is it the edge thing or the order or what? How do I 'smooth' the edges? Is it because it is filled? It doesn't do it when it's not 'filled'? C2 is an RGB colour code.
plot(time,strain,'-o','Color',C2,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C2,'MarkerFaceColor',C2);
  3 Comments
Walter Roberson
Walter Roberson on 25 Oct 2021
When I try with my own system, or with MATLAB Online, the plot looks fine no matter how much I zoom. However, when I run it here with the MATLAB Answers facility, it does indeed look bad.
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/777428/21seconds_time_strain.xlsx';
T = readtable(filename, 'VariableNamingRule', 'preserve');
B22 = [T.Time, T.Strain];
figure
% Temperature 22°C
% B22 is the data with time in first column and strain in second colomn.
time = B22(:,1);
strain = B22(:,2);
lw = 3;
ms = 7;
sz = 22;
C2 = [0.267 0.447 0.768];
plot(time,strain,'-o','Color',C2,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C2,'MarkerFaceColor',C2);
ax = gca;
set(gca,'fontsize',sz);
grid on
xlim([0 15]);
ylabel('Strain (%)','FontSize',sz);
xlabel('Time (s)','FontSize',sz);
Herline van der Spuy
Herline van der Spuy on 26 Oct 2021
Luckily, the figure is scale down a bit. And you can't see the difference on the pdf. So that's okay. But thank you for the help.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 22 Oct 2021
Linewidth problems. The circle is drawn as a series of straight segments and when the Linewidth is not 1 the ends of the lines extend out in a way that leaves the shape non-circular. The line segments are constant width, not feathered taking into account the line width.
  3 Comments
Walter Roberson
Walter Roberson on 22 Oct 2021
Edited: Walter Roberson on 22 Oct 2021
I don't seem to be replicating the problem in my tests. Could you attach data to test with, including the values of lw and ms ?
Also, what shows up for
opengl info
Kelly Kearney
Kelly Kearney on 22 Oct 2021
You can play around with layering separate line and marker objects to get a more aesthetically pleasing look:
lw = 5;
mksz = 8;
subplot(3,1,1);
plot(1:10, 1:10, '-bo', 'markersize', mksz, 'linewidth', lw, 'markeredgecolor', 'b', 'markerfacecolor', 'r');
% If you want a linewidth around the markers comparable to the line, layer
% edgeless markers of different sizes
subplot(3,1,2);
plot(1:10, 1:10, '-bo', 'markersize', mksz+lw, 'linewidth', lw, 'markeredgecolor', 'none', 'markerfacecolor', 'b');
hold on;
plot(1:10, 1:10, 'o', 'markersize', mksz-lw/2, 'markeredgecolor', 'none', 'markerfacecolor', 'r');
% If you're okay with a thinner marker outline, you can use markers with a
% different line width
subplot(3,1,3);
plot(1:10, 1:10, '-b', 'linewidth', lw);
hold on;
plot(1:10, 1:10, 'o', 'markersize', mksz, 'linewidth', 1, 'markeredgecolor', 'b', 'markerfacecolor', 'r');
(Note: the auto-generated Answers image is pretty low-res... it looks better when run in actual Matlab)

Sign in to comment.

More Answers (1)

Image Analyst
Image Analyst on 22 Oct 2021
Try a dot
plot(time,strain,'b.-','Color',C2,'LineWidth',lw,'MarkerSize',ms,'MarkerEdgeColor',C2,'MarkerFaceColor',C2);

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!