# Best way to plot (discrete) 2d distribution

**URL:** <https://discourse.julialang.org/t/best-way-to-plot-discrete-2d-distribution/128213>\
**Category:** Visualization\
**Created:** [April 19, 2025, 10:39am UTC](https://discourse.julialang.org/t/best-way-to-plot-discrete-2d-distribution/128213 "2025-04-19T10:39:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [April 19, 2025, 10:39am UTC](https://discourse.julialang.org/t/best-way-to-plot-discrete-2d-distribution/128213/1 "2025-04-19T10:39:24Z")

</div>

I have a MxN matrix. What is the best way to plot it? I tried using `histogram2d`, but its example just uses two vectors, and with my matrix the result is weird. I also tried something like

```julia
using Plots
x=range(1,stop=50,length=50)
y=range(1,stop=50,length=50)
f(x,y) = sol.u[end][x,y]
plot(x,y,f,st=:surface,camera=(-30,30))

```

but this is for a continuous function. And while I would try and interpolate my data, this feels weird and potentially a bit unnecessary.

---

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [April 19, 2025, 10:57am UTC](https://discourse.julialang.org/t/best-way-to-plot-discrete-2d-distribution/128213/2 "2025-04-19T10:57:22Z")

</div>

`heatmap` is the solution!
