79520908

Date: 2025-03-19 17:09:33
Score: 7.5 🚩
Natty:
Report link

This is very good source to learn more about spacings.
However, i have tried to apply the methods shown here for subplots with twin axes, as shown below.

Somehow, it doesnt fit to the entire horizontal spacing of the figure, leaving some empty space.
Does anyone have faced similar issue and know how to solve it?

enter image description here

This is what i have tried:

mosaic = [["A", "A"],
          ["B", "C"]]

fig = plt.figure(dpi=600)

fig, axs = plt.subplot_mosaic(
    mosaic,
    layout="constrained",
    gridspec_kw={"height_ratios": [1.25, 1],
    "width_ratios": [1, 1.5]}  # Adjust widths: A = 1, B/C = any vals
)

plt.style.use("dark_background")
plt.suptitle('AQ_20 @ 223K', fontweight = 'bold')
# Titles and labels
axs["B"].set_title("Rocking scan")
axs["B"].set_ylabel("Intensity (a.u.)")
axs["B"].set_xlabel(r"$\Delta_{diffry}$ (deg.)")

axs["C"].set_ylabel("Intensity @ max. (a.u.)")
axs["C"].set_xlabel(r"$t$ (s)")

# Limits
axs["C"].set_xlim(-5, 410)
#axs["C"].set_ylim(1.30, 1.65)

axs["B"].set_xlim(-0.2, 0.2)
#axs["B"].set_ylim(-1, 22)

# axs["A"].set_ylim(2560, 0)
# axs["A"].set_xlim(0, 2160)
axs["A"].set_aspect("auto")
axs["A"].set_title("Local structure @ rocking max")
#axs["A"].axis("off")

axC_twin1 = axs["C"].twinx()
axs["C"].plot([0, 100, 200, 300, 400], [1, 2, 3, 4, 5], label="Primary y-axis", color='blue')
axC_twin1.plot([0, 100, 200, 300, 400], [5, 4, 3, 2, 1], label="Twin y-axis", color='red')
axC_twin2 = axs["C"].twinx()
axC_twin1.plot([0, 100, 200, 300, 400], [2, 2, 2, 2, 2], label="Twin y-axis", color='red')
axC_twin1.set_ylabel("$\Delta_{diffy}$", color='red')
axC_twin2.set_ylabel("FWHM (.deg)", color='green')
axC_twin2.spines['right'].set_position(('outward', 30)) 
Reasons:
  • Blacklisted phrase (1): how to solve
  • RegEx Blacklisted phrase (1.5): how to solve it?
  • RegEx Blacklisted phrase (3): Does anyone have
  • RegEx Blacklisted phrase (2): know how to solve
  • Long answer (-1):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Low reputation (1):
Posted by: oliveirals