4/1/2024 0 Comments Matlab colors![]() I've not mastered posting graphics to SO, so trust me, this will lead you towards a solution. But it would be a lot easier, if you don't have the code, to use MS Excel.ĮDIT: So I gave this some more thought and here's what I came up with. I expect you could persuade Matlab to draw that, if you look at the File Exchange you may find someone has already written the code. Older versions of MATLAB: For older versions you can find some submissions on the MathWorks File Exchange that can rotate the tick label text, like XTICKLABEL_ROTATE from Brian Katz. Set(hStrings, TickLabelRotation', which allow you to rotate the labels and fit them better. TextColors = repmat(mat(:) > midValue, 1, 3) % Choose white or black for the MidValue = mean(get(gca, 'CLim')) % Get the middle value of the color range = meshgrid(1:5) % Create x and y coordinates for the strings TextStrings = strtrim(cellstr(textStrings)) % Remove any space padding TextStrings = num2str(mat(:), '%0.2f') % Create strings from the matrix values Imagesc(mat) % Create a colored plot of the matrix valuesĬolormap(flipud(gray)) % Change the colormap to gray (so higher values are Here's an example: mat = rand(5) % A 5-by-5 matrix of random values from 0 to 1 ![]() You can create this sort of plot yourself pretty easily using the built-in functions imagesc and text and adjusting a number of parameters for the graphics objects. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |