필터 지우기
필터 지우기

I have a gridded figure with 2 "game boards" , but they don't look the same

조회 수: 4 (최근 30일)
I have the following code to plot a figure with 2 game boards, for a battleship game:
subplot( 2, 1, 1 );
set( gca, 'XTickLabel', '', 'YTickLabel', '', 'BoxStyle', 'full' );
title( 'Computer Board' );
axis square
subplot( 2, 1, 2 );
axis square
set( gca, 'XTickLabel', '', 'YTickLabel', '', 'BoxStyle', 'full' );
title( 'Your Board' );
But the board appears as in the attached picture, so how can i make them both look the same, also how can i make both a bit bigger.

채택된 답변

Image Analyst
Image Analyst 2022년 1월 2일
Maybe try calling xlim and ylim after you call axis on each. Like maybe
xlim([0.5, 6.5]);
ylim([0.5, 6.5]);
or
xlim([1 6]);
ylim([1 6]);
  댓글 수: 4
Tariq Hammoudeh
Tariq Hammoudeh 2022년 1월 3일
@Image Analyst Ok i got it to work with:
subplot( 2, 1, 1 );
set( gca, 'XTickLabel', '', 'YTickLabel', '', 'BoxStyle', 'full' );
title( 'Computer Board' );
axis square
xlim([1, 7]);
ylim([0, 6]);
subplot( 2, 1, 2 );
set( gca, 'XTickLabel', '', 'YTickLabel', '', 'BoxStyle', 'full' );
title( 'Your Board' );
axis square
But how can i make the "boards" a bit bigger, because now they are a bit small.
Image Analyst
Image Analyst 2022년 1월 3일
ax = gca;
ax.Units = 'normalized';
ax.Position = [xLeft, yTop, width, height];
Set all values in the range 0 to 1.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by