How to plot vertical and horizontal bars in a graph?

This is my code. I want to make an intersection road graph and T-junction road.
switch get(handles.shape, 'value');
case 1
errordlg('Please choose any shape','Error');
case 2
grid on;
line(ylim, [20,20], 'Color', 'k', 'LineWidth', 50);
% Draw line for Y axis.
case 3
hold on;
line([10,10], ylim, 'Color', 'k', 'LineWidth', 22); % Draw line for Y axis.
line(xlim, [0.5,0.5], 'Color', 'k', 'LineWidth', 22); % Draw line for X axis.
case 4
hold on;
line([10,10], ylim, 'Color', 'k', 'LineWidth', 22); % Draw line for Y axis.
line(xlim, [1,1], 'Color', 'k', 'LineWidth', 22); % Draw line for X axis.
case 5
r = 1;
xc = 3;
yc = 3;
theta = linspace(0,1*pi);
x = r*cos(theta) + xc;
y = r*sin(theta) + yc;
plot(x,y,'Color','k','LineWidth',15)
axis equal
case 6
r = 1;
xc = 3;
yc = 3;
theta = linspace(0,2*pi);
x = r*cos(theta) + xc;
y = r*sin(theta) + yc;
plot(x,y,'Color','k','LineWidth',15)
axis equal
end

1 Comment

Not sure what the problem is, but line() should do it. If you want some other shape, try patch() or fill().
Is there a problem with line()? If so, attach a screenshot, and if possible your m and fig files.

Sign in to comment.

Answers (0)

Tags

Asked:

on 13 Dec 2019

Edited:

on 13 Dec 2019

Community Treasure Hunt

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

Start Hunting!