I am using Julia to run simulations on a given system and in my post-processing module I plot and save the results. Also, I have implemented a Luxor drawing function named drawSystem() that shows my data in a very good fashion: a .png file with the drawing of the system and with its values (e.g. temperatures, pressures, velocities, etc.). This function is invoked by the command:
@drawsvg begin drawSystem(dataframe, dimensions, settings) end
to show the drawing in Julia Plots, and it works fine when called by itself.
However, when I add the command in my post-processing module, that does not work anymore. The reason is the fact that that is not the last command of the post-processing module, and therefore it produces the drawing but it does not show it in Julia Plots. I have tried to add preview(), but it does not solve my issue.
@drawsvg begin rect(Point(0,0), 100 ,200 ,action=:fill) end
from the Terminal, then it works and it produces the black rectangle. But if you incorporate that command in a post-processing function like in my case, it does not work simply because the last command of the function postProcess() is println().
using Luxor
function postProcess()
println("Launching post-processing...")
@drawsvg begin rect(Point(0,0), 100 ,200 ,action=:fill) end
println("Post-processing finished")
end
In fact, if you change the post-processing function with:
using Luxor
function postProcess()
println("Launching post-processing...")
@drawsvg begin rect(Point(0,0), 100 ,200 ,action=:fill) end
end
then it works. But I canât do it in this way because I need to have other commands afterwards.
What I would like to know is: does Luxor (or Julia in general) have a command like display() for Plots.jl which shows in Julia Plots windows my drawing even if it not the last command of postProcess()?
What happens if you call postProcess()? Does it produce the black rectangle?
using Luxor
function postProcess()
println("Launching post-processing...")
@drawsvg begin rect(Point(0,0), 100 ,200 ,action=:fill) end
println("Post-processing finished")
end
Ah, youâre talking about the Plots pane in VS code? I think that shows the most recent result, so your function wonât work, since it doesnât return the drawing. Iâll wait till Iâm back in front if a computer to say much more - on the phone atm
Same as @cormullion said: also in Pluto the drawing needs to be the return value of the cell. So if you remove the println("Post-processing finished") statement, the rectangle will be shown.
Yes exactly, removing println("Post-processing finished") would solve my issue. And this can be easily done in the example.
However this is not a solution for my real code, where the function postProcess() is part of a bigger module in which many other commands need to be executed after it. I am looking for some similar command to display() for Plots.jl⌠any suggestion?
A Luxor drawing will appear differently in different working environments. In a non-graphical environment, such as a REPL or terminal emlator, youâll just get a text confirmation:
If youâre using VSCode, you might get some inspriration from this animation:
However, that code wonât work the same in Pluto, because Pluto is reactive, and because thereâs no Plots Pane, so a drawing can be displayed if its the return value:
The author of the documentation could have done a better job of describing the return values and different behaviours of all the various options, but - perhaps the more documentation there is, the harder it is to find anything⌠?