- Scatter - https://www.mathworks.com/help/matlab/ref/scatter.html
- Colormap - https://www.mathworks.com/help/matlab/ref/colormap.html
- Colorbar - https://www.mathworks.com/help/matlab/ref/colorbar.html
Creating proper colour graph
1 回表示 (過去 30 日間)
古いコメントを表示
Hi, I have the following data: set of X coordinates, Y coordinates and the percentage value that each set of coordinate represents. What I want to do is plot each percentage with different colour based on its value (high percentage red, low percentage blue). I'm unfamilar with mesh and many graphical options on matlab.
Thank you,
0 件のコメント
回答 (1 件)
ag
2024 年 9 月 25 日
Hi Kartavya,
To visualize data with color coding based on percentage values, you can use a scatter plot where the color of each point represents its percentage value. MATLAB's scatter function allows you to specify the color of each point using a colormap.
The below code snippet demonstrates how to achieve that, using dummy data:
numPoints = 100;
X = rand(numPoints, 1) * 100;
Y = rand(numPoints, 1) * 100;
percentages = rand(numPoints, 1) * 100;
figure;
scatter(X, Y, 100, percentages, 'filled');
% Set the colormap to 'jet' for a range from blue (low) to red (high)
colormap(jet);
% Add a colorbar to show the mapping of colors to percentage values
colorbar;
xlabel('X Coordinate');
ylabel('Y Coordinate');
title('Scatter Plot with Color-Coded Percentages');
xlim([0, 100]);
ylim([0, 100]);
grid on;
For more details, please refer to the following MathWorks documentations
Hope this helps!
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!