Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Combine Figures Without Resizing/Rescaling #4770

Open
draftman9 opened this issue Feb 10, 2025 · 0 comments
Open

Feature: Combine Figures Without Resizing/Rescaling #4770

draftman9 opened this issue Feb 10, 2025 · 0 comments
Labels
enhancement Feature requests and enhancements

Comments

@draftman9
Copy link

Feature description

I want to create a scientific visualization. I have two figures, fig1 and fig2, that I've created using the Figure() function. I want to combine these figures into a single figure, fig_combined, without changing the size or aspect ratio of the individual figures. Ideally, I'd like to arrange them side-by-side.

I provide a code example that demonstrates how to achieve this:

using CairoMakie

# Example data
x = LinRange(0, 10, 100)
y = sin.(x)

# Create two individual figures with square axes
fig1 = Figure() # Set the size of the figure
ax1 = Axis(fig1[1, 1], aspect = 1, xlabel = "x-axis", ylabel = "y-axis") # Force square aspect ratio and add xlabel
lines!(ax1, x, y, color = :red)

fig2 = Figure() # Set the size of the figure
ax2 = Axis(fig2[1, 1], aspect = 1, xlabel = "x-axis", ylabel = L"\beta_0\text{fs}^2") # Force square aspect ratio and add xlabel
lines!(ax2, x, y, color = :blue)

# Create a combined figure
fig_combined = Figure()

# Create axes in the combined figure
ax1_combined = Axis(fig_combined[1, 1], aspect = 1, xlabel = "x-axis", ylabel = "y-axis")
ax2_combined = Axis(fig_combined[1, 2], aspect = 1, xlabel = "x-axis", ylabel = L"\beta_0\text{fs}^2")

# Plot the contents into the respective axes
lines!(ax1_combined, x, y, color = :red)
lines!(ax2_combined, x, y, color = :blue)

# Adjust column sizes to accommodate the individual figures' widths
colsize!(fig_combined.layout, 1, Aspect(1, 1)) # Make column 1 square
colsize!(fig_combined.layout, 2, Aspect(1, 1)) # Make column 2 square

# resize the combined figure to fit the layout
resize_to_layout!(fig_combined)

display(fig_combined)

For plot types, please add an image of how it should look like

Image


Image


Actually, I made this by powerpoint where I insert the 2 pictures and combine them into 1 picture and saveas .png.

Image

@draftman9 draftman9 added the enhancement Feature requests and enhancements label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature requests and enhancements
Projects
None yet
Development

No branches or pull requests

1 participant