I’ve taken up a little challenge to reproduce a classic plot from Chorin 1973 (maybe the first computerized flow plot ever) and I hoped WaterLily.jl + UnicodePlots.jl could make short work of it.
However, to really nail this plot I need to limit myself to the the ‘x’ and ‘o’ characters, downgradingUnicodePlot.jl significantly. I can get the coordinates where the x’s and o’s should be. I’m not having any luck adding x’s and o’s to the plot at those points. Any ideas?
Wouldn’t it be easier to do this manually? Like a simple sweep through the mesh that prints spaces, Xs, and Os, depending on the values? I feel like trying to simplify UnicodePlots would be more work than that.
(I assume O is for positive vorticity, X negative. Never seen that plot before, so thanks for that =])
No idea, but why can’t you just print the results of the mesh to the terminal? You’d have to do too much interpolation or something?
In other words, which feature of UnicodePlots is needed for this?
I am generally trying to use other people’s code instead of just writing my own where possible in Julia. In this case, it is easy enough:
function print_vort(a)
width,height = size(a)
for w in 2:4:width-1
s = ""
for h in 2:2:height-1
v = sum(a[w:w+4,h:h+1])/8
s*= v<-1 ? "O" : v>1 ? "X" : " "
end
println(s)
end
end
julia> print_vort(a)
XXX OO
XX OO
XX OO
XX OO
XX OOOO OOO
XXXXXX OOO
XXXXXXX OOO
XXXXXXXOOO
OOO
OOOOO
OOOOOOOOO
OOOOOOOOO
OOOO
XXXXXXXXXX
XXXXXXXXXXX
XXXXXXXXX
XXXX
OOOOO
OOOOOOO
OOOOOOOO
OOOOOO
Gnuplot can also plot using ASCII text on the terminal by setting the terminal to dumb:
+--------------------------------------------------------------------+
| X + + + + + + + + + |
1.5 |-+ +-|
| X |
1 |-+ +-|
| X X |
0.5 |-+ O +-|
| X O O |
| O O |
0 |-+ X +-|
| O |
-0.5 |-+ O O X +-|
| |
-1 |-+ X +-|
| |
-1.5 |-+ X +-|
| |
| O |
-2 |-+ X+-|
| + + + O + + + + + + |
-2.5 +--------------------------------------------------------------------+
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
There are two julia front-ends to Gnuplot I’m aware of: Gnuplot.jl and Gaston.