- 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 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
ag
el 25 de Sept. de 2024
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 comentarios
Ver también
Categorías
Más información sobre Colormaps en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!