# Ask for better method to visualizing two-dimensional or three-dimensional areas

**URL:** <https://discourse.julialang.org/t/ask-for-better-method-to-visualizing-two-dimensional-or-three-dimensional-areas/114387>\
**Category:** General Usage\
**Tags:** question, visualization, makie\
**Created:** [May 17, 2024, 8:33am UTC](https://discourse.julialang.org/t/ask-for-better-method-to-visualizing-two-dimensional-or-three-dimensional-areas/114387 "2024-05-17T08:33:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![WuSiren](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wusiren/32/42529_2.png) [@WuSiren](https://discourse.julialang.org/u/WuSiren)\
**Post date:** [May 17, 2024, 8:33am UTC](https://discourse.julialang.org/t/ask-for-better-method-to-visualizing-two-dimensional-or-three-dimensional-areas/114387/1 "2024-05-17T08:33:09Z")

</div>

What’s the most recommended way to visualize a two-dimensional or three-dimensional areas, e.g., f(x, y) \leqslant c and f(x, y, z) \leqslant c ?

I’ve tried `CairoMakie.contour` but I’m not quite satisfied with it:

```julia
using CairoMakie

f(x, y) = x^2 + y^2
c = 3

## Method-1:
fig = Figure()
Axis(fig[1, 1])
xs = LinRange(-3, 3, 100)
ys = LinRange(-3, 3, 100)
zs = [f(x, y) for x in xs, y in ys]
contour!(xs, ys, zs, levels = [c], color=:red)
fig

## Method-2:
fig = Figure()
Axis(fig[1, 1])
xs = LinRange(-3, 3, 100)
ys = LinRange(-3, 3, 100)
zs = [f(x, y) for x in xs, y in ys]
contourf!(xs, ys, zs, levels = 2)
fig

```

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/2/92bcdc67c494939a570cf804a9abae7fefc3f78b.png)  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/4/f/4f991217f924640b6f91e1e68852ced4dbeeecc5.png)

I hope, for two-dimensional case, the area can be filled with some pure color and its border with another, and no color fills irrelevant area that f(x, y) \> c.

For three-dimensional case, the surface of the area can be displayed, and the interior is not required to be filled with color, of course, it’ll be better if it is also fill with some color.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 17, 2024, 10:02am UTC](https://discourse.julialang.org/t/ask-for-better-method-to-visualizing-two-dimensional-or-three-dimensional-areas/114387/2 "2024-05-17T10:02:07Z")

</div>

Your question can be rephrased in more general terms: how to plot implicit functions?

There is some related discussion here:

> [@Plotting Implicit Functions using ImplicitEquations.jl](https://discourse.julialang.org/t/plotting-implicit-functions-using-implicitequations-jl/49708):
>
> I’m trying to plot an implicit function using Plots, ImplicitEquations f(x,y)= sqrt((x^2+144)+(y^2+144)) and I get ERROR: Cannot convert Num to series data for plotting perhaps it’s because I have x and y as symbols using ModelingToolkit, Plots, ImplicitEquations @variables x y f(x,y)= sqrt((x^2+144)+(y^2+144))
