currently, the way i live plot with Julia is i write new data to a file, and anytime that file update i update my plot. probably not the best but it works for me anyhow i want to adjust the range of my plot but the problem is if i manually do so it breaks the live plotting. let me elaborate: when i don’t manually adjust my y-axis range everything updates and progresses on the plot, by this i mean both my y-axis and x-axis do get adjusted as i read new data but when i fix the y-axis range x-axis range stops progressing but it does plot them just won’t update the x-axis anymore
function work(fin)
#cheking if my file got updated
if watch_file(fIn, 10).changed == 1
plotTime= 2000; # the amount of data shown on screen
windSec = plotTime;
initLeng= plotTime
readData=0;
# reading the data
while (readData == 0)
try
readData = readdlm(fIn, ',', Float64)
catch e
readData=0;
end
end
# x axis
xdata=Node([zeros(windSec-1) ; readData[1,1]] ) ;
xSize = lift(b -> length(b), xdata) ;
x = lift(a -> to_value(xdata)[max(1, a-initLeng+1):max(a,initLeng)], xSize)
#Y data1 :
ydata1=Node([zeros(windSec-1) ; readData[1,2]])
ySize1= lift(a -> length(a), ydata1)
y1= lift(a -> to_value(ydata1)[max(1, a-initLeng+1):max(a,initLeng)], ySize1)
scene = Scene();
plot1=lines!(scene, x, y1)
scene=plot1
#=
######################################################
here i tried to do y axis adjustment but it fails so i leave it
for now as comment
#######################################################
# 1- i tried to do it this way didn't work
#plot1=lift(a-> lines!(scene, x, a),y1)
#ylims!(to_value(plot1),(-1,2))
# 2- I tried to do it this way didn't work either
# ylims!(scene,(-1,2))
=#
#using abstract ploting if i want to have to data in one windows
#scene = AbstractPlotting.vbox(to_value(plot1))
display(scene)
while true && isopen(scene)
if watch_file(fIn, 10).changed == 1
readData = 0
while (readData==0)
try
readData = readdlm(fIn, ',', Float64)
catch e
readData=0;
end
end
#update the data :
xdata[] = append!(to_value(xdata), readData[1,1])
ydata1[] = append!(to_value(ydata1), readData[1,2])
AbstractPlotting.update_limits!(scene)
AbstractPlotting.update!(scene)
end
end
end
end
in my function, i have block comment where i tried to adjust the y-axis but failed i attached two picture ones where i use ylims!()
function and when i don’t and when i don’t use that function it clearly update the x axis but when i do use it stops updating it i have no clue what i am doing wrong but who ever save me from my suffering i would appreciate it. i spent more than 10-15 hours trying to fix this and found no result.