In Matlab, is there a way in increase the size of a grid in a figure?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161587/image.png)
This is how I want it to display:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/161589/image.png)
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 comentarios
Respuestas (1)
Chris Portal
el 17 de Abr. de 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 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!