# Plot lines and markers beyond the limits of the axes?

**URL:** <https://discourse.julialang.org/t/plot-lines-and-markers-beyond-the-limits-of-the-axes/92506>\
**Category:** Visualization\
**Tags:** question, plots\
**Created:** [January 4, 2023, 12:48pm UTC](https://discourse.julialang.org/t/plot-lines-and-markers-beyond-the-limits-of-the-axes/92506 "2023-01-04T12:48:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [January 4, 2023, 12:48pm UTC](https://discourse.julialang.org/t/plot-lines-and-markers-beyond-the-limits-of-the-axes/92506/1 "2023-01-04T12:48:28Z")

</div>

Is it possible? I tried to search for information but I’m not sure what key words I should use . . .

In the following example, the first and last markers are cut in half or quarter at the left and right edges of the frame of the graph:

```julia
using Plots
a = vcat(1, rand(Float64, 10))
plot(0:10, a; xlim=(0,10), ylim=(0,1), marker=:circle, markersize=5)

```

I’d like the circles to be fully displayed.

Also, I sometimes want to extend the lines and markers beyond the edges of the frame. [It’s a bit ugly but a bit more informative than not showing those datapoints when only a few datapoints fall a little beyond the round number axis limits. Suppose, for example, 97 of the 100 values fall between 0 and 1 and the remaining 3 are like 1.06; then you might choose to set the y axis limit to [0,1] and let the three points shown beyond the upper edge of the frame.]

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 4, 2023, 5:12pm UTC](https://discourse.julialang.org/t/plot-lines-and-markers-beyond-the-limits-of-the-axes/92506/2 "2023-01-04T17:12:33Z")

</div>

In this case, using `frame=:origin` and adequate `xlim`, `ylim`, can help:

```julia
using Plots; gr()
x, y = 0:10, vcat(1, rand(Float64, 10))
ex, ey = extrema(x), extrema(y)
ϵ₁, ϵ₂ = 0.03*(ex[2] - ex[1]), 0.03*(ey[2] - ey[1])
plot(x, y; frame=:origin, xlim=(-ϵ₁,10+ϵ₁), ylim=(-ϵ₂,1+ϵ₂), m=:circle, ms=5)

```

The above code is displayed in the left panel, while the default display is on the right:

 ![Plots_frame_origin_and_limits](https://global.discourse-cdn.com/julialang/original/3X/d/6/d6c6ec6680ef5f2602428e6d9f53a799cf83d07c.png)

---

<div class="post-metadata">

**Author:** ![ryofurue](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ryofurue/32/24531_2.png) [@ryofurue](https://discourse.julialang.org/u/ryofurue)\
**Post date:** [January 5, 2023, 3:22am UTC](https://discourse.julialang.org/t/plot-lines-and-markers-beyond-the-limits-of-the-axes/92506/3 "2023-01-05T03:22:04Z")

</div>

Thank you for your help! You made me realize that `xlim` and `ylim` refer to the data, not the axes. I’ve also learned the `frame` attribute. . . .

. . . But, your

> In this case

has made me wonder . . . As a test, I shifted the data upward such that the data range is [1, 2]. See the sample code and the image below. _We then lose the x axis._

If the `frame` attribute could specify the exact frame, like, say, `frame = ( (xmin, ymin), (xmax, ymax))`, this problem might be solved . . . ?

**Sample code:** You can shift the ranges of x and y:

```julia
using Plots
#ymin = 0; ymax = 1; ydel = 0.1 # <- Works fine.
ymin = 1; ymax = ymin + 1; ydel = 0.1
xmin = 0; xmax = 10; xdel = 1
a = vcat(ymax, rand(Float64, 10) .+ ymin)
ylim = (ymin - ydel, ymax + ydel)
xlim = (xmin - xdel, xmax + xdel)
plot(xmin:xmax, a; xlim=xlim, ylim=ylim,
     frame=:origin, marker=:circle, markersize=5)

```

 ![Screenshot 2023-01-05 at 12.18.09](https://global.discourse-cdn.com/julialang/original/3X/1/f/1fe12b3325019099441153b2ac6a85d05961971a.png)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [January 5, 2023, 7:38am UTC](https://discourse.julialang.org/t/plot-lines-and-markers-beyond-the-limits-of-the-axes/92506/4 "2023-01-05T07:38:35Z")

</div>

Yes, that’s my concern. Perhaps you could automate a custom axis function inspired by the solution presented [in this post](https://discourse.julialang.org/t/can-i-change-axis-position-in-plots/38966/9).
