Save a figure with a specific size with a subplot of a specific size in Plots.jl (with PGFPlotsX backend)

JonasWickman
Wed, 31 Aug 2022 18:47:58 +0000
Visualization

In PyPlot, I can output a figure with a specific size containing an axis in the figure with a specific size using the code:

using PyPlot
fig_width = 4.0
fig_height = 3.0
fig = figure( figsize = (fig_width, fig_height) )
ax = plt.axes( [0.5,0.5,0.1,0.1] )
ax.plot( [0,1] , [0,1] )
savefig("pyplot_output.pdf")

This will create a pdf that is 4 inches wide and 3 inches high, and an axis that has its lower left corner in the middle of the figure and is 10% of the figure wide and 10% of the figure high.

Is it possible to to achieve the same outcome using Plots.jl with the PGFPlotsX backend? I.e., can I 1: Specify the output size of the figure? 2: Specify the relative size of the axis within the figure?

I feel a bit silly asking such a basic question, but even after reading the Plots.jl documentation and Googling around, I could not figure out how to do this.

3 posts - 2 participants