How can I draw horizontal X(0,0) single grid line?

조회 수: 3 (최근 30일)
Khondokar Fida Hasan
Khondokar Fida Hasan 2017년 11월 1일
댓글: Khondokar Fida Hasan 2017년 11월 1일
Just wondering, I need to show the central X(0,0) line visible (and not other grids) in my plot where there have positive and negative values with Y axis? I tried this to draw the line,
line([0 84436], [0 0]);
But, it comes in the legend lists (which obviously should not be) and it does not give black or grid colour.
Any suggestion is much appreciating.

채택된 답변

John D'Errico
John D'Errico 2017년 11월 1일
편집: John D'Errico 2017년 11월 1일
This will draw a reference line, with a slope and intercept of 0.
refline(0,0)
However, I do see that it does show up if I use legend, with no arguments. So this shows the refline in the legend:
plot(randn(1,10),randn(1,10),'o')
refline(0,0)
legend
Instead, I can call legend with my own descriptions. So if there are 3 curves, just call legend with 3 names.
plot(randn(10,3),randn(10,3),'o')
refline(0,0)
n = 3;
legtit = cell(1,n);
for i = 1:n
legtit{i} = ['Data ',num2str(i)];
end
legend(legtit(:))
As you can see, no refline in the legend.
  댓글 수: 1
Khondokar Fida Hasan
Khondokar Fida Hasan 2017년 11월 1일
In my case if I declare refline(0,0) before plot, it just work fine. No legend for it. But after the plot, it comes as a legend.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by