Skip to content

Matplotlib-like functions

Matplotlib-like functions for easy figure and plot definitions

close(figure_ref)

Closes the provided figure and deletes it

Source code in mlpyqtgraph/ml_functions.py
def close(figure_ref):
    """ Closes the provided figure and deletes it """
    gcf().close(figure_ref)

figure(*args, **kwargs)

Create, raise or modify FigureWorker objects

Source code in mlpyqtgraph/ml_functions.py
def figure(*args, **kwargs):
    """ Create, raise or modify FigureWorker objects """
    container = refs.worker.get('figure')
    if not args:
        return container.create(**kwargs)
    figure_worker = args[0]
    figure_worker.activate()
    container.current = figure_worker
    return figure_worker

gca()

Returns the current axis

Source code in mlpyqtgraph/ml_functions.py
def gca():
    """ Returns the current axis """
    container = refs.worker.get('axis')
    if container.current is None:
        figure()  # make sure we always have a figure
    return container.current

gcf()

Returns the current figure

Source code in mlpyqtgraph/ml_functions.py
def gcf():
    """ Returns the current figure """
    container = refs.worker.get('figure')
    if container.current is None:
        figure()  # make sure we always have a figure
    return container.current

legend(*args)

Adds a legend to the current figure

Source code in mlpyqtgraph/ml_functions.py
def legend(*args):
    """ Adds a legend to the current figure """
    gca().add_legend(*args)

plot(*args, **kwargs)

Plots into the current axis

Source code in mlpyqtgraph/ml_functions.py
def plot(*args, **kwargs):
    """ Plots into the current axis """
    gcf().create_axis(axis_type='2D')
    return gca().add(*args, **kwargs)

plot3(*args, **kwargs)

Plots a 3D line

Source code in mlpyqtgraph/ml_functions.py
def plot3(*args, **kwargs):
    """ Plots a 3D line """
    gcf().change_layout('Qt')
    gcf().create_axis(axis_type='3D')
    gca().line(*args, **kwargs)

surf(*args, **kwargs)

Plots a 3D surface

Source code in mlpyqtgraph/ml_functions.py
def surf(*args, **kwargs):
    """ Plots a 3D surface """
    gcf().change_layout('Qt')
    gcf().create_axis(axis_type='3D')
    gca().surf(*args, **kwargs)