Matlab Subplot Legend For All

I have a 4 subplots in a 2x2 grid.
Matlab subplot legend for all. I would like to make one legend on a figure with multiple subplots and place it either at the top middle or align the legend just above one of my subplots. Learn more about subplot legend. The issue here is that each legend needs to be associated with an axis. I need to move the overall legend out of the last subplot.
I am trying to plot the first two subplots with the bluewhitered colormap to emphasize the positive versus negative values. When i run the full script for my figure i get jet coloring for all three. How do i set an overall legend for all 4 subplots. Learn more about subplot legend.
I need to move the overall legend out of the last subplot. But i want the third subplot temperature to use the jet colormap. They display similar data so i need only one legend for them. Thanks laura for the comment.
In order to do this you will need to create a global legend for the figure instead of creating a legend at the axes level which will create a separate legend for each subplot. The legend is the same for all the plots and i can not put the all plots in one subplot since it becomes very small. These subplots have exactly the same legend. But if i only run the first subplots i get the coloring i want.
When i try to add a legend to the last subplot it is always inside the 4th axis. When i try to add a legend to the last subplot it is always inside the 4th axis. Sometimes you will have a grid of subplots and you want to have a single legend that describes all the lines for each of the subplots as in the following image. You will have to play with the legend s position to achieve the desired look.
How do i set an overall legend for all 4 subplots. They display similar data so i need only one legend for them. These subplots have exactly the same legend. Insted of creating just 4 subplots we creat 6 subplots one more row and then merge the last row turn the axis off and put the legend there.
There is no built in way to create an overall legend. I have a 4 subplots in a 2 2 grid.