def add_to_toolbar(fig, *widgets):
    """
    Adds a set of button-like widgets to the toolbar of a given figure.

    :param fig: a ``plt.Figure``
    :param widgets: A number of class names that extend
      ``mpl.backend_tools.ToolBase``. They must have at least defind the
      ``name`` and ``tool_group`` fields.
    """
    manager = fig.canvas.manager
    tm = manager.toolmanager
    for w in widgets:
        tm.add_tool(w.name, w)
        manager.toolbar.add_tool(tm.get_tool(w.name), w.tool_group)
