Hey Everyone, (ps: thank you in advance)
How do I write :
ResourceFunction["MultiwaySystem"][{"A" -> "B","A" -> "C","B" -> "DA", "C" -> "DA","DA"->"B"}, "A", 8, "CausalGraph"]
with The Wolfram Client Library for Python?
Hey Everyone, (ps: thank you in advance)
How do I write :
ResourceFunction["MultiwaySystem"][{"A" -> "B","A" -> "C","B" -> "DA", "C" -> "DA","DA"->"B"}, "A", 8, "CausalGraph"]
with The Wolfram Client Library for Python?
Hello Leo!
For writing that in the WolframClientLibraryForPython, you can do that by using the WolframLanguageSession and wlexpr. Executing the code is pretty straightforward, but displaying the graphics is more tricky since there’s no display for the graph in the python language. So the method I used is to rasterize the image and display it with matplotlib.
Here’s the code.
import matplotlib.pyplot as plt
from wolframclient.evaluation import WolframLanguageSession
from wolframclient.language import wl, wlexpr
session = WolframLanguageSession()
graph = session.evaluate(wlexpr('ResourceFunction["MultiwaySystem"][{"A" -> "B","A" -> "C","B" -> "DA", "C" -> "DA","DA"->"B"}, "A", 8, "CausalGraph"] // Rasterize'))
plt.imshow(graph[0])
Thank you Pedro Cabral.
Everything work perfectly and i fix the problem of rasterize the image.
The only problem is the size of the edge ( i’m only able to change it to a shape and resize it , not resize the original. can’t resize the label)
import matplotlib.pyplot as plt
from wolframclient.evaluation import WolframLanguageSession
from wolframclient.language import wl, wlexpr
session = WolframLanguageSession()
graph = session.evaluate(wlexpr('Image[ResourceFunction["MultiwaySystem"][{"A" -> "B","A" -> "C","B" -> "DA", "C" -> "DA","DA"->"B"}, "A", 8, "CausalGraph"],ImageSize -> {1920, 1080}]'))
plt.figure(figsize = (100,100))
img = plt.imshow(graph[0])
plt.show(img)