Can I change default settings of plot

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?

 Respuesta aceptada

Stephen23
Stephen23 el 9 de Mayo de 2015
Editada: Stephen23 el 9 de Mayo de 2015
Welcome to MATLAB!
Setting the some default parameters can be achieved by following these steps:
  1. Look up the axes properties and locate the ones that are of interest to you.
  2. use set to define the settings that you want, according to these instructions.
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 comentarios

Elia D'Orazio
Elia D'Orazio el 8 de Mayo de 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
Christian Kampp Kruuse el 21 de Oct. de 2020
I don't remember exactly how but the there is a "run these files on startup thing" in matlab

Iniciar sesión para comentar.

Más respuestas (1)

Arvind Srivastav
Arvind Srivastav el 31 de Oct. de 2019

0 votos

Why does it show only verticle lines?

1 comentario

Steven Lord
Steven Lord el 31 de Oct. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Properties en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Mayo de 2015

Comentada:

el 21 de Oct. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by