0

I am trying to clearly visualise the plot as shown below, as the x-axis is extremely congested. I am using matplotlib for producing the plots, and I would like to separate out this plot below into 5 different "smaller" plots, based on the x-axis names (labels in the code below). Is there a way to do it in matplotlib ?

My code is as below -

plt.hlines([-1, 1], -0.5, len(pulls) - 0.5, colors="k", linestyles="dashdot")
plt.fill_between([-0.5, len(pulls) - 0.5], [-2, -2], [2, 2], facecolor="#a8cee2")
plt.fill_between([-0.5, len(pulls) - 0.5], [-1, -1], [1, 1], facecolor="#388ebc")
plt.hlines([0], -0.5, len(pulls) - 0.5, colors="k", linestyles="dashed")

plt.scatter(range(len(pulls)), pulls, c="k")
plt.errorbar(
    range(len(pulls)), pulls, c="k", xerr=0, yerr=pullerr, marker=".", fmt="none"
)

plt.xticks(range(len(pulls)), labels, rotation=90)
plt.gcf().set_size_inches(25, 5)
plt.xlim(-0.5, len(pulls) - 0.5)
plt.ylabel(r"$(\theta - \hat{\theta})\,/ \Delta \theta$", fontsize=18);
plt.gcf().subplots_adjust(bottom=0.5)
plt.draw()

Thank you very much.

Best,

Shreya

enter image description here

Shreya
  • 23
  • 2
  • 3
    The [matplotlib docs](https://matplotlib.org/stable/gallery/subplots_axes_and_figures/subplots_demo.html) have a good introduction to subplots. Have you tried to adapt any of their suggestions? What was the specific problem you encountered? – Mr. T Feb 11 '22 at 17:34
  • Does this answer your question? [How to plot in multiple subplots](https://stackoverflow.com/questions/31726643/how-to-plot-in-multiple-subplots) – BigBen Feb 11 '22 at 17:38
  • Thanks for the link and the linked Q, I will have a look and let you know ! – Shreya Feb 11 '22 at 18:34

0 Answers0