# Imagesc in Julia v0.5

**URL:** <https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519>\
**Category:** Visualization\
**Created:** [November 23, 2016, 10:25am UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519 "2016-11-23T10:25:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertdj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertdj/32/103_2.png) [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Post date:** [November 23, 2016, 10:25am UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/1 "2016-11-23T10:25:53Z")

</div>

Up to and including Julia v0.4 I have been using Winston for plotting, but I am experiencing problems in v0.5 and hence I am starting to use other packages.

One particular thing I miss is the `imagesc` function for viewing matrices as images. I know Gadfly has a `spy` function, but I prefer an external window for graphics.

Does anyone know of such an `imagesc`-ish function?

---

<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:** [November 23, 2016, 10:38am UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/2 "2016-11-23T10:38:57Z")

</div>

here are a 2 valid approaches with the newly released GLVisualize:  
install:

```nohighlight
Pkg.update(); Pkg.add("GLVisualize"); Pkg.add("Plots")

```

With Plots.jl

```nohighlight
using Plots, Colors; glvisualize()
plot(rand(RGBA{U8}, 1000, 1000))

```

More bare bone:

```nohighlight
using GLVisualize, Colors; w = glscreen(); @async renderloop(w)
_view(visualize(rand(RGBA{U8}, 1000, 1000)))

```

---

<div class="post-metadata">

**Author:** ![tbreloff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tbreloff/32/68_2.png) [@tbreloff](https://discourse.julialang.org/u/tbreloff)\
**Post date:** [November 23, 2016, 11:27am UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/3 "2016-11-23T11:27:19Z")

</div>

And of course this isn’t limited to the glvisualize backend. Plotting a  
matrix of colors “shows an image”, but there’s also a heatmap and spy (I  
forget…might be in StatPlots…)

---

<div class="post-metadata">

**Author:** ![tknopp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tknopp/32/3569_2.png) [@tknopp](https://discourse.julialang.org/u/tknopp)\
**Post date:** [November 23, 2016, 1:42pm UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/4 "2016-11-23T13:42:44Z")

</div>

In PyPlot the function is called imshow

---

<div class="post-metadata">

**Author:** ![robertdj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertdj/32/103_2.png) [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Post date:** [November 23, 2016, 8:19pm UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/5 "2016-11-23T20:19:31Z")

</div>

Wow! There are lots of options 🙂

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![ssfrr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ssfrr/32/3736_2.png) [@ssfrr](https://discourse.julialang.org/u/ssfrr)\
**Post date:** [November 24, 2016, 4:07pm UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/6 "2016-11-24T16:07:44Z")

</div>

I use PlotlyJS’s `heatmap` function for this sort of thing. I think it’s not as efficient as a raw raster display, as it creates a rectangle per-pixel, but it works relatively well. Plotly has an [open issue](https://github.com/plotly/plotly.js/issues/332) to support raster data directly.

---

<div class="post-metadata">

**Author:** ![lobingera](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lobingera/32/211_2.png) [@lobingera](https://discourse.julialang.org/u/lobingera)\
**Post date:** [November 25, 2016, 4:54pm UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/7 "2016-11-25T16:54:48Z")

</div>

could you please give more context, about what doesn’t work in v0.5 and information about your system?

---

<div class="post-metadata">

**Author:** ![robertdj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertdj/32/103_2.png) [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Post date:** [November 25, 2016, 10:03pm UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/8 "2016-11-25T22:03:09Z")

</div>

Sure. Tried on both Linux Mint and OS X Yosemite and the problem is the same.

In order to make Winston work I have to load it as the first package and open a plot (maybe `using Winston; plot(something)` should even be the first commands).

If I load other packages first, do some calculations, then load Winston and try to plot I get errors.

I can provide a (non-)working example if you’re interested, but probably not before Monday.

---

<div class="post-metadata">

**Author:** ![harven](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@harven](https://discourse.julialang.org/u/harven)\
**Post date:** [December 2, 2016, 11:21pm UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/9 "2016-12-02T23:21:00Z")

</div>

imagesc works fine for me with julia 0.5

The following

```
  Winston.imagesc([0 2 4 6; 8 10 12 14; 16 18 20 22])

```

gives a result pretty close to the picture displayed on the matlab [website](https://fr.mathworks.com/help/examples/graphics/DisplayImageOfMatrixData2Example_01.png)  
I would agree that Winston segfaults sometimes (e.g. when closing a plot window) but not more frequently since 0.5.

---

<div class="post-metadata">

**Author:** ![robertdj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robertdj/32/103_2.png) [@robertdj](https://discourse.julialang.org/u/robertdj)\
**Post date:** [December 3, 2016, 12:30pm UTC](https://discourse.julialang.org/t/imagesc-in-julia-v0-5/519/10 "2016-12-03T12:30:11Z")

</div>

Yes, `using Winston` and then running that command also works for me. But with a package of mine there are problems:

```julia
using GeneralizedSampling
using Winston
plot(rand(8))

```

Returns

> error during Tk callback:  
> ERROR: TypeError: non-boolean (Bool) used in boolean context  
> Error showing value of type Winston.FramedPlot:  
> ERROR: TypeError: non-boolean (Bool) used in boolean context

After a bit of testing I have concluded that my GeneralizedSampling package is the problem (on Julia v0.5, not v0.4), but I am not going to look deeper into the roots of this now.
