# Create Hayshed in 3D with Inverted Catenary, Need Help with Modify the x and y ticks

**URL:** <https://discourse.julialang.org/t/create-hayshed-in-3d-with-inverted-catenary-need-help-with-modify-the-x-and-y-ticks/100807>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [June 25, 2023, 11:14am UTC](https://discourse.julialang.org/t/create-hayshed-in-3d-with-inverted-catenary-need-help-with-modify-the-x-and-y-ticks/100807 "2023-06-25T11:14:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [June 25, 2023, 11:14am UTC](https://discourse.julialang.org/t/create-hayshed-in-3d-with-inverted-catenary-need-help-with-modify-the-x-and-y-ticks/100807/1 "2023-06-25T11:14:41Z")

</div>

I am using Plotlyjs here, `gr()` can also be used, but can’t be rotated.

I want to create a hayshed that will look like this:  
 ![Capture d’écran_2023-06-24_22-17-13](https://global.discourse-cdn.com/julialang/original/3X/5/9/59c674eb007c734981604f7f2876b9e2aa40b947.png)

I have come up with this code:

```julia
# Inverted catenary
using Plots;
#gr() 
plotlyjs()

# a large hayshed of length 100 feet and width 48 feet is built
# a cross section has the shape of an inverted catenary with equation y = 37 - 24 cosh (x/24)
# ones(m) = m-element row vector (m x 1) with entries of 1
# ones(m,n) = m times n matrix with entries of 1
# range(0, 2π; length = n) = initial 0 till 2π partitioned n times
# θ' = 1x130 vector column with entries θ
# ones(m)*θ' -> becomes m x dim(θ') matrix
# cosh.(ones(m)*θ') -> compute cosh for every entries in matrix (ones(m)*θ')

function hayshedcatenary(r)   
    m = 200
    n = 130
    h = 100 # length 100 feet
    θ = range(0, 2π; length = n)
    w = range(0, 48; length = n)
    t = range(0, h; length = m) 
    x = ones(m)*w'
    y = t * ones(n)' 
    z = 37*ones(m,n) - 24cosh.(ones(m)*(θ/24)')
    return x, y, z
end
my_cg = cgrad([:green,:blue])
surface(hayshedcatenary(3), label="hayshed")	

```

![Capture d’écran_2023-06-25_18-13-31](https://global.discourse-cdn.com/julialang/original/3X/5/6/56515d59680d498dd8a9864c318c48e7bfdcf8c3.png)

There is a slight missing, on the vertical / y-axis it should be from 0 to 13, I follow the equation carefully, if there is something wrong with this:  
`37*ones(m,n) - 24cosh.(ones(m)*(θ/24)')` ?

The x axis in the picture is from -24 to 24, can we modify the code so it will goes form -24 to 24 as well? instead of 0 to 48.

**Edited,** fix the x axis with: `w = range(-24, 24; length = n)`

and I fix the y-axis with:

```julia
function hayshedcatenary(r)   
    m = 200
    n = 130
    h = 100 # length 100 feet
    w = range(-24, 24; length = n)
    t = range(0, h; length = m) 
    x = ones(m)*w'
    y = t * ones(n)' 
    z = 37*ones(m,n) - 24cosh.(ones(m)*(w/24)')
    return x, y, z
end

```

Thanks.

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [June 25, 2023, 6:39pm UTC](https://discourse.julialang.org/t/create-hayshed-in-3d-with-inverted-catenary-need-help-with-modify-the-x-and-y-ticks/100807/2 "2023-06-25T18:39:54Z")

</div>

θ should belong to a symmetric interval about 0:

```julia
function hayshedcatenary()   
    m = 200
    n = 130
    h = 100 # length 100 feet
    θ = range(-3, 3; length = n)
    w = range(-24, 24; length = n)
    t = range(0, h; length = m) 
    x = ones(m)*w'
    y = t * ones(n)' 
    z = 37*ones(m,n) - 24cosh.(ones(m)*(θ/24)')
    return x, y, z
end
my_cg = cgrad([:green,:blue])
surface(hayshedcatenary(), label="hayshed")	

```

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [June 26, 2023, 2:10pm UTC](https://discourse.julialang.org/t/create-hayshed-in-3d-with-inverted-catenary-need-help-with-modify-the-x-and-y-ticks/100807/3 "2023-06-26T14:10:22Z")

</div>

Thanks for the answer, but I find the solution if we just use `w` instead of `\theta` for z
