# How to avoid clipping points at plot boundaries?

**URL:** <https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150>\
**Category:** General Usage\
**Tags:** plotting, gr, pgfplotsx\
**Created:** [September 14, 2021, 1:39pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150 "2021-09-14T13:39:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gedankenexperiment](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@gedankenexperiment](https://discourse.julialang.org/u/gedankenexperiment)\
**Post date:** [September 14, 2021, 1:39pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150/1 "2021-09-14T13:39:14Z")

</div>

Hi there,

I have defined axis limits such that I have ticks at the boundaries of my plot. But data points whose values correspond to the limits are clipped at the plot boundaries. In `R`, one can prevent this by using [`coord_cartesian(clip="off")`](https://ggplot2.tidyverse.org/reference/coord_cartesian.html). Is there an equivalent in Julia / [GR](https://docs.juliaplots.org/latest/generated/gr/) ? Many thanks in advance.

---

<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:** [September 14, 2021, 2:23pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150/2 "2021-09-14T14:23:17Z")

</div>

Adding the plot argument `widen=true` is not satisfactory?

---

<div class="post-metadata">

**Author:** ![gedankenexperiment](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@gedankenexperiment](https://discourse.julialang.org/u/gedankenexperiment)\
**Post date:** [September 14, 2021, 2:43pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150/3 "2021-09-14T14:43:23Z")

</div>

> [@rafael.guerra](#):
>
> widen=true

Then the axes don’t end at a tick ☹ In other words: I only want to manipulate the limitations of where the data can be drawn (called plot area in Plots.jl?), such that I have full circles when plotting data points, while keeping axis limits.

---

<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:** [September 14, 2021, 3:09pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150/4 "2021-09-14T15:09:02Z")

</div>

Then you may need to change package [as in this example](https://discourse.julialang.org/t/pgfplotsx-annotate-outside-plot-area/58357/2).

---

<div class="post-metadata">

**Author:** ![gedankenexperiment](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@gedankenexperiment](https://discourse.julialang.org/u/gedankenexperiment)\
**Post date:** [September 14, 2021, 3:44pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150/5 "2021-09-14T15:44:16Z")

</div>

Good suggestion, but switching backend entails a lot of changes to be made. I guess I will simply adjust lims, export the plot as SVG and correct the axis extension in Inkscape.

---

<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:** [September 14, 2021, 4:18pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150/6 "2021-09-14T16:18:44Z")

</div>

Before we throw in the towels with Plots gr() back-end, some possible workaround:  
 ![Plots_gr_markers_on_border](https://global.discourse-cdn.com/julialang/original/3X/1/2/12c939fc25c768b5b727f4da874b488cd72a1408.png)

```julia
using Plots; gr()
rectangle(w, h, x, y) = Shape(x .+ [0,w,w,0], y .+ [0,0,h,h])
xl = (-3, 3)
yl = (-1, 1)
plot(rectangle(xl[2]-xl[1],yl[2]-yl[1],xl[1],yl[1]), opacity=.1, grid=true, legend=false)
scatter!(sin, xlims=xl, ylims=yl, tick_direction=:out, framestyle=:grid, widen=true)

```

---

<div class="post-metadata">

**Author:** ![gedankenexperiment](https://avatars.discourse-cdn.com/v4/letter/g/a183cd/32.png) [@gedankenexperiment](https://discourse.julialang.org/u/gedankenexperiment)\
**Post date:** [September 14, 2021, 5:25pm UTC](https://discourse.julialang.org/t/how-to-avoid-clipping-points-at-plot-boundaries/68150/7 "2021-09-14T17:25:08Z")

</div>

Layering seems like a good approach. I will look into this (again).
