To plot a vertical line in Maple, the cleanest general method is the plot command with an equation in the form x = c and a specified vertical range, for example plot(x = 3, y = -5 .. 5). For a line drawn on top of another graph, use plots:-implicitplot with x = c over a y-range, or build a two-point list [[3, -5], [3, 5]] and pass it to plot. The key condition is that a vertical line has no y-as-a-function-of-x form, so you must supply the range for y (or for the plot view) explicitly rather than relying on a function of x.
Maple is a computer algebra system whose 2-D plotting is handled by the plot command and the plots package. Vertical lines come up constantly in calculus (asymptotes, bounds of integration), statistics (reference markers), and geometry. The tricky part is that most plotting habits assume y is a function of x, and a vertical line breaks that assumption. Once you know the three or four idioms that work, drawing them is quick. This guide walks through each method, shows how to combine a vertical line with an existing plot, covers annotation, and explains the errors that trip people up.
Why vertical lines need special handling in Maple
The default plot command expects an expression or a procedure in one variable, and it plots that expression as y against x. A vertical line is not the graph of any function y = f(x), because a single x value maps to infinitely many y values. So you can't write plot(x = 3) and expect a useful line across a range; Maple needs to know the vertical extent.
There are two ways around this. The first is to give the line as a parametric or point-pair object with an explicit y-range. The second is to use a plotting command that accepts an implicit equation, such as implicitplot, which can handle x = 3 directly because it works with relations rather than functions. Both are legitimate; the best choice depends on whether you're drawing the line alone or layering it onto an existing curve.
A useful mental model: whenever you specify a vertical line, you must also specify two y values (a bottom and a top), or a view that establishes them. If you omit the y-range, Maple either errors or produces something unexpected.
The direct method: plot with an equation and a y-range
The most compact approach for a standalone vertical line is to pass an equation in x together with a range for y. The syntax looks like this:
Here Maple interprets x = 3 as the line and y = -5 .. 5 as the extent. The result is a vertical segment at x = 3 stretching from y = -5 to y = 5. This works because the second argument establishes the plotting variable and its range, which for a vertical line is the natural parameter.
A few practical notes:
The y-range controls how tall the visible line is. If you want it to appear to run the full height of the plot window, set the range generously or match it to the view. You can style it inline with options such as color = red, linestyle = dash, or thickness = 2. If you also want to set horizontal extent, add the view option: view = [-10 .. 10, -5 .. 5].
So a fully styled example is:
Expect a dashed red vertical line at x = 3 spanning the visible window. To check success, confirm the line is perfectly vertical (no tilt) and sits exactly at the intended x value by reading the axis labels.
One caveat: in some Maple versions the equation form x = c with a y-range is accepted by plot, while in others you may need plots:-implicitplot. If plot(x = 3, y = -5 .. 5) returns an error or an empty plot in your version, switch to the implicit method in the next section. The underlying idea is identical.
Drawing multiple vertical lines in one call
You can draw several vertical lines at once by passing a list of equations, each with the same y-range:
The color option accepts a list matching the order of the lines, so each line gets its own color. This is handy for marking several reference values, such as quartiles, thresholds, or roots.
If you prefer to define the positions as a variable first, build the list programmatically:
This scales gracefully: change positions and the plot updates. Expect one vertical line per entry, all sharing the same vertical extent.
Be careful not to confuse a list of equations with a list of points. plot([x = 1, x = 3]) without a y-range is ambiguous; always include the y-range for vertical lines.
Using implicitplot for vertical lines
The plots package's implicitplot command handles equations of the form x = c directly, because it plots relations rather than functions. Load the package first, then call it:
Here you give ranges for both x and y, and implicitplot finds the set of points satisfying x = 3, which is the vertical line. This is the most robust approach when the plot equation form misbehaves, and it's the natural choice when you're already using implicitplot for curves like circles or ellipses.
The advantage of implicitplot is that the same command draws both the vertical line and other implicit relations, so you can combine them in one call:
This draws the vertical line at x = 3 and the circle of radius 5 together. To confirm it worked, check that the line passes through the circle at the expected points (x = 3, y = ±4) — a quick arithmetic check that catches range or scaling mistakes.
One thing to watch: implicitplot sometimes needs a finer grid to render a perfectly straight vertical line without gaps. If the line looks broken or dotted unintentionally, increase the grid option, for example grid = [50, 50]. Higher grid values cost more computation but give smoother results.
Layering a vertical line onto an existing plot
Most real use cases involve adding a vertical line to a curve you've already plotted. The standard tool is the plots package's display command, which combines multiple plots into one figure.
The procedure is:
1: Create the main plot and assign it to a name. 2: Create the vertical line as a separate plot with a matching view or range. 3: Combine them with display.
A worked example:
Expect the sine curve with a dashed red vertical line at x = π/2, which is the curve's maximum. This is the pattern you'll reuse constantly: a primary plot plus one or more reference lines, all combined through display.
The critical detail is that the line's y-range and the main plot's y-range should agree, or the line may extend beyond the visible area or stop short of the frame. Setting both to the same values (or using a common view) keeps them aligned. If the line appears to float above or below the curve region, that's the symptom of mismatched ranges.
You can also layer using implicitplot for the line instead of plot, which is useful if the main plot was itself made with implicitplot. The display command doesn't care which command produced each component.
To check success, verify the line intersects the curve exactly where theory says it should. For the example above, the line at x = π/2 should touch the sine peak at y = 1. A quick visual check confirms the alignment.
Adding labels and annotations to vertical lines
A bare vertical line is often not enough; you usually want to say what it represents. Maple provides a few ways to annotate.
The simplest is to use the legend option when the plot is created:
The legend appears in the plot and identifies the line. For multiple lines, pass a list of names in the same order as the lines.
For more precise placement, the plots package includes text-plotting tools. You can create a text object and position it near the line, then combine it with display:
This places the word "threshold" just to the right of the top of the line. The coordinates in textplot are data coordinates, so adjust them relative to your view. Expect the label to sit next to the line; if it overlaps the line or runs off the frame, nudge the coordinates.
Another option is the caption or title options, which add text at the plot level rather than in the data area. These are useful for naming the whole figure but less precise for marking a specific line. For engineering or scientific plots where reference lines must be clearly identified, the textplot approach gives the most control.
Common errors and how to fix them
Several mistakes account for most failed attempts at vertical lines. Knowing the symptom points to the fix.
Symptom: an error like "cannot determine the plotting variable" or an empty plot from plot(x = 3). Cause: no y-range was supplied, so Maple doesn't know the vertical extent. Fix: add , y = -5 .. 5 (or whatever range fits) as the second argument.
Symptom: the line appears slanted or curved. Cause: you plotted a nearly vertical expression such as 1/(x - 3) thinking it would be a line, or the aspect ratio is distorted. Fix: use an actual constant-x object; if aspect ratio is the issue, set scaling = constrained so equal data units get equal visual length.
Symptom: the line renders as a dotted or broken series. Cause: implicitplot's default grid is too coarse for the range. Fix: increase grid, e.g. grid = [80, 80].
Symptom: the line extends beyond the plot frame or stops short. Cause: line range and view mismatch. Fix: make the line's y-range match the main plot's y-range, and set a shared view.
Symptom: the line is invisible against a busy background. Cause: default color and thickness blend in. Fix: set color, linestyle = dash, and thickness explicitly.
Symptom: display shows only one of the plots. Cause: one component wasn't assigned or the list syntax is wrong. Fix: confirm both plots are named and passed in a list: display([p1, p2]).
A useful reversible first check for any of these is to plot the vertical line alone, with a generous view, before combining it with other content. If it renders correctly alone, the problem is in the combination step; if it fails alone, the problem is in the line's own definition. That one diagnostic step separates most issues cleanly.
If a plot that worked previously suddenly fails after an upgrade, the likely cause is a version-specific change in how plot accepts equation forms. Switching to implicitplot for vertical lines usually resolves version differences, and the fallback is stable across recent Maple releases. If neither approach works and the error message points to the plotting package itself rather than your syntax, that's the point to consult Maple's own documentation or support rather than keep guessing.
When to use plot versus implicitplot
Both commands draw vertical lines, so the choice is mostly about context and robustness rather than capability.
Use plot with x = c and a y-range when you're drawing a simple standalone line or a handful of reference markers and your Maple version accepts the equation form. It's terse and reads naturally.
Use implicitplot when you need to draw a vertical line alongside other implicit curves in a single call, when the plot equation form errors in your version, or when you want the line to be part of a relation-based figure. It's slightly more verbose (you must load the package and give both ranges) but more consistent.
For layering onto an existing explicit plot, either works as long as you wrap everything in display. A common pattern is plot for the main curve and implicitplot or a point-pair plot for the line, combined at the end.
There's no meaningful performance difference for a single line; both render essentially instantly. The choice is about clarity and compatibility.
A complete worked example
Putting the pieces together, here's a self-contained script that plots a curve, marks two vertical reference lines, labels them, and constrains the aspect ratio:
Expect a blue parabola with dashed vertical lines at x = −2 and x = 2, each labeled near the top, with equal visual scaling on both axes so the parabola's shape isn't distorted. The reference lines cross the parabola at y = 4, which you can verify: (−2)² = 4 and 2² = 4. That arithmetic check confirms the lines are placed correctly.
This template generalizes: change the curve, change the line positions, and adjust the view and label coordinates to match. The structure — curve, lines, labels, display — handles most reference-line figures you'll need.
Wrapping up the practical details
The working rule is simple. A vertical line needs an explicit vertical extent, and Maple gives you three reliable ways to supply it: a plot call with x = c and a y-range, an implicitplot call with both ranges, or a two-point list such as [[3, -5], [3, 5]] passed to plot. For layered figures, create each component separately and combine them with display, keeping ranges and views aligned so the line doesn't spill outside the frame.
The most common failure is forgetting the y-range, and the most common quality issue is a mismatched view between the line and the main plot. A quick standalone render of the line, before combining, catches both. Once the line is visible and correctly placed, styling options like color, linestyle, thickness, and legend make it clear and publication-ready.