필터 지우기
필터 지우기

Plotting 3D surface contours of a variable with respect to x, y and z

조회 수: 3 (최근 30일)
shravani banerjee
shravani banerjee 2023년 6월 12일
편집: shravani banerjee 2023년 6월 22일
I am trying to plot a 3D surface contour plot a varaible (dust mixing ratio) with respect to lat (x-axis), long (y-axis) and levels (z axis) (attached csv file). But I am unable to plot that. While making the meshgrid I am getting an error Requested 248040x248040x2 (916.8GB) array exceeds maximum array size preference. How to plot this?
  댓글 수: 2
Rik
Rik 2023년 6월 12일
What code did you try? You can put it right in your question and run the code to show us exactly how to reproduce the error.
And what do you want exactly? A surface plot or a contour plot? Both rely on a single value for the height given an x-y coordinate pair. Your error suggests you have a list of coordinates that should be reshaped instead of using meshgrid.
shravani banerjee
shravani banerjee 2023년 6월 12일
I want a 3D contour plot with x as lat, y as lon, and z as levels and the legend colour will represent my variable. I tried to created a mesh to make a 3D contour plot.
T=readtable('MIXING_RATIOe.csv');
lat = T.lat;
lev = T.levels;
lon = T.lon;
values = T.dust_mixing_ratio;
y = lat;
m = lon;
z = lev;
[Y,M,Z] = meshgrid(y,m,z);

댓글을 달려면 로그인하십시오.

답변 (2개)

Rik
Rik 2023년 6월 12일
It sounds like you want a 3D pointcloud where the color represents a 4th variable.
As you can see below, this might not actually be a very informative plot.
t = tic;%keep track of time
unzip('MIXING_RATIOe.zip')
T=readtable('MIXING_RATIOe.csv');
lat = T.lat;
lev = T.levels;
lon = T.lon;
values = T.dust_mixing_ratio;
cmap = colormap('parula');
N_colors = size(cmap,1);
unique_values = unique(values);
C_ax = [min(values) , max(values)];
N = numel(unique_values);
%for n=1:N
for n=randperm(N) % this is to make sure stopping halfway doesn't distort the plotted colors
L = values == unique_values(n);
col_idx = interp1(...
linspace(C_ax(1),C_ax(2),N_colors),... % data range
1:N_colors,... % colormap indices available
unique_values(n)); % query current value
plot3(lat(L),lon(L),lev(L),...
'.','color',ind2rgb_private(col_idx,cmap))
if n==1,hold('on'),elseif n==N,hold('off'),end
% for the online environment, exit after 20 seconds of work
if toc(t)>20,break,end,hold('on')
end
colorbar,caxis(C_ax) % add colorbar and adjust limits to match the plotted results
function col = ind2rgb_private(col_idx,cmap)
% extend ind2rgb to allow decimal indices
N_colors = size(cmap,1);
col = [...
interp1(1:N_colors,cmap(:,1),col_idx),...
interp1(1:N_colors,cmap(:,2),col_idx),...
interp1(1:N_colors,cmap(:,3),col_idx)];
end
  댓글 수: 4
shravani banerjee
shravani banerjee 2023년 6월 12일
Here is an example of the plot I wanted to make.
Rik
Rik 2023년 6월 12일
I suspect you could get something like this if you set the Alpha property of a patch object below a certain threshold (and scale that with the value as well).
I don't know how fine your slices need to be before you don't notice them anymore. I suggest you give it a try. I'm not aware of any way to create this using solid voxels in Matlab.

댓글을 달려면 로그인하십시오.


shravani banerjee
shravani banerjee 2023년 6월 22일
편집: shravani banerjee 2023년 6월 22일
I got the required plot. It can be plotted through pcolor3. https://in.mathworks.com/matlabcentral/fileexchange/49985-pcolor3
  댓글 수: 1
Rik
Rik 2023년 6월 22일
Can you provide a link? I can't find it on Google, so I doubt it will be easy to find for future readers of this thread.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by