alishinski / lavaanPlot

R package for plotting lavaan path models with DiagrammeR
http://alexlishinski.com/lavaanPlot/
38 stars 4 forks source link

Margins in Rmarkdown #39

Open stefanradev93 opened 2 years ago

stefanradev93 commented 2 years ago

Hi Alex,

I have noticed that using the function semPlot in an Rmarkdown produces huge top and bottom white margins, larger than the actual graph. I have been struggling with this for a while. Any ideas on how to fix this?

Thanks! Stefan

alishinski commented 2 years ago

I assume you mean lavaanPlot; can you show me an example? What output format are you using with Rmarkdown? If pdf, are you using the embed_plot_pdf function?

stefanradev93 commented 2 years ago

Exactly, I mean lavaanPlot. I am using HTML as an output format. You can see an example attached:

Capture

The plot takes up an entire page, compared to all other figures. I am basically doing

lavaanPlot(model = fit, coefs = T, stand = TRUE)

alishinski commented 2 years ago

So one suggestion I can offer that might help is to use the save_png function to save the plot as a png, and then in your .Rmd document you can embed that image. I think that when you save as png it doesn't save it with that big buffer. Let me know whether that helps.

rempsyc commented 1 year ago

@stefanradev93 I was able to solve this problem in rmarkdown by installing pdfcrop in the MiKTeX Console.

pdfcrop

Edit: You also need to have ghostscript installed for this to work.