how to flip axes of isosurface plot?
3 views (last 30 days)
Show older comments
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 Comments
Walter Roberson
on 12 Oct 2024
You did not attach X.txt Y.txt or Z.txt so we are unable to test your code.
Answers (1)
Star Strider
on 12 Oct 2024
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);
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 Comments
Star Strider
on 15 Oct 2024
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.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!