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

[FR] grid function: Throw errors on bad settings

Open diegozea opened this issue 2 years ago • 0 comments

Hi! It would be great if the grid function errors when the heights and widths are not correctly set — so the users can understand the incorrect behavior through the error messages. In the following example, we should throw an error if one of the values is zero or if the sum is greater than one. Also, the argument should allow PlotMeasures units as they create error messages that are difficult to understand for newcomers. Cheers

# ╔═╡ dd200ca8-dc0a-11ec-09bc-6b12e6752417
using Plots

# ╔═╡ bb729008-f813-422c-b976-64f1a8f51195
using PlutoUI

# ╔═╡ 0022b3c5-1883-434d-9d03-31be2f5ebb0f
@bind fraction Slider(0.0:0.1:1.0, default=0.4, show_value=true)

# ╔═╡ c93e3243-b265-4c4b-8b98-4ecf011d6ba6
plot(
	plot(log), plot(exp), plot(sqrt), plot(x -> x^2),
	legend = false,
	layout = grid(2, 2, 
		heights = [fraction, 1.0 - fraction],
		widths = [fraction, 1.0 - fraction])
)

image

image

diegozea avatar May 25 '22 10:05 diegozea