In MATLAB, how to change the background color of a subtitle?

I am trying to change the background color of one subtitle in a MATLAB figure.

This is understandable because the user interface allows this, but I cannot find a function to automate it.

I looked at whitebg , but it changes the color scheme of the whole figure, not just the current subplot.

(By the way, I'm using MATLAB Version 6.1)

+7
background-color matlab plot
source share
3 answers

You can use the set command.

 set(subplot(2,2,1),'Color','Red') 

This will give you a red background at the subtitle 2.2.1.

+20
source share

I know that you mentioned that you use MATLAB 6.1, but it should be mentioned that in new versions of MATLAB you can specify additional arguments for a pair of property values ​​in the initial SUBPLOT call, which allows you to use a more compact syntax. The following creates axes with a red background in the upper left corner of the 2 by 2 layout:

 subplot(2,2,1,'Color','r'); 

I'm not sure which version of MATLAB this syntax was introduced in, since release notes returning to version 7 (R14) don't seem to mention this.

+4
source share

I have not used Matlab after a few years, but I think it could be the whitebg method called after the subplot declaration, similar to the way you set the header.

 subplot(3, 2, 4), hist(rand(50)), whitebg('y'); 
+2
source share

All Articles