- https://www.mathworks.com/help/matlab/ref/colormap.html#:~:text=map%20%E2%80%94%20Colormap%20for%20new%20color%20scheme
- https://www.mathworks.com/help/matlab/ref/colormapeditor.html
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');
댓글 수: 0
답변 (1개)
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:
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!