Utilities

For basic functions

source

get_colors

 get_colors (subsets:list, cmap_subsets:str=None, test:bool=False)

*Get colors by items

Args: subsets (list): list of items cmap_subsets (str, optional): colormap. Defaults to None. test (bool, optional): test-mode. Defaults to False.

Returns: dict: colors by items*


source

export_plot

 export_plot (spec:dict, outp:str, redirect=None, hyperlink=None,
              verbose=False)

*Export the vega plot

Args: spec (dict): vega config outp (str): output path redirect: for redirecting the outputs displayed*


source

display_plot

 display_plot (spec:dict, method:str='vega', defaults:dict=None)

*Display plot

Args: spec (dict): vega config method (str, optional): method. Defaults to ‘vega’.*

Type Default Details
spec dict
method str vega vegalite
defaults dict None

source

get_src_path

 get_src_path (pkg_name='parag')

*Get the package’s source directory path.

Returns: str: path*

get_src_path(
    'parag'
    )
WARNING:root:package is installed in the development mode
WARNING:root:running the function in a nbdev nb
'.'
display_plot({
  # "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "description": "A simple bar chart with embedded data.",
  "data": {
    "values": [
      {"a": "A", "b": 28}, {"a": "B", "b": 55}, {"a": "C", "b": 43},
      {"a": "D", "b": 91}, {"a": "E", "b": 81}, {"a": "F", "b": 53},
      {"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {"field": "a", "type": "nominal", "axis": {"labelAngle": 0}},
    "y": {"field": "b", "type": "quantitative"}
  }
}
)
get_colors(
    subsets=range(5),
    cmap_subsets=None,
    test=True,
    )
{0: '#0173b2', 1: '#de8f05', 2: '#029e73', 3: '#d55e00', 4: '#cc78bc'}