Space between each subplot of a triplot

Use of Healpix, camb, CLASS, cosmomc, compilers, etc.
Post Reply
Dournac Fabien
Posts: 38
Joined: May 18 2019
Affiliation: IRAP
Contact:

Space between each subplot of a triplot

Post by Dournac Fabien » July 09 2020

Hello,

I produce triplots like this :

Image

I would like to get spaces between each subplot like in this example :

Image

I tried to play with some settings options to use in the same way for example to specify fontsize of axes, i.e :

Code: Select all

g = plots.get_subplot_plotter()
g.settings.axes_fontsize = 20
But I couldn't find the option to apply to specify these spaces between subplot

Anyone has an idea about this issue ?

Dournac Fabien
Posts: 38
Joined: May 18 2019
Affiliation: IRAP
Contact:

Re: Space between each subplot of a triplot

Post by Dournac Fabien » July 16 2020

A strange case occurs concerning the equal space between all subplots. While I was doing different tests to get this space between subplots, I found
a case where if I apply a big y-axis labelpad on the parameter "w_a", I get these equal spaces and for the moment, I can't explain how this result is obtained.

For example, If I do :

Code: Select all

# Browse each subplot of triangle
for m in range(0,7):
  for n in range(0,m+1):
    ax = g.subplots[m,n]

    # If I am not on diagonal posterior into triplot
    if (m != n):
      if (m == 3 and n == 0):
        # Apply a big shift of "w_a" to the left : 50 !!!
        ax.yaxis.set_label_coords(x0-50, y0)
Then I firstly the image :

Image

where label [math] appears totally on the left side and the triplot on the right (even too small to be visible from entire figure).

But if I zoom on the right located triplot, I get interesting results :

Image

You can notice that I get this way the wanted behavior, i.e equal space between each subplot.

But I can't explain this result which doesn't correspond to the previous image in the thread of discussion. The ideal would be to have the same behavior (same equal space) but with right aligned labels (I mean without having to apply too large shift on them).

If this strange behavior could be explained by someone, this would be fine to tell it,

Regards

Dournac Fabien
Posts: 38
Joined: May 18 2019
Affiliation: IRAP
Contact:

Re: Space between each subplot of a triplot

Post by Dournac Fabien » July 22 2020

Hello,

The strange behavior that I mentionned previously might be related to the size of the figure. I say this since when the labels are far away from each other, all the subplots are equally spaced distant like in the figure I showed above (by the way, I don't know how this space between each subplot is computed).

Any help is welcome to overcome this issue.

Dournac Fabien
Posts: 38
Joined: May 18 2019
Affiliation: IRAP
Contact:

Re: Space between each subplot of a triplot

Post by Dournac Fabien » July 23 2020

From my last tests, the space between each subplot is not related to the size of figure :

I have set :

Code: Select all

plt.rcParams["figure.figsize"] = (100,100)
instead of :

Code: Select all

plt.rcParams["figure.figsize"] = (30,30)
and this doesn't change anything, I mean about the wanted equi-distance between each subplot and the shifting of [math] label on both axis.

Dournac Fabien
Posts: 38
Joined: May 18 2019
Affiliation: IRAP
Contact:

Re: Space between each subplot of a triplot

Post by Dournac Fabien » August 06 2020

I update my progress about the equi-space that I would like to get since I don't want that posts overlap themselves.

For instant, I don't know which parameter I have to modify or to assign that controls the space between each subplot.

I tried to manually set a space character :

Code: Select all

Code: Select all

      spacex = '  '
      spacey = '  '
      ax.set_ylabel(spacey, rotation=0, fontsize=20, labelpad=15)
      ax.set_xlabel(spacex, rotation=0, fontsize=20, labelpad=15)
But unfortulately, this doesn't seem to have an effect on each box. would you have another trick ?

Antony Lewis
Posts: 1618
Joined: September 23 2004
Affiliation: University of Sussex
Contact:

Re: Space between each subplot of a triplot

Post by Antony Lewis » August 06 2020

Getdist is designed to have zero space between the triangle subplots. Anything else you'd have to manage yourself. (you seem to be wasting a lot of time on trivial - and hence probably unnecessary - plotting tweaks!?)

Dournac Fabien
Posts: 38
Joined: May 18 2019
Affiliation: IRAP
Contact:

Re: Space between each subplot of a triplot

Post by Dournac Fabien » August 07 2020

Dear Antony,

I have finally got the triplot with all parameters that I wanted to align. The result is shown below :

Image

Now, to finish with all this stuff, I want to put manually the location of legend since as you can see on the figure, there is an overlap with the figure.
Ideally, I would like to set the legend totally on the right and if possible not completely on the top.

If it can be done, how to perform this manual location of the legend ?

Thks


Dournac Fabien
Posts: 38
Joined: May 18 2019
Affiliation: IRAP
Contact:

Re: Space between each subplot of a triplot

Post by Dournac Fabien » August 07 2020

This is the first thing I tried. The above figure has been produced with :

Code: Select all

g.triangle_plot([matrix1, matrix2],
                names,
                filled = True,
                legend_labels = [label1, label2],
                legend_loc = 'upper right',
                contour_colors = ['red', 'darkblue'],
                line_args = [{'lw':2, 'color':'red'},
                {'lw':2, 'color':'darkblue'}]
                )
But as you can see, there is an overlapping : that's why I talked about to set "manually" (with coordinates) the legend.

Is there a workaround ? Regards

Post Reply