circle marker weird filling

10 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2021-10-25
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
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.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2021-10-22
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 个评论
Walter Roberson
Walter Roberson 2021-10-22
编辑:Walter Roberson 2021-10-22
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 2021-10-22
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)

请先登录,再进行评论。

更多回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by