フィルターのクリア

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 Center および File ExchangeLighting, 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