Scale MATLAB / Octave graph to print all labels

I am trying to create a simple heat map using MATLAB / Octave: Heatmap plot
As you can see, I have many lines, each of which represents a separate category.

I am using the imagesc function, and I would like to be able to scale the image / graph so that each of the Y axis labels can be printed correctly (instead of having the mess that can be seen in the image below).

Here is an example of the code I would like to modify:

 A = randi(100, 200, 3); imagesc(A, limit = [0, 100]); set(gca, 'xtick', [1:3]); set(gca, 'xticklabel', { "1,000", "2,000", "3,000" }); set(gca, 'ytick', [1:200]); 

Edit: I am attaching a solution to the proposed problem, achieved thanks to the advice of EitanT, as well as useful information at http://nibot-lab.livejournal.com/73290.html?nojs=1 :

 paperWidth = 16.5; paperHeight = 11.7; set(gcf, 'Position', get(0,'Screensize')); set(gcf, 'PaperUnits', 'inches'); set(gcf, 'PaperSize', [paperHeight paperWidth]); set(gcf, 'PaperPositionMode', 'manual'); set(gcf, 'PaperPosition', [0 0 paperWidth paperHeight]); set(gcf, 'renderer', 'painters'); figure(gcf); A = randi(100, 200, 3); imagesc(A, limit = [0, 100]); set(gca, 'FontSize', 5); set(gca, 'FontWeight', 'light'); set(gca, 'xtick', [1:3]); set(gca, 'xticklabel', { "1,000", "2,000", "3,000" }); set(gca, 'ytick', [1:200]); 
+6
source share
1 answer

There are several possible solutions:

Resize picture window

If the shape is not already maximized, you can do this using:

 set(gcf, 'Position', get(0, 'ScreenSize')) 

Instead of get(0, 'ScreenSize') you can, of course, specify any required sizes using a custom vector (as described here ).

Font size reduction

You can also reduce the text on the label by reducing the font size:

 set(gca, 'FontSize', 5) 

Note that this, however, affects all text in the current axes.

Decrease the number of ticks displayed

As a last resort, you can reduce the number of displayed ticks along the Y axis, i.e. increase tick interval. Instead of 1:200 try playing at other intervals, for example:

 set(gca, 'YTick', [1:20:200]) 

Try a combination of the solutions described above for better visualization.

You can learn more about axis control in the official documentation . In addition, as you suggested in one of the comments, this page contains many additional useful tricks for displaying graphs in MATLAB.

+6
source

All Articles