The legend overlay is displayed when drawing

6 views (last 30 days)
龙 张
龙 张 on 29 Aug 2024
Edited: dpb on 2 Sep 2024
  14 Comments
龙 张
龙 张 on 2 Sep 2024
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 on 2 Sep 2024
Edited: dpb on 2 Sep 2024
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.

Sign in to comment.

Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!