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?

 채택된 답변

Stephen23
Stephen23 2015년 5월 9일
편집: Stephen23 2015년 5월 9일

4 개 추천

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

Elia D'Orazio
Elia D'Orazio 2020년 5월 8일
It works but after i close and then open again matlab the grid default property comes back to off. How to make it permanent?
I don't remember exactly how but the there is a "run these files on startup thing" in matlab

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Arvind Srivastav
Arvind Srivastav 2019년 10월 31일

0 개 추천

Why does it show only verticle lines?

댓글 수: 1

Steven Lord
Steven Lord 2019년 10월 31일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

태그

질문:

2015년 5월 9일

댓글:

2020년 10월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by