0

I saw this chart in a paper and need to reproduce it.

How can I plot a figure like this in Python?

Note that:

  • I suspect bigger subplots are perhaps drawn using seaborn or using matplotlib's subplot
  • The smaller plots are POINTING at a specific part of the curve in the bigger plots.

enter image description here

Ali
  • 443
  • 4
  • 15
  • Please see https://matplotlib.org/3.2.2/gallery/subplots_axes_and_figures/zoom_inset_axes.html#sphx-glr-gallery-subplots-axes-and-figures-zoom-inset-axes-py – Jody Klymak Jun 28 '20 at 21:25

1 Answers1

2

One strategy can be using mpl_toolkits.axes_grid1.inset_locator , as suggested in the answer to this question: How to overlay one pyplot figure on another

I have made a quick example:

import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1.inset_locator import inset_axes
import math

fig = plt.figure()

ax = fig.add_subplot(1,1,1)

x = [n/10 for n in range(0,101)]
y = [n*n*(1-math.sin(n*10)/5) for n in x] # just create some kind of function

ax.plot(x,y) # this is the main plot

# This produces the line that points to the location.
ax.annotate("", (x[50],y[50]),
            xytext=(4.0,65),
           arrowprops=dict(arrowstyle="-"),)

#this is the small figure
ins_ax = inset_axes(ax, width=1.5, height=1.5,
          bbox_transform=ax.transAxes, bbox_to_anchor=(0.45,0.95),)

# the small plot just by slicing the original data
ins_ax.plot(x[45:56],y[45:56])

plt.show()

This is more of a proof of concept to solve specifically the question you asked. It obviously requires tweaks and adaption to you case, to be fit for publication. I hope this helps.

enter image description here

fdireito
  • 1,709
  • 1
  • 13
  • 19