# How to plot 2D density plot with very large files?

8 vues (au cours des 30 derniers jours)
Vikash Raj le 19 Fév 2023
Hi
I want to plot 2D density plots with a colourbar for very large files. I want my x ais to be longitude, y axis to be latitude and the z axis as absolute VTEC as colour bar. I was trying to run the codes given below but I getting a error. as
"Error using repmat
Requested 373471x373471 (1039.2GB) array exceeds maximum array size preference (15.9GB). This might cause MATLAB to become unresponsive.
Error in meshgrid (line 61)
xx = repmat(xrow,size(ycol));"
Any suggestions on how can I fix this so that I can obtain my dentsity contour plots ?
Im attaching my part of data. Is it possible for the graph to have blue colour as background colour as shown with the figure attached.
whos
Name Size Bytes Class Attributes Absolute_VTEC 194004x1 1552032 double Latitude 194004x1 1552032 double Longitude 194004x1 1552032 double ans 1x35 70 char cmdout 1x33 66 char
xi =Longitude;
yi = Latitude;
[numel(xi), numel(uniquetol(xi))]
ans = 1×2
194004 111053
[numel(yi), numel(uniquetol(yi))]
ans = 1×2
194004 111143
[X,Y] = meshgrid(xi,yi);
Error using repmat
Requested 194004x194004 (280.4GB) array exceeds maximum array size preference (30.9GB). This might cause MATLAB to become unresponsive.

Error in meshgrid (line 61)
xx = repmat(xrow,size(ycol));
Z = Absolute_VTEC;
pcolor(X,Y,Z)
colorbar
colormap(jet)
##### 2 commentairesAfficher AucuneMasquer Aucune
Walter Roberson le 19 Fév 2023
Do you possibly have scattered data instead of a grid of data?
dpb le 19 Fév 2023
373471.^2*8/1024.^2
ans = 1.0642e+06
MB -- you don't have enough memory; decimate X,Y until you can hold the resulting array in memory. With only roughly 10,000 pixels on a monitor in each direction, you can't discriminate more than that many discrete locations, anyway.

Connectez-vous pour commenter.

### Réponse acceptée

Walter Roberson le 19 Fév 2023
Modifié(e) : Walter Roberson le 19 Fév 2023
You do not have a grid of lat and long: you have scattered data. You can see from the ratio of the number of unique elements to the number of stored elements that it does not happen to be a grid of data that has been reshaped into a row.
A density plot reflects how dense points are, and takes as input vectors of x and vectors of y -- no third value. You cannot do a density plot of scattered data when you have three variables. You can do things like take means.
scatter(Longitude, Latitude, 1, Absolute_VTEC)
N = 100;
[latbins, latedges] = discretize(Latitude, N);
[lonbins, lonedges] = discretize(Longitude, N+1);
denmat = accumarray([latbins(:), lonbins(:)], Absolute_VTEC(mask), [], @mean, NaN);
latmid = (latedges(1:end-1) + latedges(2:end))/2;
lonmid = (lonedges(1:end-1) + lonedges(2:end))/2;
h = pcolor(lonmid, latmid, denmat);
h.EdgeColor = 'none';
colorbar()
##### 2 commentairesAfficher AucuneMasquer Aucune
Vikash Raj le 20 Fév 2023
Modifié(e) : Vikash Raj le 20 Fév 2023
Hi, Thank you the graph looks ok to me.
I just wish to know, doses this scatter plots represents the mean values of absolute_VTEC on the z axis.
Since we are using scatter plots how may I represents my data using geoscatter plots. ?
Walter Roberson le 20 Fév 2023
Yes. The code divides the range of lat and long values into intervals; the intervals applied in two different directions form a rectangular grid. The code figures out where on the grid that each value belongs, and for each grid point takes the mean of the vtec values that fall into that grid point. With this particular coding the grid locations with no elements are assigned nan, but that is easy to change.

Connectez-vous pour commenter.

### Plus de réponses (1)

Vikash Raj le 20 Fév 2023
Thank you. I did and it is working.
How can Specificaly show the VETC along specicfic longitudinaly as shown above. Can the scatter plot that we have used be used to obtain simillar to above graph. I was trying the geoscatter but couldnt get the graph.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Geographic Plots dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by