Labels don't appear in 3d plot?

5 ビュー (過去 30 日間)
Jasmine Alvarez
Jasmine Alvarez 2018 年 3 月 1 日
コメント済み: Star Strider 2018 年 3 月 1 日
I may have posted this question twice, but I didn't see it appear in my profile. Therefore, I'm asking it again.
I applied labels to a 3D plot, but they do not appear. Matlab doesn't show any errors. I've tried removing the position and unit specifications in case it was just offset, but that did not solve it.
clc;clear;close;
RPM = 25;
R = .05;
h0 = .15;
%define constants and change units
omega = RPM*2*pi/60; %[rad/s]
g = 9.807; %[m/s^2]
r = linspace(0,R); %[m]
phi = linspace(0,2*pi); %[rad]
%PLOT
[r,phi] = meshgrid(r,phi);
[X,Y] = meshgrid(linspace(-R,R,2),linspace(-R,R,2));
t = linspace(0,2*pi);
%equation of surface
z = h0 - omega^2/(2*g)*(R^2/2 - r.^2); %[m]
%h0 (origin) plane
plane = h0*ones(2,2);
plane_1 = h0*ones([1,100]);
%radius at h0
R_h0 = R/sqrt(2);
%original figure
figure('Name','Graphical Display with Original Measurements',...
'Units','normalized','Position',[.005,.4,.4,.5]);
title('Original Surface Height and Surface with Rotation');
xlabel('Radius');
ylabel('Radius');
zlabel('Height');
surf(X,Y,plane,'FaceAlpha',0.5,'FaceColor',[1,.3,1]); hold on
plot3(R_h0*cos(t),R_h0*sin(t),plane_1,'Color','black'); hold on
surf(r.*cos(phi),r.*sin(phi),z,'LineStyle','none'); hold off
colorbar;

採用された回答

Star Strider
Star Strider 2018 年 3 月 1 日
The order you list the assignments and function calls in your code is important.
Try this:
%original figure
figure('Name','Graphical Display with Original Measurements',...
'Units','normalized','Position',[.005,.4,.4,.5]);
surf(X,Y,plane,'FaceAlpha',0.5,'FaceColor',[1,.3,1]); hold on
plot3(R_h0*cos(t),R_h0*sin(t),plane_1,'Color','black'); hold on
surf(r.*cos(phi),r.*sin(phi),z,'LineStyle','none'); hold off
colorbar;
title('Original Surface Height and Surface with Rotation');
xlabel('Radius');
ylabel('Radius');
zlabel('Height');
The title and axis labels magickally appear!
  2 件のコメント
Jasmine Alvarez
Jasmine Alvarez 2018 年 3 月 1 日
Thank you
Star Strider
Star Strider 2018 年 3 月 1 日
As always, my pleasure.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by