Hi,
I would like to know if there is an easy way to align subplots ina figure. Here is my problem.
I have a figure with a subplot with a colorbar (on the right of the plot) and a subplot without a colorbar but with two y axis and relative labels bennith it. I would like the plot to be aligned (meaning the x values of the two subplot should be at the same horizontal location). The only way I found to achive that is to thinker with the 'Position' options of the subplot. Like:
subplot(4,2,6,'Position', [0.095 0.1 0.81 0.1428])
But thsi solution depends on the size of the figure itself and on the screen the figure is beign plotted to (at least that is my guess since I get different results dependig on the screen matlab is plotting it in and if I maximize the figure or not).
minimal working example of the problem:
C = [0 2 4 6; 8 10 12 14; 16 18 20 22];figuresubplot(2,1,1)imagesc(C)colorbarsubplot(2,1,2)hold onyyaxis leftplot(C(:)); ylabel('C')yyaxis rightplot(-C(:)); ylabel('-C')
Real case problem output
Any advice is appriciated!
Best Answer