필터 지우기
필터 지우기

Odd minor grid behavior

조회 수: 1 (최근 30일)
Rob Campbell
Rob Campbell 2019년 4월 17일
Hi all:
I recently tried to use minor grids to set up lines around cells in a scaled color image, and have not been able to get it to work, I'm getting lines on the major ticks too. Here's an example:
t=rand(10);
figure
imagesc(t)
xl=xlim;
ax=gca;
ax.YAxis.MinorTickValues=[xl(1)+1:1:xl(2)-1];
ax.XAxis.MinorTickValues=[xl(1)+1:1:xl(2)-1];
set(ax,'yminorgrid','on','xminorgrid','on','minorgridlinestyle','-')
...that gives me a plot like this:
imagesc_weirdness.png
I've tried toggling the major grid with 'grid', setting the major grid linestyle to 'none', neither will get rid of the lines on the major ticks.
The same behavior occurs with a simple plot:
t=rand(10,2);
figure
plot(t(:,1),t(:,2),'k.')
ax=gca;
ax.XLim=[0 1]; ax.YLim=[0 1];
ax.YAxis.MinorTickValues=[0.05:0.1:0.95];
ax.XAxis.MinorTickValues=[0.05:0.1:0.95];
set(ax,'yminorgrid','on','xminorgrid','on','minorgridlinestyle','-')
produces this:
plot_tick_weirdness.png
Is there something I'm not understanding about the minor grid behavior? Is there a way to have just the minor grid showing? I've verified this occurs in R2017b and R2019a.
I have a workaround using a for loop to draw lines, but I'm curious to know why this is happening.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by