def gate_width(axes, gate_str, plot_params):
    """
    Calculate the width of a gate based on its string representation.

    Args:
        axes (matplotlib.axes.Axes): axes object
        gate_str (str): string representation of a gate
        plot_params (dict): plot parameters

    Returns:
        The width of a gate on the figure (in inches)
    """
    if gate_str == 'X':
        return 2 * plot_params['not_radius'] / plot_params['units_per_inch']
    if gate_str == 'Swap':
        return 2 * plot_params['swap_delta'] / plot_params['units_per_inch']
    if gate_str == 'Measure':
        return plot_params['mgate_width']
    obj = axes.text(0, 0, gate_str, visible=True, bbox=dict(edgecolor='k',
        facecolor='w', fill=True, lw=1.0), fontsize=14)
    obj.figure.canvas.draw()
    width = obj.get_window_extent(obj.figure.canvas.get_renderer()
        ).width / axes.figure.dpi
    obj.remove()
    return width + 2 * plot_params['gate_offset']
