3次元プロットのカラ​ースケールプロットと​透明プロットを同時に​描画することができま​せん。

6 views (last 30 days)
Takahiro Sasaki
Takahiro Sasaki on 7 Feb 2023
Commented: Takahiro Sasaki on 8 Feb 2023
3Dプロットについて質問させてください。
h1) カラースケール付きの三次元プロット
h2) 透明の三次元プロット
を同時に描画したいのですが、下記のコードで透明化処理「h2.Color(4)=0.5;」を入れると、h1のカラー情報が消えてしまいます。
h1/h2の両立は可能でしょうか?
試しに「h2.Color(4)=0.5;」をコメントアウトするとh1のカラー情報は残ったまま描画されますが、当然h2のプロットが透明化されません。(図を参照)
ご助言いただけますと幸いです。
t = 0:pi/500:pi;
xt1 = sin(t).*cos(10*t);
yt1 = sin(t).*sin(10*t);
zt1 = cos(t);
xt2 = sin(t).*cos(12*t);
yt2 = sin(t).*sin(12*t);
zt2 = cos(t);
h1 = plot3(xt1,yt1,zt1);
n = length(t);
cd = [uint8(jet(n)*255) uint8(ones(n,1))].';
drawnow
set(h1.Edge, 'ColorBinding','interpolated', 'ColorData',cd);
hold on
h2 = plot3(xt2,yt2,zt2);
h2.Color(4)=0.5;
hold off

Accepted Answer

交感神経優位なあかべぇ
h1.EdgeのColorDataの4行目を255に変更してみたところ、上手くいきました。
t = 0:pi/500:pi;
xt1 = sin(t).*cos(10*t);
yt1 = sin(t).*sin(10*t);
zt1 = cos(t);
xt2 = sin(t).*cos(12*t);
yt2 = sin(t).*sin(12*t);
zt2 = cos(t);
h1 = plot3(xt1,yt1,zt1);
n = length(t);
cd = [uint8(jet(n)*255) repmat(0xFF,n,1)].'; % 4行目の値を255に変更
drawnow
set(h1.Edge, 'ColorBinding','interpolated', 'ColorData',cd);
hold on
h2 = plot3(xt2,yt2,zt2);
h2.Color(4)=0.5;
hold off
  1 Comment
Takahiro Sasaki
Takahiro Sasaki on 8 Feb 2023
ありがとうございました!
いただいた回答でこちらでも再現できました。

Sign in to comment.

More Answers (0)

Categories

Find more on グラフィックス パフォーマンス 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!