How to make grid lines visible while Axis is invisible?

조회 수: 16 (최근 30일)
Chaitanya Jha
Chaitanya Jha 2019년 6월 24일
답변: Chaitanya Jha 2019년 6월 26일
Hi, I am developing a GUI in which I have two plots, current and voltage (see below). I am using 3 axes, a big one whos X-Axis displays the time, two smaller axes on top of this big axes, I plot current and voltage in these two smaller top axes. The visibility of the smaller axes is set to 0 and only the visibility of their Y-Axis is switched on afterwards. This gives it an impression that both current and voltage are plotted on the bigger axes on which X-Axis serves as time axis. I can do all this, however, I would like to switch on the YGrid of the two smaller axis while keeping the axis itself invisible. I have tried different methods, such as setting the YGrid property to 'on' and using 'grid on' command, but nothing works. Can it be done?
  댓글 수: 4
Geoff Hayes
Geoff Hayes 2019년 6월 25일
Chaitanya - to be clear, the axes object is hidden (visible property set to off or false) yet you want to show the YGrid lines for that hidden axes object?
Chaitanya Jha
Chaitanya Jha 2019년 6월 25일
Yes Geoff. I figured that if I can only show the Y-Axis while the rest of the Axes is hidden then there might be a way to just enable the visible property of the YGrid for the same axis without making the the rest of the Axes (i.e. XGrid, X-Axis, Background, etc) visible.

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

채택된 답변

Chaitanya Jha
Chaitanya Jha 2019년 6월 26일
I found the workaround of this problem by chaning the background of the axes to transparent using below code
set(Ax,'Color','none');

추가 답변 (1개)

Jan
Jan 2019년 6월 25일
The question is a little bit confusing for me. An invisible axes does not have visible properties. But you can create a visible axes and hide what you want:
ax = axes;
ax.XGrid = 'on';
ax.YGrid = 'on';
ax.XTick = [];
ax.YTick = [];
ax.XAxis.Visible = 'off';
ax.YAxis.Visible = 'off';
  댓글 수: 1
Chaitanya Jha
Chaitanya Jha 2019년 6월 25일
Hi Jan, I can understand your confusion. Creating a visible axes means the background of the axes is still visible, I would like to make the background and everything else invisible, and then make only a few selected properties, such as YAxis and YGrid, visible.

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

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by