Skip to content

Instantly share code, notes, and snippets.

@mpilosov
Last active August 25, 2017 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpilosov/a9f03e62eb909d5591ec1acae42b6457 to your computer and use it in GitHub Desktop.
Save mpilosov/a9f03e62eb909d5591ec1acae42b6457 to your computer and use it in GitHub Desktop.
Write files to a grid of images in latex.
save_dir = "images/4D_2/"
QoI_list = [[12],[10], [7,16]]
std = 20
# image of the scatterplots.
portion = 0.32 # should be a hair less than 1/cols
cols = 3
rows = 2
# the following variable is how you want the row*cols images that will be in the figure to be ordered.
order = [ [1 3], [2 3], [1 4], [3 4], [1 2], [2 4] ] # part of the filenames (these are 2D scatterplots in 4D), serpentine column-dominant ordering. (top left to bot right)
for QoI_inds in QoI_list # loop through a list that differentiates the files from one another. each one of these is a different figure saved.
# open the file (create it) that you will write to.
open("4D_w$(QoI_inds...)_scatter.tex", "w") do f
write(f, "\\begin{figure}[h!]\n")
write(f, "\\centering\n")
for c = 1:cols
write(f, "\\begin{minipage}{$(portion)\\textwidth}\n")
for r = 1:rows
write(f, "\t\\includegraphics[width=\\linewidth]{\"./images/4p_acc_w$(QoI_inds...)_$(order[(c-1)*rows + r])_sd$(std)\"}\n")
end
write(f, "\\end{minipage}\n")
end
write(f, "\\caption{}\n")
write(f, "\\label{fig:4D_w$(QoI_inds...)_scatter}\n")
write(f, "\\end{figure}\n")
println("File written.")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment