From 95a0bc1531565e1098024f6b2fe576baa99b184a Mon Sep 17 00:00:00 2001 From: Arief Anbiya <35247692+anbarief@users.noreply.github.com> Date: Fri, 4 Mar 2022 22:47:58 +0700 Subject: [PATCH 1/6] Removed `if (plottype not in _valid_types_all) ... ` This is unnecessary because the kwarg validator already check whether `kwarg['type']` is in `_valid_types_all`. So if the value passed the validator then it must be in `_valid_types_all`. So we don't need to check again in function `_get_valid_plot_types` (unless...this function is used also by function other than `plotting.plot`) --- src/mplfinance/_arg_validators.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/mplfinance/_arg_validators.py b/src/mplfinance/_arg_validators.py index 268fe855..98a78947 100644 --- a/src/mplfinance/_arg_validators.py +++ b/src/mplfinance/_arg_validators.py @@ -93,13 +93,9 @@ def _get_valid_plot_types(plottype=None): if plottype is None: return _valid_types_all - - if plottype not in _valid_types_all: - return None elif plottype in _alias_types: return _alias_types[plottype] - else: - return plottype + return plottype def _mav_validator(mav_value): From 1b3a5abd57351e047f4ff561d3e2ddf79f99cd8f Mon Sep 17 00:00:00 2001 From: Arief Anbiya <35247692+anbarief@users.noreply.github.com> Date: Tue, 8 Mar 2022 16:27:40 +0700 Subject: [PATCH 2/6] Update _panels.py --- src/mplfinance/_panels.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mplfinance/_panels.py b/src/mplfinance/_panels.py index cf4d8956..0ee8a156 100644 --- a/src/mplfinance/_panels.py +++ b/src/mplfinance/_panels.py @@ -63,7 +63,6 @@ def _build_panels( figure, config ): addplot = config['addplot'] volume = config['volume'] volume_panel = config['volume_panel'] - num_panels = config['num_panels'] main_panel = config['main_panel'] panel_ratios = config['panel_ratios'] From f58d1780d435d8a33310f06673a1daad421ffcee Mon Sep 17 00:00:00 2001 From: Arief Anbiya <35247692+anbarief@users.noreply.github.com> Date: Sun, 27 Mar 2022 18:00:08 +0700 Subject: [PATCH 3/6] Fixing comments of max. number of panels Previously the comments say the max number of panels is 10. So I fixed it to be consistent with the current version, max. panels equal 32. --- src/mplfinance/_panels.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/mplfinance/_panels.py b/src/mplfinance/_panels.py index 0ee8a156..7d8524a2 100644 --- a/src/mplfinance/_panels.py +++ b/src/mplfinance/_panels.py @@ -22,16 +22,16 @@ def _build_panels( figure, config ): ------ The following items are used from `config`: - num_panels : integer (0-9) or None + num_panels : integer (0-31) or None number of panels to create addplot : dict or None value for the `addplot=` kwarg passed into `mplfinance.plot()` - volume_panel : integer (0-9) or None + volume_panel : integer (0-31) or None panel id (0-number_of_panels) - main_panel : integer (0-9) or None + main_panel : integer (0-31) or None panel id (0-number_of_panels) panel_ratios : sequence or None @@ -63,11 +63,12 @@ def _build_panels( figure, config ): addplot = config['addplot'] volume = config['volume'] volume_panel = config['volume_panel'] + num_panels = config['num_panels'] main_panel = config['main_panel'] panel_ratios = config['panel_ratios'] if not _valid_panel_id(main_panel): - raise ValueError('main_panel id must be integer 0 to 9, but is '+str(main_panel)) + raise ValueError('main_panel id must be integer 0 to 31, but is '+str(main_panel)) if num_panels is None: # then infer the number of panels: pset = {0} # start with a set including only panel zero @@ -84,12 +85,12 @@ def _build_panels( figure, config ): if panel in backwards_panel_compatibility: panel = backwards_panel_compatibility[panel] if not _valid_panel_id(panel): - raise ValueError('addplot panel must be integer 0 to 9, but is "'+str(panel)+'"') + raise ValueError('addplot panel must be integer 0 to 31, but is "'+str(panel)+'"') pset.add(panel) if volume is True: if not _valid_panel_id(volume_panel): - raise ValueError('volume_panel must be integer 0 to 9, but is "'+str(volume_panel)+'"') + raise ValueError('volume_panel must be integer 0 to 31, but is "'+str(volume_panel)+'"') pset.add(volume_panel) pset.add(main_panel) From 7234f2fd05137994e52c18c017b65ab613fba962 Mon Sep 17 00:00:00 2001 From: Arief Anbiya <35247692+anbarief@users.noreply.github.com> Date: Sun, 27 Mar 2022 18:01:10 +0700 Subject: [PATCH 4/6] Update _version.py --- src/mplfinance/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mplfinance/_version.py b/src/mplfinance/_version.py index 4a6dfc24..52fc2ea2 100644 --- a/src/mplfinance/_version.py +++ b/src/mplfinance/_version.py @@ -1,5 +1,5 @@ -version_info = (0, 12, 8, 'beta', 9) +version_info = (0, 12, 8, 'beta', 10) _specifier_ = {'alpha': 'a','beta': 'b','candidate': 'rc','final': ''} From d674480766a1e675d77f33237d74c7741b16f694 Mon Sep 17 00:00:00 2001 From: Arief Anbiya <35247692+anbarief@users.noreply.github.com> Date: Sun, 27 Mar 2022 18:04:23 +0700 Subject: [PATCH 5/6] Feature request #510 to show only specific figure created in plotting.py instead of using plt.show we use fig.show. #510 --- src/mplfinance/plotting.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mplfinance/plotting.py b/src/mplfinance/plotting.py index 2d816fe2..82d72c27 100644 --- a/src/mplfinance/plotting.py +++ b/src/mplfinance/plotting.py @@ -855,18 +855,18 @@ def plot( data, **kwargs ): save = config['savefig'] if isinstance(save,dict): if config['tight_layout'] and 'bbox_inches' not in save: - plt.savefig(**save,bbox_inches='tight') + fig.savefig(**save,bbox_inches='tight') else: - plt.savefig(**save) + fig.savefig(**save) else: if config['tight_layout']: - plt.savefig(save,bbox_inches='tight') + fig.savefig(save,bbox_inches='tight') else: - plt.savefig(save) + fig.savefig(save) if config['closefig']: # True or 'auto' plt.close(fig) elif not config['returnfig']: - plt.show(block=config['block']) # https://stackoverflow.com/a/13361748/1639359 + fig.show() # https://stackoverflow.com/a/13361748/1639359 if config['closefig'] == True or (config['block'] and config['closefig']): plt.close(fig) From 4ceafac708a2dd0bc9df9fa2694db9cbd5c7e738 Mon Sep 17 00:00:00 2001 From: Daniel Goldfarb Date: Tue, 26 Apr 2022 15:52:12 -0400 Subject: [PATCH 6/6] restore `plt.show()`, because `fig.show()` is NOT equivalent. --- src/mplfinance/plotting.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mplfinance/plotting.py b/src/mplfinance/plotting.py index 82d72c27..6b45958e 100644 --- a/src/mplfinance/plotting.py +++ b/src/mplfinance/plotting.py @@ -866,7 +866,7 @@ def plot( data, **kwargs ): if config['closefig']: # True or 'auto' plt.close(fig) elif not config['returnfig']: - fig.show() # https://stackoverflow.com/a/13361748/1639359 + plt.show(block=config['block']) # https://stackoverflow.com/a/13361748/1639359 if config['closefig'] == True or (config['block'] and config['closefig']): plt.close(fig)