module plotting.plot_helper

Short summary

module pymlbenchmark.plotting.plot_helper

Plotting helpers

source on GitHub

Functions

function

truncated documentation

ax_position

matplotlib uses a one dimension array if the number of columns or rows is 1. This function makes a correction. …

filter_df_options

Filters out rows from a dataframe.

list_col_options

move_color

Returns a different colors, lighter or darker.

move_color_add

Makes color lighter or darker based on a style.

options2label

Converts a list of options into a label.

plt_colors

Returns matplotlib colors.

plt_styles

Returns matplotlib styles.

remove_common_prefix

Removes the common prefix of a series of labels.

Documentation

Plotting helpers

source on GitHub

pymlbenchmark.plotting.plot_helper.ax_position(shape, pos)

matplotlib uses a one dimension array if the number of columns or rows is 1. This function makes a correction.

Parameters:
  • shape – graph shape

  • pos – graph current position

Returns:

corrected position

<<<

from pymlbenchmark.plotting.plot_helper import ax_position
print(ax_position((2, 2), (0, 0)))
print(ax_position((1, 2), (0, 0)))

>>>

    (0, 0)
    (0,)

source on GitHub

pymlbenchmark.plotting.plot_helper.filter_df_options(df, options)

Filters out rows from a dataframe.

Parameters:
  • df – dataframe

  • options – options

Returns:

filtered dataframe

<<<

from pymlbenchmark.plotting.plot_helper import filter_df_options
from pandas import DataFrame
df = DataFrame([
    dict(i=1, t='aa', x=0.5),
    dict(i=2, t='bb', x=0.5),
    dict(i=2, t='aa', x=0.5),
])

sub = filter_df_options(df, {'i': 1, 't': 'aa'})
print(sub)

sub = filter_df_options(df, [None])
print(sub)

>>>

       i   t    x
    0  1  aa  0.5
       i   t    x
    0  1  aa  0.5
    1  2  bb  0.5
    2  2  aa  0.5

source on GitHub

pymlbenchmark.plotting.plot_helper.list_col_options(df, cols)
Parameters:
  • df – dataframe

  • cols – cols to look for options

Returns:

options

Enumerate all coordinates

<<<

from pymlbenchmark.plotting.plot_helper import list_col_options
from pandas import DataFrame
df = DataFrame([
    dict(i=1, t='aa', x=0.5),
    dict(i=2, t='bb', x=0.5),
    dict(i=2, t='aa', x=0.5),
])
for opt in list_col_options(df, ['i', 't']):
    print(opt)

# if None...
print(list_col_options(df, None))

>>>

    {'i': 1, 't': 'aa'}
    {'i': 1, 't': 'bb'}
    {'i': 2, 't': 'aa'}
    {'i': 2, 't': 'bb'}
    [None]

source on GitHub

pymlbenchmark.plotting.plot_helper.move_color(color, add=2)

Returns a different colors, lighter or darker.

Parameters:
  • color – name of something starting with #

  • add – what to add to each color, positive to make it lighter

Returns:

lighter column

source on GitHub

pymlbenchmark.plotting.plot_helper.move_color_add(style)

Makes color lighter or darker based on a style.

source on GitHub

pymlbenchmark.plotting.plot_helper.options2label(opt, sep=' ', format_number='{:.3g}')

Converts a list of options into a label.

Parameters:
  • opt – dictionary

  • sep – separator

  • format_number – how to format real numbers

Returns:

string

<<<

from pymlbenchmark.plotting.plot_helper import options2label
res = options2label({'i': 1, 't': 'aa', 'x': 3.145667e10})
print(res)

>>>

    i=1 t=aa x=3.15e+10

source on GitHub

pymlbenchmark.plotting.plot_helper.plt_colors()

Returns matplotlib colors.

<<<

from pymlbenchmark.plotting.plot_helper import plt_colors
from pprint import pprint
pprint(plt_colors())

>>>

    ['blue',
     'orange',
     'green',
     'red',
     'purple',
     'brown',
     'pink',
     'gray',
     'olive',
     'cyan',
     'aliceblue',
     'antiquewhite',
     'aqua',
     'aquamarine',
     'azure',
     'beige',
     'bisque',
     'black',
     'blanchedalmond',
     'blue',
     'blueviolet',
     'brown',
     'burlywood',
     'cadetblue',
     'chartreuse',
     'chocolate',
     'coral',
     'cornflowerblue',
     'cornsilk',
     'crimson',
     'cyan',
     'darkblue',
     'darkcyan',
     'darkgoldenrod',
     'darkgray',
     'darkgreen',
     'darkgrey',
     'darkkhaki',
     'darkmagenta',
     'darkolivegreen',
     'darkorange',
     'darkorchid',
     'darkred',
     'darksalmon',
     'darkseagreen',
     'darkslateblue',
     'darkslategray',
     'darkslategrey',
     'darkturquoise',
     'darkviolet',
     'deeppink',
     'deepskyblue',
     'dimgray',
     'dimgrey',
     'dodgerblue',
     'firebrick',
     'floralwhite',
     'forestgreen',
     'fuchsia',
     'gainsboro',
     'ghostwhite',
     'gold',
     'goldenrod',
     'gray',
     'green',
     'greenyellow',
     'grey',
     'honeydew',
     'hotpink',
     'indianred',
     'indigo',
     'ivory',
     'khaki',
     'lavender',
     'lavenderblush',
     'lawngreen',
     'lemonchiffon',
     'lightblue',
     'lightcoral',
     'lightcyan',
     'lightgoldenrodyellow',
     'lightgray',
     'lightgreen',
     'lightgrey',
     'lightpink',
     'lightsalmon',
     'lightseagreen',
     'lightskyblue',
     'lightslategray',
     'lightslategrey',
     'lightsteelblue',
     'lightyellow',
     'lime',
     'limegreen',
     'linen',
     'magenta',
     'maroon',
     'mediumaquamarine',
     'mediumblue',
     'mediumorchid',
     'mediumpurple',
     'mediumseagreen',
     'mediumslateblue',
     'mediumspringgreen',
     'mediumturquoise',
     'mediumvioletred',
     'midnightblue',
     'mintcream',
     'mistyrose',
     'moccasin',
     'navajowhite',
     'navy',
     'oldlace',
     'olive',
     'olivedrab',
     'orange',
     'orangered',
     'orchid',
     'palegoldenrod',
     'palegreen',
     'paleturquoise',
     'palevioletred',
     'papayawhip',
     'peachpuff',
     'peru',
     'pink',
     'plum',
     'powderblue',
     'purple',
     'rebeccapurple',
     'red',
     'rosybrown',
     'royalblue',
     'saddlebrown',
     'salmon',
     'sandybrown',
     'seagreen',
     'seashell',
     'sienna',
     'silver',
     'skyblue',
     'slateblue',
     'slategray',
     'slategrey',
     'snow',
     'springgreen',
     'steelblue',
     'tan',
     'teal',
     'thistle',
     'tomato',
     'turquoise',
     'violet',
     'wheat',
     'white',
     'whitesmoke',
     'yellow',
     'yellowgreen']

source on GitHub

pymlbenchmark.plotting.plot_helper.plt_styles()

Returns matplotlib styles.

<<<

from pymlbenchmark.plotting.plot_helper import plt_styles
from pprint import pprint
pprint(plt_styles())

>>>

    [('o', '-'),
     ('x', '-'),
     ('*', '-'),
     ('^', '-'),
     ('o', '--'),
     ('x', '--'),
     ('*', '--'),
     ('^', '--')]

source on GitHub

pymlbenchmark.plotting.plot_helper.remove_common_prefix(labels, drop_rename=None)

Removes the common prefix of a series of labels.

Parameters:
  • labels – labels

  • drop_rename – skips those labels

Returns:

stripped labels

<<<

from pymlbenchmark.plotting.plot_helper import remove_common_prefix
labels = ["x=a", "x=b"]
print(remove_common_prefix(labels))

>>>

    ['a', 'b']

source on GitHub