Right and top axes disappear when I hold on a figure
이전 댓글 표시
Hello,
My question seems so stupid that I feel obliged to say I have already looked for an answer on Mathworks. When I use hold on with a figure, the right and top axes of the figure disappear. I would like to get all four axes so that my figure has a real frame. Any idea on how I can do that?
Thank you very much,
댓글 수: 8
dpb
2013년 8월 8일
Something besides hold is causing the issue; hold by itself only toggles the state of whether subsequent "stuff" is added to or replaces earlier "stuff" on the axes.
Pare an example down to the minimum it takes w/ a set of random data to illustrate the problem...something like
figure
plot(rand(10,1))
hold on
plot(sqrt([1:10])-0.5)
Then, add what it is from there that you're doing in your case to cause your symptoms and if that doesn't give you the answer of what not to do or how to fix the problem, post that series of commands.
Sandip
2013년 8월 8일
did you try "box on" after the axes disappear! You may try Box On at the end of all plots.
dpb
2013년 8월 8일
Or conversely remove any box off :)
I was trying to get OP to find where he turned it off in his code...
Pl Pl
2013년 8월 8일
dpb
2013년 8월 8일
Well, that's a logic flow error; you're putting hold on before you put anything on the axes. Rearrange the code to not execute the hold until the first plot is there and I think the "symptom" will also disappear.
IOW, I think this is a case of "working as designed".
Jessica Piper
2017년 3월 23일
편집: Jessica Piper
2017년 3월 23일
dpb, I don't see why this is a logic error. Moreover, this behavior did not occur pre hg2, at least for me.
One of the most natural use cases for "hold on" is when you have a loop that plots a number of data sets. The natural way to write that code would place the statements "figure;hold on;" outside of the loop, and the plot command within the loop. Requiring the user to do one extra-loop plot is ugly.
Also for the record, I am having this problem on R2015a.
Paolo Manfredi
2019년 4월 3일
I had the same issue. "Box on" solves it. Thanks for the hint!
Tony Hu
2020년 12월 15일
Thanks for the explanation, I found one of the subplots has a 'hold on' command before plot. Everything happens for a reason, indeed.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!