'SchemDraw returns blank schematic when using logicparse
Python 3.8, Spyder IDE
I installed Schemdraw using,
pip install schemdraw[matplotlib]
I'm using the following code but all I get is a blank canvas,
import schemdraw
import schemdraw.elements as elm
from schemdraw import logic
from schemdraw.parsing import logicparse
with schemdraw.Drawing() as d:
logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$')
Also tried,
with schemdraw.Drawing() as d:
d = logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$')
d.draw()
Gives a blank canvas.
Also tried,
with schemdraw.Drawing() as d:
d.add(logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$'))
Also tried,
d = logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$')
d.draw()
Returns nothing not even a blank canvas.
This throws the following error,
Traceback (most recent call last):
File "D:\Python codes\temp.py", line 10, in <module>
d.add(logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$'))
File "D:\ProgramData\Anaconda3\lib\site-packages\schemdraw\schemdraw.py", line 233, in add
element = element(**kwargs)
TypeError: 'Drawing' object is not callable
I have also tried (after the imports) just,
logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$')
which gives no output at all. I have the lastest version of pyparse
installed.
Whereas the following simple circuit works fine,
with schemdraw.Drawing() as d:
d.add(elm.Resistor())
d.add(elm.Capacitor())
d.add(elm.Diode())
Is there something obvious missing here?
Solution 1:[1]
Try this:
from schemdraw.parsing import logicparse
drawing = logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$')
drawing.draw()
Solution 2:[2]
You could try:
with logicparse('not ((w and x) or (y and z))', outlabel='$\overline{Q}$'):
pass
logicparse returns a Drawing, so it doesn't work to put it inside a with schemdraw.Drawing
block. But somehow Spyder's console doesn't seem to pick up the Figure from Drawing.draw().
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MatLag |
Solution 2 | Collin |