# Real time plotting on the Raspberry PI 4

**URL:** https://discourse.julialang.org/t/real-time-plotting-on-the-raspberry-pi-4/123225
**Category:** General Usage
**Tags:** plotting
**Created:** [November 28, 2024, 5:00pm UTC](https://discourse.julialang.org/t/real-time-plotting-on-the-raspberry-pi-4/123225 "2024-11-28T17:00:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Jake](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake/32/46007_2.png) [@Jake](https://discourse.julialang.org/u/Jake)
#### Post date: [November 28, 2024, 5:00pm UTC](https://discourse.julialang.org/t/real-time-plotting-on-the-raspberry-pi-4/123225/1 "2024-11-28T17:00:18Z")

</div>

I am looking for a real time plotting capability for the Raspberry PI 4 and/or 5. The PI 4 has a pretty weak graphics capability, limited to Open GL ES 3.1 and Vulkan 1 and the PI 5 with OpenGL ES 3.1 and Vulkan 1.2. In doing some discourse browsing, I have come across a few links for real time plotting:

[InspectDR example](https://discourse.julialang.org/t/realtime-plotting/15638/5) by @[MA\_Laforge](https://discourse.julialang.org/u/MA_Laforge)  
[ImPlot](https://discourse.julialang.org/t/ann-implot-jl-fast-real-time-plotting-for-cimgui-jl/43087)  
[Makie](https://discourse.julialang.org/t/real-time-plotting-with-makie/20432/13)

I have given up on using Makie on the PI based on its GPU resource requirements.

I tried the InspectDR example linked above and it works well on Julia 1.10.7. My modified version of that program is shown below with timing. It seems suitable for what I am doing.

My questions:

1. How can I get the example to autoscale the y-axis?
2. Is InspectDR likely to be updated and supported on newer versions of Julia?
3. Is there another library that I should be looking at?

```julia
using InspectDR
using Colors

function getmeasdata(t, φ)
	sig = Matrix{Float64}(undef, length(t), 3)
	sig[:,1] = sin.(t .+ φ)
	sig[:,2] = cos.(t .+ φ)
	sig[:,3] = sin.(t .+ φ) .+ cos.(t .+ φ)
	return sig
end

#Build general structure of animation plot
function buildanimplot()
	NPOINTS = 50_000
	NCYCLES = 2 #To display

	color = [
        RGB24(1, 0, 0), # red
        RGB24(0, 1, 0), # green
        RGB24(0, 0, 1), # blue
        RGB24(1, 0.2, 1)] # magenta
	nchan = 3

	#collect: InspectDR does not take AbstractArray:
	t = collect(range(0, stop=NCYCLES*2pi, length=NPOINTS))
	sig = getmeasdata(t, 0)

	#Using Plot2D simplified "template" constructor:
	p = InspectDR.Plot2D(:lin, fill(:lin, nchan),
		title = "Measured Data", xlabel = "time (s)",
		ylabels = fill("Amplitude (V)", nchan))
	p.layout[:enable_legend] = true

	wfrm = Vector{InspectDR.Waveform{InspectDR.IDataset}}(undef, nchan)
	for c in 1:nchan
		wfrm[c] = add(p, t, sig[:,c], id="Signal $c", strip=c)
		wfrm[c].line = line(color=color[c], width=2)
	end

	gplot = display(InspectDR.GtkDisplay(), p)
	return (gplot, t, wfrm)
end

#Update animated plot in "real time":
function testanimplot()
	DURATION = 5 #sec
	NSTEPS = 100
	RADPERSEC = 2pi
	tstep = DURATION/NSTEPS
	ϕstep = RADPERSEC * tstep

	(gplot, t, wfrm) = buildanimplot()

	@time begin #Curious to see how long it actually takes
		for ϕ in range(0, step=ϕstep, length=NSTEPS)
			amp = (ϕ + NSTEPS)/NSTEPS
			#sleep(DURATION/NSTEPS)
			sig = getmeasdata(t, ϕ)
			nchan = size(sig,2)
			for c in 1:nchan
				wfrm[c].ds.y = sig[:,c] .* amp
			end
			InspectDR.refresh(gplot)
		end
	end
	return gplot
end

julia> gplot = testanimplot()
  9.838003 seconds (33.31 M allocations: 1007.255 MiB, 2.97% gc time)
GtkPlot("", 1 subplots)

julia>

```
