Grid of differently colored scatter plots

Hello,
I am trying to plot a 14x3 grid of scatter plots with common x-axes and common coloring based on their z-value (I have a vector of colors).
My current code looks like this:

plot(layout=(14,3))
for i in 1:42
    plot!(x, y[i,:], markercolors=cols, seriestype = :scatter, subplot=i, size=(300,200))
end

but this overlays all the plots and returns this message:

GKS: Rectangle definition is invalid in routine SET_VIEWPORT

ivct_band
Do you have any solution on how to plot this many subplots with a reasonable size?

Plots.jl’s plotly() backend might be helpful to handle a large number of subplots. One example:

using Measures, Plots; plotly()

function grid_scatter(N,M)
    plotsize = (M*400,N*400)
    plts = [scatter(rand(10), xlabel="X-axis ($i)", ylabel="Y-axis ($i)", color=i,
        margin = 10mm, legend=false, plotsize=(400,400), label="plot#$i") for i in 1:N*M]
    plot(plts..., layout=(N,M), size=plotsize)
end

grid_scatter(14,13)

Fyi, a fraction of the scrollable html file created:

Thanks! This is working!
Would you know how to export the grid to .pdf?
Typing just:

savefig("./plots.pdf")

will fail like this (png gives the same result as pdf):

I am only able to save to html and from the browser create a PDF.

For batch processing you may consider wkhtmltopdf freeware.

1 Like