Plot matrix containing negatives in confusionchart() style
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Christopher McCausland
le 26 Juil 2023
Modifié(e) : Christopher McCausland
le 4 Août 2023
Hello,
I have a matrix of numbers which includes negitives. I would like to plot this in the same graphical style as confusionchart() so all figures look consistent. I have had a look inside the function with open confusionchart() however I do not beleive the specific code is visable.
Is there an easy way to replicate this? If not I can code it manually, however I don't want to spend lots of time on this if there is a pre-existing solotion.
Kind regards,
Christopher
0 commentaires
Réponse acceptée
Shubham
le 26 Juil 2023
Hi Christopher,
If you want to plot a matrix of numbers with negative values in the same graphical style as `confusionchart()`, you can use the `imagesc()` function in MATLAB. `imagesc()` is commonly used to visualize matrices as images, with a color scale representing the values.
Here's an example of how you can use `imagesc()` to plot a matrix with negative values:
% Example matrix with negative values
matrix = [1 2 3; -1 -2 -3; 4 5 6];
% Plot the matrix using imagesc()
figure;
imagesc(matrix);
% Set the color map to match confusionchart()
colormap(parula); % You can choose a different colormap if desired
% Add colorbar for reference
colorbar;
In this example, `imagesc()` is used to plot the `matrix` with negative values. The `colormap()` function is then used to set the color map to match the style of `confusionchart()`. You can choose a different colormap if you prefer.
By using `imagesc()` and setting the appropriate colormap, you can achieve a consistent graphical style similar to `confusionchart()` for plotting matrices with negative values.
You can refer to these documentation for more info:
4 commentaires
Christopher McCausland
le 4 Août 2023
Modifié(e) : Christopher McCausland
le 4 Août 2023
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Orange dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!