interplot.conf: Module Defaults Configuration¶
Modify the default behavior of the interplot package.
Example:
>>> # default behavior
... interplot.line(x, y)
>>> # modify default behavior
... interplot.conf.INTERACTIVE = False
... interplot.conf.COLOR_CYCLE[0] = "#000000"
... interplot.conf.DPI = 150
... interplot.conf.MPL_FIG_SIZE = (400, 400)
...
... # user-modified default behavior
... interplot.line(x, y)
VARIABLES¶
- interplot.conf.INTERACTIVE = True¶
Type:
bool
Generate a plotly figure by default.
- interplot.conf.COLOR_CYCLE = ['#006BA4', '#FF800E', '#ABABAB', '#595959', '#5F9ED1', '#C85200', '#898989', '#A2C8EC', '#FFBC79', '#CFCFCF']¶
Type:
list
Colors to be cycled through by default.
This default cycle is optimised for color vision deficiencies.
- interplot.conf.DPI = 100¶
Type:
int
Figure resolution in dots per inch.
- interplot.conf.PTY_FIG_SIZE = (None, 500)¶
Type:
tuple
Default figure size for the plotly backend, in px. Use None for adaptive size.
- interplot.conf.MPL_FIG_SIZE = (700, 450)¶
Type:
tuple
Default figure size for the matplotlib backend, in px.
- interplot.conf.EXPORT_FORMAT = 'png'¶
Type:
str
Default export format.
- interplot.conf.EXPORT_REPLACE = {'\n': '_', ' ': '-', '<.*?>': '', '<\\s*br\\s*/?\\s*>': '_', '[ ]?[/|\\\\][ ]?': '_', '[@!?,:;+*%&()=#|\'"<>]': '', '\\\\': '_', '\\s': '_'}¶
Type:
dict
Replace characters in the figure title to use as default filename.
Use a dictionary with regex patterns as keys and the (regex) replacement as values.
- interplot.conf.GLOBAL_CUSTOM_FUNC(fig)¶
Apply a custom function on figures on finishing the plot.
Will be called in interplot.Plot.post_process().
When overriding this function, make sure it accepts fig. There is no need to return fig.
- Parameters:
- fig: interplot.Plot instance
Examples
>>> def global_custom_func(fig): ... # do your customisations ... fig.add_text(0, 0, "watermark", color="gray") ... ... # also include default function ... conf.GLOBAL_CUSTOM_FUNC(fig) ... ... fig = interplot.Plot( ... global_custom_func=global_custom_func ... ) ... fig.add_line(x, y) ... fig.post_process() # global_custom_func will be executed here ... fig.show()
- interplot.conf.MPL_CUSTOM_FUNC(fig, ax)¶
Apply a custom function on matplotlib figures on finishing the plot.
Will be called in interplot.Plot.post_process().
When overriding this function, make sure it accepts fig and ax and returns fig and ax.
- Parameters:
- figmatplotlib.figure.Figure
The figure object.
- axmatplotlib.axes.Axes
The axes object.
- Returns:
- figmatplotlib.figure.Figure
The modified figure object.
- axmatplotlib.axes.Axes
The modified axes object.
Examples
>>> def mpl_custom_func(fig, ax): ... # do your customisations ... fig.do_stuff() ... ax[0, 0].do_more() ... ... # also include default function ... fig, ax = conf.MPL_CUSTOM_FUNC(fig, ax) ... ... return fig, ax ... ... fig = interplot.Plot( ... interactive=False, ... mpl_custom_func=mpl_custom_func ... ) ... fig.add_line(x, y) ... fig.post_process() # mpl_custom_func will be executed here ... fig.show()
- interplot.conf.PTY_CUSTOM_FUNC(fig)¶
Apply a custom function on plotly figures on finishing the plot.
Will be called in interplot.Plot.post_process().
When overriding this function, make sure it accepts fig and returns fig.
- Parameters:
- figplotly.graph_objects.Figure
The figure object.
- Returns:
- figplotly.graph_objects.Figure
The modified figure object.
Examples
>>> def pty_custom_func(fig): ... # do your customisations ... fig.do_stuff() ... ... # also include default function ... fig = conf.PTY_CUSTOM_FUNC(fig) ... ... return fig ... ... fig = interplot.Plot( ... interactive=True, ... pty_custom_func=pty_custom_func ... ) ... fig.add_line(x, y) ... fig.post_process() # pty_custom_func will be executed here ... fig.show()
- interplot.conf.PTY_CONFIG = {'displayModeBar': True, 'displaylogo': False}¶
Type:
dict
Modify the layout of the plotly figure.
See https://plotly.com/python/reference/layout/ for reference.
- interplot.conf.PTY_LINE_STYLES = {'-': 'solid', '--': 'dash', '-.': 'dashdot', ':': 'dot', 'dashdot': 'dashdot', 'dashed': 'dash', 'dotted': 'dot', 'solid': 'solid'}¶
Type:
dict
Mapping for line styles for plotly.
- interplot.conf.MPL_LINE_STYLES = {'dash': 'dashed', 'dashdot': 'dashdot', 'dot': 'dotted', 'solid': 'solid'}¶
Type:
dict
Mapping for line styles for matplotlib.
- interplot.conf.PTY_MARKERS = {'.': 'circle', 's': 'square', 'D': 'diamond', 'P': 'cross', 'X': 'x', '^': 'triangle-up', 'v': 'triangle-down', '<': 'triangle-left', '>': 'triangle-right', 'triangle-ne': 'triangle-ne', 'triangle-se': 'triangle-se', 'triangle-sw': 'triangle-sw', 'triangle-nw': 'triangle-nw', 'p': 'pentagon', 'h': 'hexagon', 'H': 'hexagon2', '8': 'octagon', '*': 'star', 'hexagram': 'hexagram', 'star-triangle-up': 'star-triangle-up', 'star-triangle-down': 'star-triangle-down', 'star-square': 'star-square', 'star-diamond': 'star-diamond', 'd': 'diamond-tall', 'diamond-wide': 'diamond-wide', 'hourglass': 'hourglass', 'bowtie': 'bowtie', 'circle-cross': 'circle-cross', 'circle-x': 'circle-x', 'square-cross': 'square-cross', 'square-x': 'square-x', 'diamond-cross': 'diamond-cross', 'diamond-x': 'diamond-x', '+': 'cross-thin', 'x': 'x-thin', 'asterisk': 'asterisk', 'hash': 'hash', '2': 'y-up', '1': 'y-down', '3': 'y-left', '4': 'y-right', '_': 'line-ew', '|': 'line-ns', 'line-ne': 'line-ne', 'line-nw': 'line-nw', 6: 'arrow-up', 7: 'arrow-down', 4: 'arrow-left', 5: 'arrow-right', 'arrow-bar-up': 'arrow-bar-up', 'arrow-bar-down': 'arrow-bar-down', 'arrow-bar-left': 'arrow-bar-left', 'arrow-bar-right': 'arrow-bar-right', 'arrow': 'arrow', 'arrow-wide': 'arrow-wide'}¶
Type:
dict
Mapping for marker styles for plotly.
- interplot.conf.PTY_MARKERS_LIST = ['circle', 'square', 'diamond', 'cross', 'x', 'triangle-up', 'triangle-down', 'triangle-left', 'triangle-right', 'triangle-ne', 'triangle-se', 'triangle-sw', 'triangle-nw', 'pentagon', 'hexagon', 'hexagon2', 'octagon', 'star', 'hexagram', 'star-triangle-up', 'star-triangle-down', 'star-square', 'star-diamond', 'diamond-tall', 'diamond-wide', 'hourglass', 'bowtie', 'circle-cross', 'circle-x', 'square-cross', 'square-x', 'diamond-cross', 'diamond-x', 'cross-thin', 'x-thin', 'asterisk', 'hash', 'y-up', 'y-down', 'y-left', 'y-right', 'line-ew', 'line-ns', 'line-ne', 'line-nw', 'arrow-up', 'arrow-down', 'arrow-left', 'arrow-right', 'arrow-bar-up', 'arrow-bar-down', 'arrow-bar-left', 'arrow-bar-right', 'arrow', 'arrow-wide']¶
Type:
list
Possible line styles for plotly.
- interplot.conf.MPL_MARKERS = {'arrow': 6, 'arrow-bar-down': 7, 'arrow-bar-left': 4, 'arrow-bar-right': 5, 'arrow-bar-up': 6, 'arrow-down': 7, 'arrow-left': 4, 'arrow-right': 5, 'arrow-up': 6, 'arrow-wide': 6, 'asterisk': '*', 'bowtie': 'D', 'circle': '.', 'circle-cross': '+', 'circle-x': 'x', 'cross': 'P', 'cross-thin': '+', 'diamond': 'D', 'diamond-cross': 'D', 'diamond-tall': 'd', 'diamond-wide': 'D', 'diamond-x': 'D', 'hash': '*', 'hexagon': 'h', 'hexagon2': 'H', 'hexagram': '*', 'hourglass': 'd', 'line-ew': '_', 'line-ne': '|', 'line-ns': '|', 'line-nw': '_', 'octagon': '8', 'pentagon': 'p', 'square': 's', 'square-cross': 's', 'square-x': 's', 'star': '*', 'star-diamond': 'D', 'star-square': 's', 'star-triangle-down': 'v', 'star-triangle-up': '^', 'triangle-down': 'v', 'triangle-left': '<', 'triangle-ne': '>', 'triangle-nw': '^', 'triangle-right': '>', 'triangle-se': 'v', 'triangle-sw': '<', 'triangle-up': '^', 'x': 'X', 'x-thin': 'x', 'y-down': '1', 'y-left': '3', 'y-right': '4', 'y-up': '2'}¶
Type:
dict
Mapping for marker styles for matplotlib.