Setting the background color of a plot in MATLAB using the command line?

I am doing an assignment for my programming class, and I need to create a plot, along with a line of best fit for a few data points using only the command line in MATLAB. I know how to set the background using the figure editor, but I cannot for the life of me figure out how to do it via the command line. I need to set it to yellow. How would I do this? I think I am just missing something simple.

Answers


The solution to your specifiec question, is given by @M.Huster. I will just show you how you can help yourself in these cases.

Just make your plot and apply any manual changes you'd like. Then, in the figure window choose the option "Generate Code" in the File menu. This will generate an m-file that takes a dataset and recreates the figure for that dataset. If you look at that code (which is generally quite readable), you will see what commands are responsible for a certain effect.

As @M.Huster said, you can use get to get the properties, a more graphic way is using inspect(gca) and even better is the uiinspect command written by Yair Altman.


To change the background color of the axis:

 set(gca, 'color', [1 1 0])

To change the background color of the figure:

 set(gcf, 'color', [1 1 0])

In general, if you want to know the properties of a plot, try

get(gca) % for axis properties  
get(gcf) % for figure properties

This will return a list of available property names and property values.


Need Your Help

Use different Python version with virtualenv

python virtualenv virtualenvwrapper

I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtualenv with a different vers...

Vertically center content of floating div

css css-float css-position vertical-alignment

How do I verically center the content of floating div (which height I don't know)?