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

后端 未结 2 1258
走了就别回头了
走了就别回头了 2020-12-31 10:34

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

相关标签:
2条回答
  • 2020-12-31 11:04

    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.

    0 讨论(0)
  • 2020-12-31 11:15

    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.

    0 讨论(0)
提交回复
热议问题