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

Subplot horizontal alignment off (y-axes not all aligned) in regular grid #2237

Closed
OminousOmen opened this issue Nov 4, 2019 · 2 comments
Closed

Comments

@OminousOmen
Copy link

I am trying to make a 2x2 grid of plots, all set to the same size. While the first column of the grid behaves as expected, with the y-axes aligned, the second column has the issue that the bottom right plot is slightly too far over to the left, breaking the alignment of the y axes. Below is my MWE code; I have tried and seen this on both PyPlot and GR backends. Attached is savefig() output from my system.

Julia version is 1.2.0, current released packages for Plots.jl and backends used, on Linux/AMD64.

using Plots
using LaTeXStrings

C_theta = [0.0, 1.13]
C_delta = [0.0, 0.84]
C_M = [5.0, 2.1]

B_theta = [2.42, 0.0]
B_delta = [-0.35, 0.0]
B_M = [2.1, 5.0]

xlimvals = (-0.075, 2.5)
ylimvals_delta = (-0.9, 0.025)
ylimvals_M = (1.8, 5.1)
p_MWE_1 = plot(C_theta, -C_delta, ylab=L"$\delta$", legend = :none, grid = :none, color = :black, xlims = xlimvals, ylims = ylimvals_delta)
p_MWE_2 = plot(C_theta, C_M, xlab=L"$\theta_\gamma - \theta_2$", ylab=L"$M$", legend = :none, grid = :none, color = :black, xlims = xlimvals, ylims = ylimvals_M)

p_MWE_3 = plot(B_theta, B_delta, legend = :none, grid = :none, color = :black, xlims = xlimvals, ylims = ylimvals_delta)
p_MWE_4 = plot(B_theta, B_M, xlab=L"$\theta_\gamma - \theta_2$", legend = :none, grid = :none, color = :black, xlims = xlimvals, ylims = ylimvals_M)


p_composite_MWE = plot(p_MWE_1, p_MWE_3, p_MWE_2, p_MWE_4, layout = (2,2), show = true)

plot_alignment_issue_MWE.pdf

@fredcallaway
Copy link
Contributor

fredcallaway commented Dec 8, 2019

Bump. I am having the same issue. Note that matplotlib handles this correctly.

Julia

x = rand(100); y = rand(100)
f1 = scatter(x, y,)
f2 = scatter(x, y,)
f3 = scatter(x, y)
f4 = scatter(x, y,  yticks=[])
plot(f1, f2, f3, f4)

julia

Python

x = np.random.rand(100)
y = np.random.rand(100)
fig, axes = plt.subplots(2, 2, figsize=(8, 8))
for ax in axes.flat:
    ax.scatter(x, y)

axes[1,1].set_yticklabels(());

matplotlib

@mattiasvillani
Copy link

Same problem here on:

Julia Version 1.4.1
Commit 381693d3df* (2020-04-14 17:20 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-8.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4

This was referenced Jun 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants