Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for changing colors in dag circuit drawer #13106

Open
nonhermitian opened this issue Sep 6, 2024 · 3 comments · May be fixed by #13253
Open

Allow for changing colors in dag circuit drawer #13106

nonhermitian opened this issue Sep 6, 2024 · 3 comments · May be fixed by #13253
Assignees
Labels
type: feature request New feature or request

Comments

@nonhermitian
Copy link
Contributor

What should we add?

It would be nice if we can change colors for the DAG drawer in a similar manner to the circuit drawer

@nonhermitian nonhermitian added the type: feature request New feature or request label Sep 6, 2024
@Shivansh20128
Copy link
Contributor

Hi @nonhermitian! I want to know more about this feature, and then maybe I can work on this.
I did some reading about both functions. The circuit_drawer function uses the "output" parameter and the "backgroundcolor" to add some colors to the graph.

The following code shows the usage of output parameter.

from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)
circuit_drawer(qc, output="mpl")

image

The following code shows the usage of style parameter with backgroundcolor specified (it gives a blue color for background).


from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
qc = QuantumCircuit(1, 1)
qc.h(0)
qc.measure(0, 0)
circuit_drawer(qc, output="mpl", style={"backgroundcolor":"#0000FF"})

image

If we talk about the DAG circuit drawer now, which uses the function dag_drawer, it does not have the output parameter, and relies only on the style parameter. The style parameter can take two values, plain and color.


from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit
from qiskit.dagcircuit import DAGCircuit
from qiskit.converters import circuit_to_dag
from qiskit.visualization import dag_drawer
 
q = QuantumRegister(3, 'q')
c = ClassicalRegister(3, 'c')
circ = QuantumCircuit(q, c)
circ.h(q[0])
circ.cx(q[0], q[1])
circ.measure(q[0], c[0])
circ.rz(0.5, q[1]).c_if(c, 2)

dag = circuit_to_dag(circ)
dag_drawer(dag, style="color")

image

Now, you have mentioned that we should be able to change colors in the DAG drawer like the way we can do it in the circuit drawer function. So, are you talking about changing the background color?
Thank You

@emilkovacev
Copy link
Contributor

I am interested in working on this, can I be assigned to this issue?

@Shivansh20128
Copy link
Contributor

Shivansh20128 commented Oct 1, 2024

🙄😅
I had already started looking into this, and have asked a question here too. So I request you to let me work with you on this.
Thank you

@emilkovacev emilkovacev linked a pull request Oct 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants