Matplotlib

[1]:
from pyfeyn2.feynmandiagram import FeynmanDiagram, Leg, Propagator, Vertex
from pyfeyn2.render.mpl.mpl import MPLRender
from pyfeyn2.render.latex.dot import feynman_adjust_points
import pyfeyn2
print(pyfeyn2.__version__)
[2]:
fd = FeynmanDiagram()
v1 = Vertex("v1").with_xy(-1, 0)
v2 = Vertex("v2").with_xy(1, 0)
p1 = Propagator("p1").connect(v1, v2).with_type("gluon")
l1 = Leg("l1").with_target(v1).with_xy(-2, 1).with_type("gluon").with_incoming()
l2 = Leg("l2").with_target(v1).with_xy(-2, -1).with_type("gluon").with_incoming()
l3 = Leg("l3").with_target(v2).with_xy(2, 1).with_type("gluon").with_outgoing()
l4 = Leg("l4").with_target(v2).with_xy(2, -1).with_type("gluon").with_outgoing()
p1.with_source(v1)
p1.with_target(v2)
fd.propagators.append(p1)
fd.vertices.extend([v1, v2])
fd.legs.extend([l1, l2, l3, l4])
[3]:
MPLRender(fd).render()
../../../_images/renderers_mpl_mpl_MPL_3_0.png
[4]:
fd = FeynmanDiagram()
v1 = Vertex("v1").with_xy(-1, 0)
v2 = Vertex("v2").with_xy(1, 0)
p1 = Propagator("p1").connect(v1, v2).with_type("photon")
l1 = Leg("l1").with_target(v1).with_xy(-1, 1).with_type("photon").with_incoming()
l2 = Leg("l2").with_target(v1).with_xy(-2, -1).with_type("photon").with_incoming()
l3 = Leg("l3").with_target(v2).with_xy(2, 1).with_type("photon").with_outgoing()
l4 = Leg("l4").with_target(v2).with_xy(2, -1).with_type("photon").with_outgoing()
p1.with_source(v1)
p1.with_target(v2)
fd.propagators.append(p1)
fd.vertices.extend([v1, v2])
fd.legs.extend([l1, l2, l3, l4])
MPLRender(fd).render()
/home/apn/data/de.neuwirthinformatik.Alexander/Development/git/pyfeyn2/pyfeyn2/render/mpl/mpl.py:79: RuntimeWarning: divide by zero encountered in divide
  alpha = np.arctan((p2[1] - p1[1]) / np.array([(p2[0] - p1[0])]))
../../../_images/renderers_mpl_mpl_MPL_4_1.png
[ ]: