qiskit/visualization/circuit_visualization.py
def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=False,
                         plotbarriers=True, justify=None, vertically_compressed=True):
    """
    Draws a circuit using ascii art.
    Args:
        circuit (QuantumCircuit): Input circuit
        filename (str): optional filename to write the result
        line_length (int): Optional. Breaks the circuit drawing to this length. This
                   useful when the drawing does not fit in the console. If
                   None (default), it will try to guess the console width using
                   shutil.get_terminal_size(). If you don't want pagination
                   at all, set line_length=-1.
        reverse_bits (bool): Rearrange the bits in reverse order.
        plotbarriers (bool): Draws the barriers when they are there.
        justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
                        the circuit should be justified.
        vertically_compressed (bool): Default is `True`. It merges the lines so the
                                      drawing will take less vertical room.
    Returns:
        TextDrawing: An instances that, when printed, draws the circuit in ascii art.
    """
    qregs, cregs, ops = utils._get_layered_instructions(circuit,
                                                        reverse_bits=reverse_bits,
                                                        justify=justify)
    text_drawing = _text.TextDrawing(qregs, cregs, ops)
    text_drawing.plotbarriers = plotbarriers
    text_drawing.line_length = line_length
    text_drawing.vertically_compressed = vertically_compressed

    if filename:
        text_drawing.dump(filename)
    return text_drawing
def _text_circuit_drawer(circuit, filename=None, line_length=None, reverse_bits=False,
                         plotbarriers=True, justify=None, vertically_compressed=True):
    """
    Draws a circuit using ascii art.
    Args:
        circuit (QuantumCircuit): Input circuit
        filename (str): optional filename to write the result
        line_length (int): Optional. Breaks the circuit drawing to this length. This
                   useful when the drawing does not fit in the console. If
                   None (default), it will try to guess the console width using
                   shutil.get_terminal_size(). If you don't want pagination
                   at all, set line_length=-1.
        reverse_bits (bool): Rearrange the bits in reverse order.
        plotbarriers (bool): Draws the barriers when they are there.
        justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
                        the circuit should be justified.
        vertically_compressed (bool): Default is `True`. It merges the lines so the
                                      drawing will take less vertical room.
    Returns:
        TextDrawing: An instances that, when printed, draws the circuit in ascii art.
    """
    qregs, cregs, ops = utils._get_layered_instructions(circuit,
                                                        reverse_bits=reverse_bits,
                                                        justify=justify)
    text_drawing = _text.TextDrawing(qregs, cregs, ops)
    text_drawing.plotbarriers = plotbarriers
    text_drawing.line_length = line_length
    text_drawing.vertically_compressed = vertically_compressed

    if filename:
        text_drawing.dump(filename)
    return text_drawing
Draws a circuit using ascii art.
    Args:
        circuit (QuantumCircuit): Input circuit
        filename (str): optional filename to write the result
        line_length (int): Optional. Breaks the circuit drawing to this length. This
                   useful when the drawing does not fit in the console. If
                   None (default), it will try to guess the console width using
                   shutil.get_terminal_size(). If you don't want pagination
                   at all, set line_length=-1.
        reverse_bits (bool): Rearrange the bits in reverse order.
        plotbarriers (bool): Draws the barriers when they are there.
        justify (str) : `left`, `right` or `none`. Defaults to `left`. Says how
                        the circuit should be justified.
        vertically_compressed (bool): Default is `True`. It merges the lines so the
                                      drawing will take less vertical room.
    Returns:
        TextDrawing: An instances that, when printed, draws the circuit in ascii art.