# Problems with surface

**URL:** https://discourse.julialang.org/t/problems-with-surface/123226
**Category:** General Usage
**Tags:** plotting
**Created:** [November 28, 2024, 5:32pm UTC](https://discourse.julialang.org/t/problems-with-surface/123226 "2024-11-28T17:32:17Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)
#### Post date: [November 28, 2024, 5:32pm UTC](https://discourse.julialang.org/t/problems-with-surface/123226/1 "2024-11-28T17:32:17Z")

</div>

Dear all,  
I want to plot a simple surface, as in the following command:

```julia

using Plots
gr()
xs = collect(0.1:0.05:2.0)
ys = collect(0.2:0.1:2.0)
X = [x for x = xs for _ = ys]
Y = [y for _ = xs for y = ys]
Z = ((x, y)->begin
            1 / x + y * x ^ 2
     end)

surface(X, Y, Z.(X, Y), xlabel = "longer xlabel", ylabel = "longer ylabel", zlabel = "longer zlabel")

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/6/0/60c855ab12edd17e73816f6ac2dcc5e554978287.png)

The problem is that the result does not appear the produced surface.  
What’s the problem?  
Anyone can help me please?

These are my packages, at Julia 1.11.0-beta2

```julia
julia> Pkg.status()
Status `C:\Users\Angelo\.julia\environments\v1.11\Project.toml`
  [a076750e] CPLEX v1.0.3
⌃ [a93c6f00] DataFrames v1.6.1
⌃ [5789e2e9] FileIO v1.16.3
⌃ [f6369f11] ForwardDiff v0.10.36
⌃ [2e9cd046] Gurobi v1.3.0
⌃ [7073ff75] IJulia v1.25.0
⌃ [033835bb] JLD2 v0.4.48
⌃ [4076af6c] JuMP v1.22.2
  [bcdb8e00] Metaheuristics v3.3.5
  [a03496cd] PlotlyBase v0.8.19
  [f2990250] PlotlyKaleido v2.2.5
⌃ [91a5bcdd] Plots v1.40.4
  [10745b16] Statistics v1.11.1
  [37e2e46d] LinearAlgebra v1.11.0
  [de0858da] Printf v1.11.0
  [9a3f8284] Random v1.11.0

```

---

<div class="post-metadata">

### Author: ![mbaz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbaz/32/17295_2.png) [@mbaz](https://discourse.julialang.org/u/mbaz)
#### Post date: [November 28, 2024, 6:14pm UTC](https://discourse.julialang.org/t/problems-with-surface/123226/2 "2024-11-28T18:14:57Z")

</div>

A simple way to plot this is to pass the function directly to `surface`:

```julia
xs = 0.1:0.05:2.0
ys = 0.2:0.1:2.0
z(x, y) = 1/x + y*x^2
surface(xs, ys, z)

```

---

<div class="post-metadata">

### Author: ![angeloaliano1](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@angeloaliano1](https://discourse.julialang.org/u/angeloaliano1)
#### Post date: [November 28, 2024, 6:17pm UTC](https://discourse.julialang.org/t/problems-with-surface/123226/3 "2024-11-28T18:17:27Z")

</div>

> [@mbaz](#):
>
> ```julia
> xs = 0.1:0.05:2.0
> ys = 0.2:0.1:2.0
> z(x, y) = 1/x + y*x^2
> surface(xs, ys, z)
> 
> ```

Not work yet, I have run your code. Result:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/5/3/53b88bf4fe8a7e3544f6a9f366bbdd513066ee87.png)

---

<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: [November 28, 2024, 6:19pm UTC](https://discourse.julialang.org/t/problems-with-surface/123226/4 "2024-11-28T18:19:38Z")

</div>

Your code works for me (which maybe isn’t surprising given that it’s just the docs example for surface).

I note that you are on a beta version of Julia 1.11, and have an outdated version of Plots.jl installed as well. I would recommend you update both Julia and Plots to the latest stable releases.
