How to draw vertical and horizontal line at the center of the screen in matlab?
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi. I want to draw cross image.
I wonder How to draw vertical and horizontal line at the center of the screen.
Is there any way to draw line which is center?
Respuestas (2)
Abdolkarim Mohammadi
el 23 de Ag. de 2020
If you want to draw vertical or horizontal line in a figure, you can use xline() and yline().
0 comentarios
Image Analyst
el 23 de Ag. de 2020
I don't know if you can do that. I think you can only draw lines within the MATLAB client area, meaning within a certain figure or axes. If you want you can maximize the figure and if you want to draw on that, you can use annotation().
xline() and yline() only draw on an axes and axes usually don't completely fill the figure. But if you have an axes control on your figure and want a line on that you can use them.
Try this:
figure;
% Set up figure properties.
g = gcf;
g.WindowState = 'maximized';
g.Units = 'normalized';
g.NumberTitle = 'off';
% Get rid of tool bar and pulldown menus that are along top of figure.
g.ToolBar = 'none';
g.MenuBar = 'none';
% Give a name to the title bar.
g.Name = 'Demo by ImageAnalyst'
% Draw vertical red line of thickness 3:
xMiddle = [0.5, 0.5]
yAll = [0, 1]
annotation(g, 'line', xMiddle, yAll, 'Color', 'r', 'LineWidth', 3)
% Draw vertical red line of thickness 3:
yMiddle = [0.5, 0.5]
xAll = [0, 1]
annotation(g, 'line', xAll, yMiddle, 'Color', 'r', 'LineWidth', 3)
% xline and yline draw only within an axes, not outside of it into the figure.
% xline(xMiddle, 'LineWidth', 3) % Will create an axes that may not be centered.
0 comentarios
Ver también
Categorías
Más información sobre Dialog Boxes en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!