Friday, September 27, 2013

Fake colorbar

Often I want to plot two (or many) datasets that have the same time vector. I simply use the SUBPLOT command in MATLAB to do so. A problem arises, however, when one of these datasets happens to be three-dimensional — something that I want to plot with pcolor. When I add a colorbar to that subplot, the time-axis (x-axis) no longer lines up with the other subplots.

BAD: The time-axes for (a) and (b) have different scales because of the colorbar in (b).

To fix this problem, I wrote a simple function called FAKECOLORBAR which changes the size of the subplot that does not require a colorbar so it matches the subplot with the colorbar.

GOOD: The time-axes for (a) and (b) now align because I used FAKECOLORBAR on (a)

Now, if someone could just tell me how to fix the phi in the title of (b) so that it is not partially cutoff...

Oh, and these data will in a jagged and blocky way unless I subtract 2000 years from the time vector, which is why the x-axis label in (b) says "January 7" instead of "January 2007." I'm sure others have run into this problem before. Another problem for another day.

1 comment:

  1. Nice function!

    Can you fix the cut off Phi by using something like '... \Phi{ }_T [K^2]' where there're some curly braces with a space in the middle, before the subscript T? I can't seem to replicate the problem in Matlab 2012a or 2013b, either exporting or saving as *.eps.