# How can I save a Makie heatmap as PNG with one pixel per matrix element?

**URL:** <https://discourse.julialang.org/t/how-can-i-save-a-makie-heatmap-as-png-with-one-pixel-per-matrix-element/70579>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [October 28, 2021, 7:11pm UTC](https://discourse.julialang.org/t/how-can-i-save-a-makie-heatmap-as-png-with-one-pixel-per-matrix-element/70579 "2021-10-28T19:11:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [October 28, 2021, 7:11pm UTC](https://discourse.julialang.org/t/how-can-i-save-a-makie-heatmap-as-png-with-one-pixel-per-matrix-element/70579/1 "2021-10-28T19:11:00Z")

</div>

For example:

```julia
using Makie
x = rand(300, 400)
fig = heatmap(x)
Makie.save("out1.png", fig) # 800 x 600
Makie.save("out2.png", fig, px_per_unit=1) # 800 x 600
Makie.save("out3.png", fig, resolution=size(x)) # 300 x 400

```

The last version (out3.png) is closest to what I want, but it squeezes the actual heatmap and the x & y axes into a png of size 300 x 400. I want the **plotting area** to be 300 x 400 (so the saved image with axes becomes slightly larger), i.e. using exactly one pixel per matrix element. Is this possible?

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [October 28, 2021, 8:50pm UTC](https://discourse.julialang.org/t/how-can-i-save-a-makie-heatmap-as-png-with-one-pixel-per-matrix-element/70579/2 "2021-10-28T20:50:33Z")

</div>

You can do this by directly drawing to a scene with the pixel camera projection:

```julia
x = rand(300, 400)
scene = Scene(camera=campixel!, resolution=size(x))
heatmap!(scene, x)
save("out.png", scene)

```
