Future home RonSheely Home Page
ronsheely / schemdraw Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Is there a way to add a font file so that we can configure schemdraw with a custom font ? If not what are the supported fonts ?
Thank you!
The save function doesn't work for jpg/png file types (svg does work). The resulting file types are corrupted.
To duplicate try the following for png or jpgs:
import schemdraw
from schemdraw import flow
with schemdraw.Drawing() as d:
d += flow.Start().label('START')
d += flow.Arrow().down(d.unit/3)
d.save('test.png')
Hello,
I have series of questions. Can you please help me solve these issues please?
- Is there any way of converting the schemdraw's draw canvas to the opencv image?
- Is there anyway that I can get the bounding box co-ordinates for each of the element from schemdraw schematic?
- I am confused with the default schemdraw schematic canvas type. How can I cange it to the matplotlib as backend?
SwitchSpdt(action=open) is not showing any arrow in the digaram and showing this error: NameError: name 'close' is not defined with SwitchSpdt(action=close)
Any idea why nodes 3, 4, and 5 are not in the same x-axis position as nodes 0, 1, and 2 are?
import schemdraw
import schemdraw.elements as elm
from schemdraw import flow
edge = [(0,2), (1, 2), (2, 3), (3, 4), (3, 5)]
x_order = {0: 0, 1: 0, 2: 1, 3: 2, 4: 3, 5: 3}
y_order = {0: 0, 1: 1, 2: 0, 3: 0, 4: 0, 5: 1}
drawing = {}
drawing[net] = schemdraw.Drawing()
drawing[net].config(fontsize=12)
delta = 4
nodes = []
node_dict = {}
position = {}
for e in edge:
if e[0] not in nodes:
nodes += [e[0]]
pos = ((x_order[e[0]])*3, (y_order[e[0]])*3)
position[e[0]] = pos
node_dict[e[0]] = flow.Circle(r=1).at(pos).label('$S_{}$'.format(e[0]))
drawing[net] += (node_dict[e[0]])
if e[1] not in nodes:
nodes += [e[1]]
pos = ((x_order[e[1]])*3, (y_order[e[1]])*3)
position[e[1]] = pos
node_dict[e[1]] = flow.Circle(r=1).at(pos).label('$S_{}$'.format(e[1]))
drawing[net] += (node_dict[e[1]])
drawing[net] += elm.Arrow(arrow='->').at(node_dict[e[0]].E).to(node_dict[e[1]].W).label('0')
drawing[net].draw()
The output figure is available at the following link:
https://stackoverflow.com/questions/73227392/schemdraw-does-not-draw-flow-according-to-the-provided-position
Pthyon 3.8
I'm using the following code from the examples on the docs page,
import schemdraw
from schemdraw import logic
with schemdraw.Drawing() as d:
d.config(unit=0.5)
d += (S := logic.Xor().label('S', 'right'))
d += logic.Line().left(d.unit*2).at(S.in1).idot().label('A', 'left')
d += (B := logic.Line().left().at(S.in2).dot())
d += logic.Line().left().label('B', 'left')
d += logic.Line().down(d.unit*3).at(S.in1)
d += (C := logic.And().right().anchor('in1').label('C', 'right'))
d += logic.Wire('|-').at(B.end).to(C.in2)
This throws the folloiwng error,
File "D:\Python codes\temp.py", line 11
d += (S := logic.Xor().label('S', 'right'))
^
SyntaxError: invalid syntax
Any idea why this is happening?
When I use logicparse, the inputs are not annotated with names.
This happens also in the example shown in the documentation (https://schemdraw.readthedocs.io/en/0.16/elements/logic.html), whereas it seems it was not happening on v0.9.1 (https://schemdraw.readthedocs.io/en/0.9.1/elements/logic.html)
I've created a python virtual environment and installed the requirements but I can't build the html documentation:
Running Sphinx v5.3.0
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 48 source files that are out of date
updating environment: [new config] 48 added, 0 changed, 0 removed
executing compound [ 4%] elements/compound
executing connectors 6%] elements/connectors
executing dspes... [ 8%] elements/dsp
executing electrical 10%] elements/electrical
executing flows... [ 12%] elements/flow
executing intcircuits14%] elements/intcircuits
executing logic... [ 16%] elements/logic
executing analog.. [ 18%] gallery/analog
Extension error:
Cell raised uncaught exception:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In [5], line 12
10 I1 = d.add(elm.SourceI(d='down', botlabel='1A'))
11 L2 = d.add(elm.Line(d='left', tox=V1.start))
---> 12 d.loopI([R1,R2,L2,V1], '$I_1$', pad=1.25)
13 d.loopI([R1,I1,L2,R2], '$I_2$', pad=1.25) # Use R1 as top element for both so they get the same height
14 d.draw()
AttributeError: 'Drawing' object has no attribute 'loopI'
make: *** [Makefile:20: html] Error 2
Hi,
I just discovered this library and found it quite neat for drawing flow charts. I now have a chart where multiple boxes join in a subsequent one. I chose one of them to form the backbone and just attached the second "from the side":
with Drawing() as d:
width = 5.5
height = 1
arrowlen = d.unit / 4
data_bg = "#ccecff"
process_bg = "#ffbfbf"
d.config(font="sans", lw=2)
flow.Box.defaults["fill"] = data_bg
flow.Box.defaults["w"] = width
flow.Box.defaults["h"] = height
flow.Box.defaults["minsize"] = (width, height)
flow.RoundBox.defaults["fill"] = process_bg
flow.RoundBox.defaults["w"] = width
flow.RoundBox.defaults["h"] = height
flow.RoundBox.defaults["minsize"] = (width, height)
flow.Arrow.defaults["arrowwidth"] = 0.3
flow.Arrow.defaults["arrowlength"] = 0.3
# print(flow.Box.defaults)
db = flow.Box().label("first").drop("S")
flow.Arrow().down(arrowlen)
aq = flow.RoundBox().label("second")
flow.Box().at(db.W, -3.5, height/2).label("side")
flow.Line().down(arrowlen + height / 2)
flow.Wire(arrow="->").to(aq.W)
This is exactly what I want (layout-wise). However, the Wire
I use to make the elbow connection seems to spawn some Segment
s internally that do not care about the changed arrowwidth/length defaults, so the arrowheads have different size. I can work around this by just chaining an Arrow
to the respective anchor of aq, but where should the default go for this to work? Is this a bug or intentional?
I am using the SchemDraw library to draw a timing diagram with three signals. The issue I am experiencing is that the diagram only displays the first five waveforms for each signal. Here is the code I am using:
with schemdraw.Drawing() as d:
d.config(fontsize=12)
d += logic.TimingDiagram(
{'signal': [
{'name': r'$\Phi1$', 'wave': '01010', 'async': [0, 1, 9, 17, 25, 32], 'risetime': .06},
{'name': r'$\Phi2$', 'wave': '01010', 'async': [0, 2, 10, 18, 26, 32], 'risetime': .06},
{'name': 'S', 'wave': 'x0101', 'async': [0, 1, 15.8, 16.2, 31.8, 32], 'risetime': .06},
],
'config': {'hscale': 0.6},
}, ygap=.5, grid=True)
The timing diagram only shows the first five waveforms for each signal. I tried to fix the issue by adding waveform , and the code is as follows, but this is not ideal enough.
with schemdraw.Drawing() as d:
d.config(fontsize=12)
d += logic.TimingDiagram( {'signal': [
{'name': r'$\Phi1$', 'wave': '01010','async': [0,1,9,17,25,32],'risetime':.06},
{'name': r'$\Phi2$', 'wave': '01010','async': [0,2,10,18,26,32],'risetime':.06},
{'name': 'S', 'wave': 'x0101', 'async': [0,1, 15.8, 16.2,31.8,32],'risetime':.06},
{'name': r'test', 'wave': 'p...............................','phase':0},],
'config': {'hscale': 0.6},
}, ygap=.5, grid=True)
I believe this could be a bug in the library. Could you please help me identify the cause of the issue and provide a solution?
Please try this input to logic_parser.logicparse
(((((((Input1 nor Input2) nor Input3) nor Input4) xnor Input5) xnor Input6) nor Input7) nor Input8)
I will freeze there forever tested with 0.17 and 0.18
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.