# Use ResourceFunction with the Wolfram Client Library for Python

**URL:** <https://community.wolfram.com/t/use-resourcefunction-with-the-wolfram-client-library-for-python/15974>\
**Category:** Questions\
**Tags:** external-interfaces, graphs-and-networks\
**Created:** [May 12, 2020, 9:00am UTC](https://community.wolfram.com/t/use-resourcefunction-with-the-wolfram-client-library-for-python/15974 "2020-05-12T09:00:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leorni](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@leorni](https://community.wolfram.com/u/leorni)\
**Post date:** [May 12, 2020, 9:00am UTC](https://community.wolfram.com/t/use-resourcefunction-with-the-wolfram-client-library-for-python/15974/1 "2020-05-12T09:00:32Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![pedrogcabral](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/pedrogcabral/32/34157_2.png) [@pedrogcabral](https://community.wolfram.com/u/pedrogcabral)\
**Post date:** [May 13, 2020, 11:31am UTC](https://community.wolfram.com/t/use-resourcefunction-with-the-wolfram-client-library-for-python/15974/2 "2020-05-13T11:31:52Z")

</div>

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`.

 ![Screenshotfrom2020-05-1308-25-26.png](https://global.discourse-cdn.com/wolfram/original/3X/d/b/db6cfa5153e372a8464fe7e2e026097f03cbfbe5.png)

Here’s the code.

```py
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])

```

---

<div class="post-metadata">

**Author:** ![leorni](https://avatars.discourse-cdn.com/v4/letter/l/97f17d/32.png) [@leorni](https://community.wolfram.com/u/leorni)\
**Post date:** [May 14, 2020, 2:24am UTC](https://community.wolfram.com/t/use-resourcefunction-with-the-wolfram-client-library-for-python/15974/3 "2020-05-14T02:24:01Z")

</div>

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)

 ![download.png](https://global.discourse-cdn.com/wolfram/original/3X/8/6/868e1f0f25311deccc95138235552ed5fe5a0438.png)

```
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)

```
