-1

This one is a quick and easy one for the matplotlib community. I was looking to plot an L-shaped gridspec layout, which I have done:

enter image description here

Ignoring a few layout issues I have for the moment, what I have is that the x-axis in the gs[0] plot (top left) shares the x-axis with the gs[2] plot (bottom left) and the gs[2] shares its y axis with the gs[3] plot. Now, what I was hoping to do was update the w-space and h-space to be tighter. So that the axes are almost touching, so perhaps wspace=0.02, hspace=0.02 or something similar.

I was also hoping that the bottom right hand plot was to be longer in the horizontal orientation, keeping the two left hand plots square in shape. Or as close to square as possible. If someone could run through all of the parameters I would be very appreciative. I can tinker then in my own time.

GCien
  • 2,221
  • 6
  • 30
  • 56
  • 2
    If you provide some code to make the plots, it would be easy for us to help you. Everything you want though should be on [this](http://matplotlib.org/users/gridspec.html) page. – will Nov 16 '14 at 17:43
  • 1
    You will get the best response if you question is something like "here as a minimal amount of code (that is copy-past runnable), it does X, I want to do Y" – tacaswell Nov 16 '14 at 19:50
  • 1
    I've sorted it anyway, gs.update(hspace=0.01, wspace=0.01) along with gs = gridspec.GridSpec(2, 2,width_ratios=[1,1.5],height_ratios=[1,1]). – GCien Nov 16 '14 at 21:39

1 Answers1

0

To change the spacings of the plot with grid spec:

 gs = gridspec.GridSpec(2, 2,width_ratios=[1,1.5],height_ratios=[1,1])

This changes the relative size of plot gs[0] and gs[2] to gs1 and gs[3], whereas something like:

gs = gridspec.GridSpec(2, 2,width_ratios=[1,1],height_ratios=[1,2])

will change the relative sizes of plot gs[0] and gs1 to gs[2] and gs[3].

The following will tighten up the plots:

gs.update(hspace=0.01, wspace=0.01)

This gave me the following plot:

enter image description here

I also used the following to remove the axis labels where needed:

nullfmt = plt.NullFormatter()

ax.yaxis.set_major_formatter(nullfmt)
ax.xaxis.set_major_formatter(nullfmt) 
GCien
  • 2,221
  • 6
  • 30
  • 56