How to get individual plots in PDF

Hi.
I am recently shifting from R to Julia. I want a help in getting individual plot for each ID in a PDF.
I have attached the R code i used to do that. Can someone suggest equivalent code in julia to do the same?

pdf("path//indplots.pdf")
for(i in unique(df$ID))
{
  print((ggplot(subset(df,df$ID == i),aes(x=TAD,y=DV))+
           geom_point()+
           xlab("TAD (hrs)")+
           ylab("Plasma concentration (mg/L)")+
           ggtitle(paste(as.character(i)))+
           theme(panel.grid.minor=element_blank(),
                 panel.grid.major=element_blank(),
                 panel.background = element_blank(),
                 plot.title=element_text(hjust=0.5),
                 legend.position="right",
                 legend.key=(element_rect(colour='white',fill='white')),
                 plot.margin=unit(c(0.5,0.5,0.5,0.5),"cm"),
                 legend.text=element_text(colour="black",size=10),
                 axis.text.x=element_text(colour="black",size=10),
                 axis.text.y=element_text(colour="black",size=10),
                 axis.title=element_text(colour="black",size=14),
                 axis.line.x = element_line( colour="black",size=1,linetype ="solid"),
                 axis.line.y = element_line( colour="black",size=1,linetype ="solid"))))
}
dev.off()

Thanks in advance

You got some suggestions in February. Could you expand on why those didn’t work for you?

To me it’s a bit difficult to help here, because you’re not describing clearly what you want. Do you want many pdf’s, one pdf with many pages or one pdf with one page with many plots?

The documentation for PDFmerger.jl suggests this

using Plots, PDFmerger

for i in 1:5
    p = plot(rand(33), title="$i");
    savefig(p, "temp.pdf")
    append_pdf!("allplots.pdf", "temp.pdf", cleanup=true)
end
2 Likes

My Dataframe looks like this

 df = DataFrame(id = 1:5, a = 10:14, b = 5:9)

I want pdf contains 5 pages.(1 page for 1 ID). i want a xy plot for the variables a and b.

10 on x , 5 on y for id 1 in first page,
11 on x , 6 on y for id 2 in second page
.
.
14 on x , 9 on y for id 5 in last page.

just plots for individual id’s.

is there a way to get that. Thank you

for r in eachrow(df)
    p = plot([r.a], [r.b]; title="ID: $(r.id)", seriestype=:scatter)
    savefig(p, "temp.pdf")
    append_pdf!("plots.pdf", "temp.pdf"; cleanup=true)
end

Something like this?

1 Like

Exactly,Thank you very much.