1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime
from matplotlib.dates import strpdate2num
from matplotlib.ticker import AutoMinorLocator
minorLocator = AutoMinorLocator()
y = np.loadtxt ('t.txt')
z = np.loadtxt ('h.txt')
x = np.loadtxt('d.txt',comments='#', delimiter='\t', converters = { 0 : strpdate2num('%Y-%m-%d %H:%M:%S') }, dtype=None)
np.putmask(y, y<20, np.nan)
np.putmask(y, y>50, np.nan)
np.putmask(z, z>98, np.nan)
np.putmask(z, z<20, np.nan)
plt.style.use('seaborn-white')
#plt.style.use('fivethirtyeight')
#plt.style.use('seaborn-white')
#plt.rcParams['font.family'] = 'serif'
#plt.rcParams['font.serif'] = 'Ubuntu'
#plt.rcParams['font.monospace'] = 'Ubuntu Mono'
plt.rcParams['font.size'] = 10
plt.rcParams['axes.labelsize'] = 10
plt.rcParams['axes.labelweight'] = 'bold'
plt.rcParams['axes.titlesize'] = 10
plt.rcParams['xtick.labelsize'] = 12
plt.rcParams['ytick.labelsize'] = 12
plt.rcParams['legend.fontsize'] = 10
plt.rcParams['figure.titlesize'] = 18
fig = plt.figure(figsize=(20,10))
#plt.subplot(2,1,1)
ax1 = fig.add_subplot(2,1,1,)
ax1.xaxis.set_minor_locator(minorLocator)
ax1.legend(loc=4, fontsize=10)
plt.setp(ax1.get_xticklabels(), visible=False)
plt.tick_params(which='both', width=2)
plt.tick_params(which='major', length=7)
plt.tick_params(which='minor', length=4)
plt.grid(b=True, which='both', color='0.65',linestyle='--')
ax1.xaxis.set_major_formatter(mdates.DateFormatter('%d/%m/%Y %H:%M'))
ax1.yaxis.grid(True, which='major')
ax1.yaxis.grid(True, which='minor')
ax1.get_xaxis().tick_bottom()
ax1.get_yaxis().tick_left()
ax1.plot(x, y, 'k-', linewidth=1)
ax2 = fig.add_subplot(2,1,2)
ax2.xaxis.set_minor_locator(minorLocator)
plt.setp(ax2.get_xticklabels(), fontsize=14,rotation=30)
plt.tick_params(which='both', width=2)
plt.tick_params(which='major', length=7)
plt.tick_params(which='minor', length=4)
plt.grid(b=True, which='both', color='0.65',linestyle='--')
ax2.grid(True)
ax2.xaxis.set_major_formatter(mdates.DateFormatter('%d/%m/%Y %H:%M'))
ax2.yaxis.grid(True, which='both')
ax2.xaxis.grid(True, which='major')
ax2.yaxis.grid(True, which='minor')
ax2.get_xaxis().tick_bottom()
ax2.get_yaxis().tick_left()
ax2.plot(x, z, 'r-', linewidth=1)
plt.grid()
plt.show() |