I am trying to plot a five colum dat file into two subplots using matplotlib. First colum from the dat file will be same for both the subplots. I could read the dat file in matplotlib but it is plotting only first three colums only (only one plot).
My file is sigma.dat with below entries
0.013610 0.719520E-01 0.774371E-01 0.126304E-02 0.133856E-02
0.040820 0.218942E+00 0.235756E+00 0.384315E-02 0.407507E-02
0.068030 0.370247E+00 0.398893E+00 0.649864E-02 0.689443E-02
0.095240 0.526034E+00 0.567041E+00 0.923211E-02 0.979962E-02
0.122450 0.686473E+00 0.740396E+00 0.120463E-01 0.127937E-01
0.149660 0.851747E+00 0.919171E+00 0.149441E-01 0.158801E-01
0.176870 0.102205E+01 0.110358E+01 0.179285E-01 0.190620E-01
0.204090 0.119764E+01 0.129394E+01 0.210038E-01 0.223444E-01
0.231300 0.137860E+01 0.149035E+01 0.241710E-01 0.257286E-01
0.258510 0.156522E+01 0.169312E+01 0.274349E-01 0.292199E-01
0.285720 0.175773E+01 0.190255E+01 0.307990E-01 0.328224E-01
0.312930 0.195639E+01 0.211891E+01 0.342672E-01 0.365405E-01
0.340140 0.216143E+01 0.234251E+01 0.378436E-01 0.403789E-01
0.367350 0.237315E+01 0.257367E+01 0.415324E-01 0.443426E-01
0.394570 0.259192E+01 0.281281E+01 0.453396E-01 0.484383E-01
0.421780 0.281787E+01 0.306012E+01 0.492672E-01 0.526684E-01
I tried to plot it with a small script but I am getting only single plot.
import numpy as np
import matplotlib.pyplot as pl
with open("sigma.dat", "r") as f:
x = []
y1 = []
y2 = []
for line in f:
if not line.strip() or line.startswith('@') or line.startswith('#'):
continue
row = line.split()
x.append(float(row[0]))
y1.append(float(row[1]))
y2.append(float(row[2]))
pl.plot(x, y1, x, y2)
pl.savefig("sigma.p`enter code here`ng", dpi=300)
I want to know how to plot this five colum dat file into two subplots, like clm:0:1:2; and clm:0:3:4. I expect the output image file should be having two subplots (2 1) with a space between both of them in one and no space between two subplots in another image.


matplotlib.pyplotisplt.