How can I create a clear 2D plot that shows the distribution of values across a full latitude and longitude range with color shading?

50 visualizaciones (últimos 30 días)
I'm trying to analyze spatial data patterns across geographic coordinates by creating a 2D color plot in MATLAB. My data includes latitude and longitude values (tplatitude and tplongitude) as well as associated data values (NO_ver) that I want to display with color to represent varying intensities. The plot should span the entire range from -90° to +90° in latitude and -180° to +180° in longitude.
The main goal is to create a visualization that clearly shows where values are higher or lower across this grid, and I’d like advice on:
Choosing an effective color scheme to represent the data range. Setting up axes and labels for clarity. Using MATLAB functions to optimize the display for clear interpretation of intensity variations. I'm open to any tips on enhancing the plot’s readability and ensuring the data patterns are easy to analyze.

Respuestas (1)

Arjun
Arjun el 8 de Nov. de 2024 a las 9:14
Hi @Shri,
I see that you have some spatial data and you want help in creating a 2D color plot with color shading to show intensity.
Since you have latitude, longitude and data values, the goal is to map these onto a grid that spans the entire globe, from -90° to +90° in latitude and -180° to +180° in longitude. Using MATLAB's “meshgrid” function, you create a grid of these coordinates. Then, employ “griddata” to interpolate your data values onto this grid, allowing you to fill gaps between data points and create a continuous surface for visualization. For plotting, “pcolor” or “imagesc” can be used to generate a 2D color plot, where color intensity represents the magnitude of your data values.
You can enhance the plot's readability by choosing a suitable colormap, such as “parula” or viridis, which are perceptually uniform and better for interpreting data. Add axis labels, a title, and a colorbar to convey the data's context and scale effectively. Overlaying the original data points can further clarify where measurements were taken, helping to ensure the visualization is both informative and easy to interpret.
Kindly refer to the code below for better understanding:
% Random latitudes from -90 to 90
tplatitude = rand(100, 1) * 180 - 90;
% Random longitudes from -180 to 180
tplongitude = rand(100, 1) * 360 - 180;
NO_ver = rand(100, 1) * 100;
% Create a grid for the entire globe
latGrid = linspace(-90, 90, 180);
lonGrid = linspace(-180, 180, 360);
[Lon, Lat] = meshgrid(lonGrid, latGrid);
% Interpolate data onto the grid
NO_grid = griddata(tplongitude, tplatitude, NO_ver, Lon, Lat, 'linear');
% Plot the data
figure;
pcolor(Lon, Lat, NO_grid);
% Smooth out the color transitions
shading interp;
% Choose a color scheme; 'jet' is common for intensity or use 'parula'
colormap('jet');
% Add a colorbar to indicate data values
colorbar;
clim([min(NO_ver), max(NO_ver)]); % Set color axis limits
% Enhance plot readability
xlabel('Longitude');
ylabel('Latitude');
title('Spatial Data Patterns of NO\_ver');
axis tight;
set(gca, 'FontSize', 12, 'LineWidth', 1.5);
% Plot original data points
hold on;
plot(tplongitude, tplatitude, 'k.', 'MarkerSize', 5);
hold off;
Kindly refer to the documentation of following functions to understand better:
I hope this will help!

Community Treasure Hunt

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

Start Hunting!

Translated by