circle marker weird filling

조회 수: 6 (최근 30일)
Herline van der Spuy
Herline van der Spuy 2021년 10월 22일
댓글: Herline van der Spuy 2021년 10월 26일
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
Herline van der Spuy 2021년 10월 26일
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에서 Graphics Object Programming에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by