2020年12月21日星期一

Python plot script launched 2 times while drawing the 2 curves on the same interactive plot window

I have a Python script that plots a simple curve from 2 columns of an input1.dat file :

#!/usr/local/bin/python3    from __future__ import division  import numpy as np  import matplotlib.pyplot as plt  import sys    fileData = sys.argv[1]  # Chose the first column x-axis : sys.argv[2]  # Chose the first column y-axis : sys.argv[3]  columnx = int(sys.argv[2])  columny = int(sys.argv[3])    # Load data  data = np.loadtxt(fileData, skiprows=1)    # Min/Max for (x,y)  minx = np.min(data[:,columnx])  maxx = np.max(data[:,columnx])  miny = np.min(data[:,columny])  maxy = np.max(data[:,columny])    # Limits  plt.xlim(minx, maxx)  plt.ylim(miny, maxy)    # Plot  plt.plot(data[:,columnx], data[:,columny], "-", linewidth=2)  plt.minorticks_on()  plt.grid(which='both', color='#aaaaaa')  plt.show()  

I called this scrip "plot" and put it in PATH environment varable.

So I can call it a first time : $ plot input1.dat 0 2 & which displays the first curve.

Now, as I have put a '&' symbol on command line, I get the hand to launch a second command :

$ plot input2.dat 0 2 &

As you guess, I would like this second curve was plotted on the same interactive window than the first one interactive graphic window; this way, I would have plotted the 2 curves on the same figure.

How could I carry out this if it is possible ? Have I got to change something in my Python script ?

Any suggestion is welcome.

https://stackoverflow.com/questions/65402002/python-plot-script-launched-2-times-while-drawing-the-2-curves-on-the-same-inter December 22, 2020 at 09:06AM

没有评论:

发表评论