The legend overlay is displayed when drawing

조회 수: 6 (최근 30일)
龙 张
龙 张 2024년 8월 29일
편집: dpb 2024년 9월 2일
  댓글 수: 14
龙 张
龙 张 2024년 9월 2일
clear all;
N = 50;
x = sort(rand(1,N));
y = rand(1,N);
z = rand(1,N);
x_interp = linspace(0,1,N);
y_interp = interp1(x, y, x_interp);
z_interp = interp1(x, z, x_interp);
z_real = z_interp + randn(1,N);
figure
h1 = plot3(x, y, z, 'o', 'MarkerSize', 6, 'MarkerFaceColor', 'r');
hold on;
plot3(x_interp, y_interp, z_interp, 'b-', 'LineWidth', 2);
plot3(x_interp, y_interp, z_real, 'g-', 'LineWidth', 2);
grid on;
set(gca, 'YDir', 'reverse');
xlabel('X');ylabel('Y');zlabel('Z');
title('隧道反演结果三维示意图');
p1 = patch(x, y, z, 'FaceColor', 'blue');
legend([h1, p1], {'反演结果', '填充'});
xlim([0 200]);
ylim([0 200]);
zlim([-25 0]);
hold off;
I tested the code on the webpage and there were no errors;
But on my local computer, I reinstalled Matlab and run the code, it still encountered errors. In the figure, there seems to be a shadow covering the top.
dpb
dpb 2024년 9월 2일
편집: dpb 2024년 9월 2일
OK, that's interesting and informative. This leads to confriming the fact something is unique/different on the particular machine; now it's down to specifics that may matter. Which OS, release, is it updated? Same with MATLAB although with a reinstall if you downloaded afresh it should include updates but you didn't say which release with the question posting(*).
These kinds of graphical display issues often get into the specifics of the display hardware/chipset and drivers and the MATLAB renderer. Updating your graphics drivers from the chipset/card vendor can sometimes fix things.
However, first work through the suggestions at <resolving low level graphics issues> and you may be able to resolve it yourself. If switching to a software OpenGL renderer makes the issue go away, then it is pretty clearly something in the hardware/drivers.
(*) There's an alternative thing one could try albeit time-consuming; download a prior release and see if the symptom stays/goes away...one can have multiple releases of MATLAB installed at the same time so don't have to remove your current install; you just need patience and enough bandwidth it's not too much of a chore.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by