In Matlab, is there a way in increase the size of a grid in a figure?
7 views (last 30 days)
Show older comments
I am trying to create a sudoku puzzle in a figure and am using a grid. However, when I run the program, the figure is extremely small and I always have to manually make the figure bigger in order to the sudoku to display properly. This is how is displays:
This is how I want it to display:
This is my code for creating the sudoku figure:
{function dispSudoku(ingrid)
checker = [.8 .8 .8 .8 .8 .8 .8 .8 .8 .8 ; .8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6; .8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 1 1 1 0.6 0.6 0.6 1 1 1;.8 1 1 1 0.6 0.6 0.6 1 1 1;.8 1 1 1 0.6 0.6 0.6 1 1 1;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6;.8 0.6 0.6 0.6 1 1 1 0.6 0.6 0.6];
% Create matrix to show white/gray checkers
figure('position', [500 200 700,500]) % create new figure with specified size
grid on
imshow(checker); % Show image
colormap gray; % Make values gray
set(gca,'Position',[0 0 1 1]); % Adjust position
...
}
0 Comments
Answers (1)
Chris Portal
on 17 Apr 2016
The grid spacing is driven by the tick spacing in your axes, so it requires your setting the XTick and YTick properties. For example:
figure
plot(1:100)
grid on
set(gca,'xtick',[0:5:100])
set(gca,'ytick',linspace(0,100,13))
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!