2016-12-26 18:06:54 +04:00
|
|
|
import numpy as np
|
|
|
|
import pandas as pd
|
|
|
|
import matplotlib as plt
|
|
|
|
import matplotlib.colors as pltcolors
|
|
|
|
import matplotlib.pyplot as plt
|
|
|
|
from mpl_toolkits.mplot3d import Axes3D
|
2017-01-20 19:51:20 +04:00
|
|
|
from pyFTS.common import Membership, Util
|
2016-12-26 18:06:54 +04:00
|
|
|
|
2016-12-27 00:25:59 +04:00
|
|
|
|
2017-01-20 19:51:20 +04:00
|
|
|
def plotSets(data, sets, titles, tam=[12, 10], save=False, file=None):
|
2016-12-26 23:13:19 +04:00
|
|
|
num = len(sets)
|
2017-01-21 06:38:32 +04:00
|
|
|
#fig = plt.figure(figsize=tam)
|
2016-12-26 18:06:54 +04:00
|
|
|
maxx = max(data)
|
|
|
|
minx = min(data)
|
2017-01-21 06:38:32 +04:00
|
|
|
#h = 1/num
|
|
|
|
#print(h)
|
|
|
|
fig, axes = plt.subplots(nrows=num, ncols=1,figsize=tam)
|
|
|
|
for k in np.arange(0,num):
|
|
|
|
#ax = fig.add_axes([0.05, 1-(k*h), 0.9, h*0.7]) # left, bottom, width, height
|
|
|
|
ax = axes[k]
|
|
|
|
ax.set_title(titles[k])
|
|
|
|
ax.set_ylim([0, 1])
|
|
|
|
ax.set_xlim([minx, maxx])
|
2016-12-26 18:06:54 +04:00
|
|
|
for s in sets[k]:
|
|
|
|
if s.mf == Membership.trimf:
|
2017-01-21 06:38:32 +04:00
|
|
|
ax.plot([s.parameters[0],s.parameters[1],s.parameters[2]],[0,1,0])
|
2016-12-26 18:46:29 +04:00
|
|
|
elif s.mf == Membership.gaussmf:
|
|
|
|
tmpx = [ kk for kk in np.arange(s.lower, s.upper)]
|
|
|
|
tmpy = [s.membership(kk) for kk in np.arange(s.lower, s.upper)]
|
2017-01-21 06:38:32 +04:00
|
|
|
ax.plot(tmpx, tmpy)
|
|
|
|
|
|
|
|
plt.tight_layout()
|
2017-01-20 19:51:20 +04:00
|
|
|
|
|
|
|
Util.showAndSaveImage(fig, file, save)
|