z_multi.html
001|
002| from os import path
003| from random import uniform
004| import numpy as np
005| import matplotlib.pyplot as plt
006| from matplotlib.ticker import MultipleLocator, FormatStrFormatter
007|
008| BasePath = r'C:\CJS\prj\Python\charts'
009| ImgsPath = path.join(BasePath,'img')
010|
011|
012|
013| def do_chart_multi ():
014| filename = path.join(ImgsPath,'z_multi.png')
015|
016|
017| xs = np.linspace(0.0, 5.0, 500)
018| ys1, ys2, yr = [0.0], [0.0], 0.80
019| for x in xs[1:]:
020| ys1.append( (uniform(-yr,+yr)) )
021| ys2.append( (uniform(-yr,+yr)) )
022|
023|
024| fig,axes = plt.subplots(nrows=2, ncols=1, squeeze=True)
025| fig.suptitle('Multiple Charts')
026| ax1 = axes[0]
027| ax2 = axes[1]
028|
029|
030| ax1.set_title('Left Channel', loc='right')
031| ax1.set_xlabel('Time (mS)')
032| ax1.set_ylabel('Potential (mV)')
033| ax1.set_fc('#f0fff0')
034| ax1.set_xlim(0.0, +5.0)
035| ax1.set_ylim(-1.0, +1.0)
036| ax1.xaxis.set_major_locator(MultipleLocator(1.00))
037| ax1.xaxis.set_minor_locator(MultipleLocator(0.10))
038| ax1.yaxis.set_major_locator(MultipleLocator(0.50))
039| ax1.yaxis.set_minor_locator(MultipleLocator(0.10))
040| ax1.yaxis.set_major_formatter(FormatStrFormatter('%+.1f'))
041| ax1.axhline(0.0, color='k', lw=1.5)
042| ax1.grid(which='major', axis='both', color='#7f7f7f', lw=1.0,ls='-', alpha=1.0, zorder=1)
043| ax1.grid(which='minor', axis='both', color='#bfbfbf', lw=0.5,ls='-', alpha=1.0, zorder=0)
044| ax1.plot(xs,ys1)
045|
046|
047| ax2.set_title('Right Channel', loc='right')
048| ax2.set_xlabel('Time (mS)')
049| ax2.set_ylabel('Potential (mV)')
050| ax2.set_fc('#fff0f0')
051| ax2.set_xlim(0.0, +5.0)
052| ax2.set_ylim(-1.0, +1.0)
053| ax2.yaxis.set_major_formatter(FormatStrFormatter('%+.1f'))
054| ax2.xaxis.set_major_locator(MultipleLocator(1.00))
055| ax2.xaxis.set_minor_locator(MultipleLocator(0.10))
056| ax2.yaxis.set_major_locator(MultipleLocator(0.50))
057| ax2.yaxis.set_minor_locator(MultipleLocator(0.10))
058| ax2.yaxis.set_major_formatter(FormatStrFormatter('%+.1f'))
059| ax2.axhline(0.0, color='k', lw=1.5)
060| ax2.grid(which='major', axis='both', color='#7f7f7f', lw=1.0,ls='-', alpha=1.0, zorder=1)
061| ax2.grid(which='minor', axis='both', color='#bfbfbf', lw=0.5,ls='-', alpha=1.0, zorder=0)
062| ax2.plot(xs,ys2)
063|
064| fig.set_figwidth(6.4)
065| fig.set_figheight(4.8)
066| fig.subplots_adjust(left=0.12, bottom=0.12, right=0.95, top=0.90, hspace=0.50)
067| fig.savefig(filename)
068|
069|
070|
071| if __name__ == '__main__':
072| do_chart_multi()
073|
074| '''eof'''
075|