how to plot colored cube 3d contour graph?

25 ビュー (過去 30 日間)
Devin
Devin 2017 年 3 月 22 日
回答済み: Joseph Straccia 2021 年 4 月 7 日
Hi everyone, can anyone help me plot such colored cube graph? I have some experimental data which are 4 dimensional (x,y,z,f). Similarly to the example, I wish the color depends on the f, which is the 4th dimension.
Really! Thanks you very much!
  3 件のコメント
Peihong Yu
Peihong Yu 2018 年 5 月 18 日
Hi, did you figure out how to plot this kind of graph? I meet the same problem and I'm wondering can you share the solution? It's really appreciated!
KSSV
KSSV 2018 年 5 月 18 日
It depends on how the data is....how is your data?

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

回答 (2 件)

Aditya Adhikary
Aditya Adhikary 2018 年 5 月 18 日
For an explanation of the following code, look at Multifaceted Patches. The individual colors you put have to map to the volume function in some manner (not done here). Hope it helps.
vert = [0 0 0;1 0 0;1 1 0;0 1 0;0 0 1;1 0 1;1 1 1;0 1 1];
vert = 2*pi*vert;
fac = [1 2 6 5;2 3 7 6;3 4 8 7;4 1 5 8;1 2 3 4;5 6 7 8];
C = rand(8,3);
% C = hsv(8);
patch('Vertices',vert,'Faces',fac,'FaceVertexCData',C,'FaceColor','interp')
view(3)
axis vis3d
colorbar
  1 件のコメント
Asawira Emaan Khan
Asawira Emaan Khan 2020 年 5 月 20 日
@aditya Adhikary can you please help me with plotting cube with certain length, width and height?

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


Joseph Straccia
Joseph Straccia 2021 年 4 月 7 日
I had the same question. I found that by using the slice function twice and setting the slices at the minimum and maximum extents of my domain in x, y, z that I was able to generate a 3D color contour figure like that.
figure
hold on
slice(data.X,data.Y,data.Z,data.U,min(min(min(data.X))),min(min(min(data.Y))),min(min(min(data.Z))))
slice(data.X,data.Y,data.Z,data.U,max(max(max(data.X))),max(max(max(data.Y))),max(max(max(data.Z))))
view(3);
grid on;
colormap(jet(64));
colorbar('vertical');
shading interp;
hold off
axis equal

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by