- Look up the axes properties and locate the ones that are of interest to you.
- use set to define the settings that you want, according to these instructions.
Can I change default settings of plot
82 views (last 30 days)
Show older comments
Ehsan Haq
on 9 May 2015
Commented: Christian Kampp Kruuse
on 21 Oct 2020
I am new to MATLAB. When I use plot command, it displays the graph but by default grid is OFF. I have to use grid on command, each & every time I use the plot command. Is there a way that will turn grid on with the plot command?
0 Comments
Accepted Answer
Stephen23
on 9 May 2015
Edited: Stephen23
on 9 May 2015
Welcome to MATLAB!
Setting the some default parameters can be achieved by following these steps:
So, just to get you started, here is what I just tried after a fresh restart:
>> set(0,'DefaultAxesXGrid','on')
>> plot([0,1,2],[2,3,2])
which produced this:
Note that recent versions use groot (from 2014?), older versions simply used 0 to indicate the graphics root.
If you want these setting to be the default every time you start MATLAB< then you can put theses commands in a startup Mfile.
2 Comments
Elia D'Orazio
on 8 May 2020
It works but after i close and then open again matlab the grid default property comes back to off. How to make it permanent?
Christian Kampp Kruuse
on 21 Oct 2020
I don't remember exactly how but the there is a "run these files on startup thing" in matlab
More Answers (1)
Arvind Srivastav
on 31 Oct 2019
Why does it show only verticle lines?
1 Comment
Steven Lord
on 31 Oct 2019
Because Stephen only changed the default value for the axes object's XGrid property.
Setting DefaultAxesXGrid changes the
Default value of
(future) Axes objects'
XGrid property
There are corresponding YGrid and ZGrid properties.
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!