PPTX.jl icon indicating copy to clipboard operation
PPTX.jl copied to clipboard

Plotting example

Open matthijscox-asml opened this issue 2 years ago • 2 comments

I'd like to have a plotting example in the documentation.

I think you have to:

  • Load your favorite plotting package, let's assume either Plots.jl or Makie.jl.
  • Then make a plot, say fig = plot(1:5,1:5)
  • Find and use the savefig(fig, path) function of your favorite plotting package.
  • Wrap the saved figure path into a Picture() type and push it into a Slide.

We can try how annoying it is to position multiple pictures on a slide. We can then define enhancement issues to address that.

Related issue: https://github.com/ASML-Labs/PPTX.jl/issues/16

matthijscox-asml avatar Feb 01 '23 08:02 matthijscox-asml

Thanks alot for this package! I had the misfortune of making my own ppt exporter just a few days before your announcement wrapping a python lib for the pptx integration and I'm looking forward to switching to this package instead.

We can try how annoying it is to position multiple pictures on a slide. We can then define enhancement issues to address that.

A neat trick that at least works with Plots is to freeride on the layout mechanism from that package since the subplots and their positions are (at least to me) surprisingly easy to access through what appears to be public APIs.

Example:


julia> plt = plot(plot(randn(10)), plot(1:10)) #Not gonna bother with any advanced layout here

julia> for pind in 1:length(plt)
       subplt = plt[pind]
       @info "subplot nr $pind at position $(plotarea(subplt))"
       end
[ Info: subplot nr 1 at position BBox{l,t,r,b,w,h = 12.314935833891495mm,3.0mm, 74.9455056932351mm,94.38944mm, 62.63056985934361mm,91.38944mm}
[ Info: subplot nr 2 at position BBox{l,t,r,b,w,h = 86.76943014065641mm,3.0mm, 149.40000000000003mm,94.38944mm, 62.630569859343616mm,91.38944mm}

In addition, this gave a very nice WYSIWYG aspect while still allowing the user to move the plots around independently.

One issue is that the sizes don't materialize unless you actually try to display the plot. One can either show the plot to a dummy IO (e.g. show(IOBuffer(), plt))or use the non-public Plots.prepare_output(plt).

Another feature useful in this context is the grouped shapes in power point. If the plots do not fit on a slide one can just change the size of the entire group and the plots stay aligned.

DrChainsaw avatar Feb 12 '23 10:02 DrChainsaw

Great! We started with wrapping the python-pptx package, but installing Python is annoying. Pure Julia is better, but we may lack some features.

Please try out the package and feel free to report back with plotting documentation ideas :)

For direct Plots integration itself, I started this issue: https://github.com/ASML-Labs/PPTX.jl/issues/16

matthijscox-asml avatar Feb 13 '23 08:02 matthijscox-asml

I took the liberty of adding some plotting examples in PR https://github.com/ASML-Labs/PPTX.jl/pull/66

matthijscox-asml avatar Oct 28 '24 13:10 matthijscox-asml