In [ ]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
# dummy index
x=0;y=1;ro=2;pr=3;vx=4;vy=5;vz=6;ux=7;uy=8;uz=9;u0=10;bx=11;by=12;bz=13;ex=14;ey=15;ez=16;pt=17

# reading the data...
d1 = np.loadtxt('data/x-00000.dat')
d2 = np.loadtxt('data/x-00002.dat')

line1, = plt.plot(d1[:,x],d1[:,u0],linestyle=':',color='gray')
line2, = plt.plot(d2[:,x],d2[:,u0],linestyle='-',color='black')

plt.xlim( -0.1, 0.1)
plt.xlabel(r'$X$',fontsize=16)
plt.ylabel(r'$\gamma$', fontsize=16)

plt.legend( (line1, line2), ('t=0.0', 't=0.2'), loc='upper left', fontsize=14, shadow=True)

#plt.tight_layout() # if necessary
plt.show()
#plt.savefig("output.png")

In [ ]:
# Interactive version by jupyter-notebook / ipywidgets
# To use it, please install jupyter and then activate widgetsnbextension.
# $ pip3 install jupyter
# $ [ pip3 install ipywidgets ]
# $ jupyter nbextension enable --py widgetsnbextension
# Then one can run this sample
# $ jupyter-notebook plot.ipynb

%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import glob
from ipywidgets import interact

labels={"x":0,"y":1,"Density":2,"Pressure":3,"vx":4,"vy":5,"vz":6,"ux":7,"uy":8,"uz":9,"u0":10,"Bx":11,"By":12,"Bz":13,"Ex":14,"Ey":15,"Ez":16,"Total pressure":17}
colors=['r','g','b']
markers=['o','s','.']
linestyles=['--','-.','-']
datalist = sorted(glob.glob('data/x-?????.dat')) # filelist (regular expression)

@interact (inputdata=datalist,xlabel=labels,ylabel=labels,color=colors,marker=markers,linestyle=linestyles)
def plot(inputdata,xlabel=0,ylabel=3,color='b',marker='o',linestyle='-'):
    # reading the data...
    data = np.loadtxt(inputdata)
    # plot
    plt.plot(data[:,xlabel],data[:,ylabel],color=color,marker=marker,linestyle=linestyle)
    labelnames = list(labels.keys())
    plt.xlabel(labelnames[xlabel])
    plt.ylabel(labelnames[ylabel])
    #plt.savefig("output.png")

In [ ]: