Plotting horizontal and vertical lines

If I run:

Plot[y = 10, {x, -3, 5}]

output: If I run:

Plot[x = 10, {y, -3, 5}]

I am getting exactly same output as in first case.

I need:

1. To plot y=10 and x from -3 to 5
2. To plot x=10 and y from -3 to 5

How can I do that and what I am doing wrong?

• Plot shows a function independant from name. But you can add a line like: 'Show[Plot[y = 10, {x, -3, 5}], Graphics[Line[{{1, 0}, {1, 20}}]]]' Mar 30 '20 at 18:08

Just for exploring one more option.

Plot[10, {x, -3, 5}, GridLines -> {{10}, None}, PlotRange -> {{-3, 11}, {-3, 11}},
GridLinesStyle -> Directive[RGBColor[0.368417, 0.506779, 0.709798], AbsoluteThickness[1.6]]] The form

Plot[f,{x,-3,5}]

plots f across the range -3,5. If f is a function of x, then it will plot f[x] but your expressions y=10 and x=10 aren't functions of x. They're assignments to y and to x, respectively. Mathematica's rather aggressive evaluator evaluates them both, returning 10 in both cases, and merrily plots

Plot[10,{x,-3,5}]

for you. Try changing the assignment to x or to y and see what value the variable has after the Plot command.

Try

Show[
Plot[10,{x,-3,5},PlotRange->{{-3,12},{-4,12}}],
Graphics[Line[{{10,-3},{10,5}}]]
]

The Plot will give your horizontal line. If you don't give that a PlotRange then it will only show the diagram from x=-3 to x=5 and you want to have that plot large enough so that it will include your vertical line when x=10.

Then the Graphics will give your vertical line.

And the Show will combine both those.

As always there are several different ways, sometimes a dozen different ways, to accomplish anything in Mathematica. Pick one you can memorize and use without making too many mistakes.

You can draw lines directly with Graphics, and then show its axes:

Graphics[{Line[{{10, -3}, {10, 5}}], Line[{{-3, 10}, {5, 10}}]}, Axes -> True]

Another way

Plot[10, {x, -3, 5}, PlotRange -> {{-3, 12}, {-4, 12}}, Epilog -> Line[{{10, -3}, {10, 5}}]]

ParametricPlot

ParametricPlot[{{x, 10}, {10, x}}, {x, -3, 5}] Use many options to embellish:

p1 = ParametricPlot[{{x, 10}, {10, x}}, {x, -3, 5}, Frame -> True,  