From 789734de518e2ba1b00f240b948d07ee369ba9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=C3=B4nio=20C=C3=A2ndido=20de=20Lima=20e=20Silva?= Date: Mon, 5 Oct 2020 10:28:53 -0300 Subject: [PATCH] Improvements in nonstationary.Utils.plot_sets --- pyFTS/models/nonstationary/util.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pyFTS/models/nonstationary/util.py b/pyFTS/models/nonstationary/util.py index 0d99d7f..fcf5dd0 100644 --- a/pyFTS/models/nonstationary/util.py +++ b/pyFTS/models/nonstationary/util.py @@ -7,7 +7,7 @@ from pyFTS.common import Membership, Util def plot_sets(partitioner, start=0, end=10, step=1, tam=[5, 5], colors=None, - save=False, file=None, axes=None, data=None, window_size = 1, only_lines=False): + save=False, file=None, axes=None, data=None, window_size = 1, only_lines=False, legend=True): range = np.arange(start,end,step) ticks = [] @@ -42,16 +42,17 @@ def plot_sets(partitioner, start=0, end=10, step=1, tam=[5, 5], colors=None, axes.set_ylabel("Universe of Discourse") axes.set_xlabel("Time") plt.xticks([k for k in range], ticks, rotation='vertical') - - handles0, labels0 = axes.get_legend_handles_labels() - lgd = axes.legend(handles0, labels0, loc=2, bbox_to_anchor=(1, 1)) + + if legend: + handles0, labels0 = axes.get_legend_handles_labels() + lgd = axes.legend(handles0, labels0, loc=2, bbox_to_anchor=(1, 1)) if data is not None: axes.plot(np.arange(start, start + len(data), 1), data,c="black") - plt.tight_layout() - - Util.show_and_save_image(fig, file, save) + if file is not None: + plt.tight_layout() + Util.show_and_save_image(fig, file, save) def plot_sets_conditional(model, data, step=1, size=[5, 5], colors=None,