How do I change my graph output from the standard Cartesian look to one that resembles a map?

2 次查看(过去 30 天)
I am plotting multiple data points of temperature for different depths of Mars' mantle layers. One graph should look like the following:
This was the graph given to me and I had to create code to replicate this kind of graph, but this is what I'm getting in terms of look.
How do I turn this above graph into the appropriate shape? The difficult part I keep running into is that I am not working with geographical data necessarily. If you see my files/code, I am just looping through lots of numbers to graph the right coordinate points, so utilizing the mapping toolbox hasn't been really compatible with my work/data. I could be using it wrong, but I am just trying to figure out how I can get the above graph to be blue to white to red in terms of coloring, with higher values/redder colors correlating with hotter temperatures and for the graph itself to be shaped into that map shape of the first figure. I need to understand this to complete my research analysis, so please any advice would be helpful! I have been stuck on this for too many days/weeks.
Also, how can I make the color bar range from 0 to 1 instead of just picking the smallest and highest values from my data?
Here is the plotting code snippet:
%% Plot the points for every file for the fixed depth
figure
dataPoints = horzcat(finalLong,finalLat,temp);
x = finalLong(:,1); % Plot longitude (phi & second column) on x-axis
y = finalLat(:,1); % Plot latitude (theta & first column) on y-axis
z = temp(:,1); %plot temperatures
hold on
pointsize = 10;
scatter(x, y, pointsize, z)
colorbar('southoutside');

回答(1 个)

R
R 2024-3-28
Hi Ritisha,
To change the colours in the plot, you can utilize 'colormap'. You can create a custom colormap programatically or by using the Colormap Editor by refering to the following documentation:
Additionally, to change the range of the colorbar, refer to the 'TickLabels' property of the colorbar:

类别

Help CenterFile Exchange 中查找有关 Colormaps 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by