1

I am running a program which uses a plotting subroutine for gnuplot. I am running a script and am supposed to view the resultant plot in real time.

Inside the do loop, the plotting command would come up say 100 times. Because of this I am obtaining 100 seperate gnuplot windows containing the plot.

The program is like

do i=1,100
...
...
call plota1(x,y)
end do

Is there any way such that I do not get such 100 plots,only one, and say, when the (i+1)th plot comes, it will come in the same gnuplot window replacing the ith plot?

The plotting subroutine used is as follows.

subroutine plota1(x,y)
real*8::x(:),y(:)
integer l,u,i
l=lbound(x(:),dim=1)
u=ubound(x(:),dim=1)
open(1,file="p.dat")
open(2,file="p.plt")

do i=l,u
write(1,*) x(i),y(i)
end do


write(2,*) "p 'p.dat' u 1:2 w l"

call execute_command_line('gnuplot -p p.plt')
close(1,status='delete')
close(2,status='delete')
end subroutine plota1

The plotting command comes from the line "write(2,*) "p 'p.dat' u 1:2 w l"". What should I add there to get the desired output? If there is no way, suggestions for using some other software will also be helpful.

0

1 Answer 1

0

The subroutine you show is doing two things. It creates a new data file, then it creates a new gnuplot instance to plot the data in that file. That's not what you want. You want a single-purpose subroutine to fill a data file with the new data, then a separate subroutine (or direct call from the main program) to tell an already existing instance of gnuplot to plot the data from that new file. I.e. you need to separate the steps of opening a gnuplot instance and then later sending commands to it. Since you do not say what library you are using, people cannot advise you whether it contains appropriate routines or not.

Sign up to request clarification or add additional context in comments.

1 Comment

By library, I just meant a module where the subroutines are kept. I am using the aforesaid subroutine only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.