Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

AlexYang's code can run outside the PSSe GUI! I added code to export to XLS, change ax1.plot to plt.plot, and commented "axes.set_facecolor('w')" to make it work on my pc:

import dyntools
import matplotlib.pyplot as plt

outfile = r"""test.out"""
chnfobj = dyntools.CHNF(outfile)
short_title, chanid, chandata = chnfobj.get_data()

t = chandata['time']
v = chandata[1]              #based on the channel identifier set in the dynamic simulation
XLSfile = 'voltage.xls'
sheetname= 'V_chan1'
chnfobj.xlsout(channels=[1,],outfile=outfile,xlsfile=XLSfile,sheet=sheetname,show=False)

fig = plt.figure()
fig.patch.set_facecolor('0.8')
plt.plot(t,v,linestyle='-', linewidth=1, color='green',label="Voltage")
plt.grid(linestyle='--', color='grey',linewidth=0.5)
plt.xlabel("Time")
plt.ylabel("Voltage")
plt.legend()
axes = plt.gca()
#axes.set_facecolor('w')
axes.set_ylim([0.6,1.2])
axes.set_xlim([0,10])
plt.savefig(r"""figure.pdf""",dpi=fig.dpi,facecolor='0.8')
plt.show()