Plot matrix containing negatives in confusionchart() style
16 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Shubham
2023-7-26
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!