1

When I use inset_axes to place an inset in a figure, for small figure sizes, the tick labels for the inset will overlap the axes frame. Is there a way to make the figure adjust to avoid this problem?

code:

fig, ax1 = plt.subplots()

ax1.plot(dd1["mag"].index, dd1["mag"], '.-',label="$\omega$")
ax1.plot(newindex,curvy1,'--', label="${0:.3f} \cdot I$".format(popt1[0]))
ax1.set_xlim((5e11, 5e13))
ax1.set_ylim((2e-7,.25e-4))

ax1_inset = inset_axes(ax1, width="40%", height="40%", loc=4)
ax1_inset.plot(dd1["mag"].index, (one - np.array(dd1["mag"]))/one)
ax1_inset.plot(dd1["mag"].index, map(lambda x: -.01, dd1["mag"].index), ':')
ax1_inset.set_xlim(5e11,5e13)
ax1_inset.set_ylim(-.1,.05)
ax1_inset.set_xscale("log")

with the matplotlibrc values:

matplotlib.rcParams['figure.figsize'] = '4,3'

matplotlib.rcParams['axes.formatter.use_mathtext'] = 'True'
matplotlib.rcParams['axes.formatter.useoffset'] = 'False'

matplotlib.rcParams['figure.subplot.left'] = .22
matplotlib.rcParams['figure.subplot.right'] = .95
matplotlib.rcParams['figure.subplot.bottom'] = .20
matplotlib.rcParams['figure.subplot.top'] = .90

example figure

Andrew Spott
  • 3,457
  • 8
  • 33
  • 59
  • There is not an automatic layout engine, you will have to fiddle with the placement, size, and font size to make it work. IIRC `inset_axes` has a pad kwarg. – tacaswell Sep 10 '14 at 13:44
  • @tcaswell: write up the specific kwarg for padding in an answer, and I'll accept it. That is exactly what I was looking for. – Andrew Spott Sep 10 '14 at 19:43
  • If that was enough for you to sort it out can you please write the answer up? I don't recall the syntax of the top of my head, don't have the bandwidth to look it up / write it up today, and I don't really need the rep. – tacaswell Sep 10 '14 at 19:59
  • @tcaswell: that is fine. I thought I would offer it to you before I answered my own question. Thanks for the help – Andrew Spott Sep 10 '14 at 20:00

1 Answers1

-1

The kwarg "borderpad" appears to solve this problem.

Gabe
  • 21