Plotting 3D surface contours of a variable with respect to x, y and z
3 次查看(过去 30 天)
显示 更早的评论
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
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.
回答(2 个)
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 个评论
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
2023-6-22
编辑:shravani banerjee
2023-6-22
1 个评论
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 Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!