Skip to content

Added dpi option to plot command even outside savefig option #678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/mplfinance/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ def _valid_plot_kwargs():
and isinstance(value[0],(float,int))
and isinstance(value[1],(float,int)) },

'dpi' : { 'Default' : None, # Set the resolution of the figure in dots-per-inch.
'Description' : 'Set the resolution of the figure in dots-per-inch',
'Validator' : lambda value: isinstance(value,float) or isinstance(value,int) },

'fontscale' : { 'Default' : None, # scale all fonts up or down
'Description' : 'Scale font sizes up (if > 1) or down (if < 1)',
'Validator' : lambda value: isinstance(value,float) or isinstance(value,int) },
Expand Down Expand Up @@ -444,6 +448,11 @@ def plot( data, **kwargs ):
'\n\n WARNING: `figsize` has NO effect in External Axes Mode.'+
'\n\n ================================================================ ',
category=UserWarning)
if config['dpi'] is not None:
warnings.warn('\n\n ================================================================= '+
'\n\n WARNING: `dpi` has NO effect in External Axes Mode.'+
'\n\n ================================================================ ',
category=UserWarning)
else:
if config['figscale'] is None: config['figscale'] = 1.0
if config['figratio'] is None: config['figratio'] = DEFAULT_FIGRATIO
Expand Down Expand Up @@ -1012,6 +1021,8 @@ def _adjust_figsize(fig,config):
else:
fsize = config['figsize']
fig.set_size_inches(fsize)
if not config['dpi'] is None:
fig.set_dpi(config['dpi'])

def _adjust_fontsize(config):
if config['fontscale'] is None:
Expand Down