From 6a2d9fb72d9ac1cd558ad6b83e66d67a2a802b79 Mon Sep 17 00:00:00 2001 From: jitendracandela Date: Wed, 28 Jul 2021 22:28:56 +0530 Subject: [PATCH] added legend location,legend column,legend fontsize,legend box --- py-scripts/lf_graph.py | 12 +++++++++++- py-scripts/lf_report_test.py | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/py-scripts/lf_graph.py b/py-scripts/lf_graph.py index 9575989b..e01fe19e 100755 --- a/py-scripts/lf_graph.py +++ b/py-scripts/lf_graph.py @@ -53,6 +53,11 @@ class lf_bar_graph(): _text_font=None, _text_rotation=None, _grp_title = "", + _legend_handles=None, + _legend_loc="best", + _legend_box=None, + _legend_ncol=1, + _legend_fontsize=None, _dpi=96, _enable_csv=False): @@ -79,6 +84,11 @@ class lf_bar_graph(): self.grp_title = _grp_title self.enable_csv = _enable_csv self.lf_csv = lf_csv() + self.legend_handles = _legend_handles + self.legend_loc = _legend_loc + self.legend_box = _legend_box + self.legend_ncol = _legend_ncol + self.legend_fontsize = _legend_fontsize def build_bar_graph(self): if self.color is None: @@ -121,7 +131,7 @@ class lf_bar_graph(): else: plt.xticks(np.arange(0, len(self.data_set[0]), step=self.xaxis_step), self.xaxis_categories, fontsize = self.xticks_font) - plt.legend() + plt.legend(handles=self.legend_handles, loc=self.legend_loc, bbox_to_anchor=self.legend_box, ncol=self.legend_ncol, fontsize=self.legend_fontsize) plt.suptitle(self.title, fontsize=self.title_size) plt.title(self.grp_title) fig = plt.gcf() diff --git a/py-scripts/lf_report_test.py b/py-scripts/lf_report_test.py index adedf1f9..8c1af448 100755 --- a/py-scripts/lf_report_test.py +++ b/py-scripts/lf_report_test.py @@ -103,7 +103,11 @@ if __name__ == "__main__": _show_bar_value=True, _text_font=7, _text_rotation=45, - _xticks_font=7) + _xticks_font=7, + _legend_loc="best", + _legend_box=(1,1), + _legend_ncol=1, + _legend_fontsize=None) graph_png = graph.build_bar_graph()