I would like to draw a graph with Mathematica in such a way that it looks like a handmade drawing or painting. To be more precise, is there a way to set a custom edge style such that it looks made with writing ink or with a brush stroke?
If this is not possible in Mathematica, are you aware of any software that can be used to obtain such an effect? If so, what is the best format in which to export my graph?
Answer
You ought to use EdgeRenderingFunction
to achieve this.
First, import a graphic for a brushstroke:
BRUSH = Import[NotebookDirectory[] <> "brush.png"]
Then use the EdgeRenderingFunction
option in GraphPlot
to obtain the image.
GraphPlot[Graph[{1 -> 2, 2 -> 3, 3 -> 1}],
EdgeRenderingFunction -> ({Inset[BRUSH, Mean[#1], Automatic, 1.7, #[[2]] - #[[1]]]} &),
VertexRenderingFunction -> None
]
The value 1.7
was something I tweaked based on my image. I recommend using a well-cropped image with a transparent background.
I used the image:
to obtain the following graph:
You can make this more complex by trying to use multiple different images as brushstrokes, manually specifying your vertex coordinates, etc.
Comments
Post a Comment