how to flip axes of isosurface plot?

2 ビュー (過去 30 日間)
Janee
Janee 2024 年 10 月 12 日
編集済み: Walter Roberson 2024 年 10 月 15 日
I have a 3D set of data that I am using isosurface plotting to visulaize. The issue if I am trying to visualize my plot from a different angle of view. By flipping the x and z axes without having to really rechange my indexing or change use of meshgrid. Is there a way to fix this just visually?
The code:
clearvars; clc; close all;
% Set path to where data are saved
filelocation1 = 'C:\Users\Data';
filelocation1 = '';
% Load x and y grids
Nx = 32;
Ny = 32;
Nz = 32;
neIC = reshape(dlmread([filelocation1,'ICs.txt']),Nz+1,Nx,Ny);
%meshes are produced using: [X,Z,Y] = meshgrid(x,z,y);
XX = reshape(dlmread([filelocation1,'X.txt']),Nz+1,Nx,Ny);
YY = reshape(dlmread([filelocation1,'Y.txt']),Nz+1,Nx,Ny);
ZZ = reshape(dlmread([filelocation1,'Z.txt']),Nz+1,Nx,Ny);
figure
isosurface(XX,ZZ,YY,neIC);
grid on;
xlabel('x'); ylabel('z'); zlabel('y');
colorbar;
The image the is produced looks like:
How can I flip the y and z axes? Thanks!
  3 件のコメント
Walter Roberson
Walter Roberson 2024 年 10 月 12 日
You did not attach X.txt Y.txt or Z.txt so we are unable to test your code.
Janee
Janee 2024 年 10 月 14 日
@Walter Roberson I just attached X, Y, and Z text files with the ICs file as well. I am not sure if I need to "run" the code for the attached files to be avilable for you. Thanks.

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

回答 (1 件)

Star Strider
Star Strider 2024 年 10 月 12 日
Missing files, so I cannot run this.
One optiion would be to permute the order of the first three arguments to isosurface.
clearvars; clc; close all;
% Set path to where data are saved
filelocation1 = 'C:\Users\Data';
filelocation1 = '';
% Load x and y grids
Nx = 32;
Ny = 32;
Nz = 32;
neIC = reshape(dlmread([filelocation1,'ICs.txt']),Nz+1,Nx,Ny);
%meshes are produced using: [X,Z,Y] = meshgrid(x,z,y);
XX = reshape(dlmread([filelocation1,'X.txt']),Nz+1,Nx,Ny);
Error using dlmread (line 19)
The file 'X.txt' could not be opened because: No such file or directory
YY = reshape(dlmread([filelocation1,'Y.txt']),Nz+1,Nx,Ny);
ZZ = reshape(dlmread([filelocation1,'Z.txt']),Nz+1,Nx,Ny);
figure
isosurface(XX,ZZ,YY,neIC);
grid on;
xlabel('x'); ylabel('z'); zlabel('y');
colorbar;
.
  2 件のコメント
Janee
Janee 2024 年 10 月 14 日
I attached the text files again and hopefully that helps. I am not sure what do you mean by " to permute the order of the first three arguments to isosurface." ? Thanks
Star Strider
Star Strider 2024 年 10 月 15 日
I was referring to changing their order in the isosurface call. That works witth other types of plots.
Anyway, it turns out that doesn’t work with isosurface plots because the first three arguments (at least in this instance) are 3D matrices, and just changing their order throws an error because in that orientation, they are not consistent with ndgrid format (even though the isosurface documentation specifies that they must be in meshgrid format, and the outputs of those two functions — ndgrid and meshgrid — are definitely not the same). Since they are 3D matrices, simple tweaks such as transposing them will not work. All of those matrices would themselves probably have to be permuted (the permute function), and that would likely require a long period of experimentation, since I am not certain what isosurface needs those matrices to be in order for it to work. It does not appear to be obvious from the documentation.
My other experiment was with the rotate function, however the doesn’t work with isosurface plots because the output is not an object handle.
I have no idea where to go with this.

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

Community Treasure Hunt

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

Start Hunting!

Translated by