# Is there an equivalent of python's PyPlot tight\_layout() for Julia Plots?

**URL:** <https://discourse.julialang.org/t/is-there-an-equivalent-of-pythons-pyplot-tight-layout-for-julia-plots/67304>\
**Category:** New to Julia\
**Tags:** plotting, plots\
**Created:** [August 29, 2021, 6:19pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-pythons-pyplot-tight-layout-for-julia-plots/67304 "2021-08-29T18:19:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hdcpereira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdcpereira/32/28705_2.png) [@hdcpereira](https://discourse.julialang.org/u/hdcpereira)\
**Post date:** [August 29, 2021, 6:19pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-pythons-pyplot-tight-layout-for-julia-plots/67304/1 "2021-08-29T18:19:04Z")

</div>

As you can see in this graph, the annotation goes beyond the area of the figure. In python I’m used to fix this with pyplot.tight\_layout().

![howdy](https://global.discourse-cdn.com/julialang/original/3X/b/9/b9da61b01145e0afb4ae9ce6f73c785df49ebb00.png)

```julia
d = Dict{Any, Any} with 7 entries:
  "C" => 10.7406
  "C ffast-math" => 7.28659
  "Python- Built-in" => 1631.21
  "Python numpy" => 4.74571
  "Python hand-written" => 1942.86
  "Julia built-in" => 6.45389
  "Julia hand-written" => 10.7421

l_vec = sort(collect(d), by=x->x[2], rev = true)

x = map(x->x[1], l_vec)
y = map(x->x[2], l_vec)

y_annotations = [@sprintf(" %.2f ms",i) for i in y]  

Plots.bar(x ,y ,
    xaxis = ("time (ms)",false, nothing), 
    yaxis = ("Languages",false),
    orientation= :horizontal,label = "" , series_annotation = (y_annotations, font(7, :left)))

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [August 29, 2021, 6:36pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-pythons-pyplot-tight-layout-for-julia-plots/67304/2 "2021-08-29T18:36:59Z")

</div>

This post was temporarily hidden by the community for possibly being off-topic, unfocused, inappropriate, or spammy.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [August 29, 2021, 6:40pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-pythons-pyplot-tight-layout-for-julia-plots/67304/3 "2021-08-29T18:40:05Z")

</div>

`bar(x, y, right_margin = 10Plots.mm)` (or however many `mm` you need to add to get it all to show)

---

<div class="post-metadata">

**Author:** ![hdcpereira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdcpereira/32/28705_2.png) [@hdcpereira](https://discourse.julialang.org/u/hdcpereira)\
**Post date:** [August 29, 2021, 6:58pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-pythons-pyplot-tight-layout-for-julia-plots/67304/4 "2021-08-29T18:58:47Z")

</div>

i wrote a proper post for this, I think the discussion is rich enough. here: [Comparing Sum function from multiple languages](https://discourse.julialang.org/t/comparing-sum-function-from-multiple-languages/67305)

---

<div class="post-metadata">

**Author:** ![hdcpereira](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hdcpereira/32/28705_2.png) [@hdcpereira](https://discourse.julialang.org/u/hdcpereira)\
**Post date:** [August 29, 2021, 6:59pm UTC](https://discourse.julialang.org/t/is-there-an-equivalent-of-pythons-pyplot-tight-layout-for-julia-plots/67304/5 "2021-08-29T18:59:23Z")

</div>

Wow. Is there any other way to do so?
