-
Couldn't load subscription status.
- Fork 1.4k
[graf2d] allow zero outer margins when dividing canvas #20209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
When nx or ny is negative, the pads is divided according to abs(nx) or abs(ny), but the outer margins is set to 0. The inner margins are equal to xmargin and ymargin, respectively.
ad4dab7 to
9eb99eb
Compare
|
I force pushed small fix. In the previous version I was generating margins twice smaller than in the original implementation. So in my implementation whenever I use |
|
@couet But I started to have a second thoughts. Unfortunately, my proposed solution, if run on older ROOT version, will fall for the previous behavior: if (nx <= 0) nx = 1;
if (ny <= 0) ny = 1;and if someones does So perhaps other idea would be one of two:
void TPad::Divide(Int_t nx, Int_t ny, Float_t xmargin, Float_t ymargin, Int_t color, Float_t xmargin_outer = 999.0, Float_t ymargin_outer = 999.0)or make an overload: void TPad::Divide(Int_t nx, Int_t ny, Float_t xmargin, Float_t ymargin, Int_t color, Float_t xmargin_outer, Float_t ymargin_outer)This is more flexible as allows to adjust the outer margin - may not be 0 but may also be smaller than inner margins. If value is 1 or more (for the case with defaults), then inner |
|
I do not think a negative marging has some meaning. It is not allowed. In SetMargin one can see this protection: |
But documentation says something else. Please see this comment: #20138 (comment) and see the image which is just above. The lower row of canavses has odd behavior - non-zero top-right margins. I reported that in my first issue. And in the code the top-right margin is somehow treated in a special way. So perhaps this special case should be removed? Perhaps it is some very obsolete code and not relevant today? |
|
Ok I need to check.... |
|
The margins <0 means there is now space between the pads. May be there is somthing wrong in that case. Does your PR fixes it ? That's very old code which was not change since 21 years. May be it can be improved as you suggest. |
|
I tried to not modify this behavior as it was explicitly documented, so assumed that it is important to keep it as it is. So I changed from initial idea of using negative margins to negative divisions numbers. But if you say, I can get back to initial idea of negative margins, and remove the this old obsolete code. |
|
Yes negative margins means no spaces betwen the pads. This code was introduced by this PR: e2cbbfc it says: Extend the functionality of TPad::Divide when xmargin=0 and ymargin=0. When you run this example it looks fine. |
|
Margins set to 0 are fine. But margins set to negative number give the odd top-right non-negative margin, and left-bottom zero margin. See the middle row of the image on top of the page. |
|
In the example above (given in the original PR) if i put negative margins like: I get exactly the same plot as the original with margins = 0. |
I guess it leaves as much margin on the right part as the space on the left for the y axis labels? Same for top vs bottom x labels. So that the axes lines are centered. |


This Pull request:
Implements feature proposed here: #20165 (comment)
Changes:
nxornyis negative, the pads is divided according toabs(nx)orabs(ny), but the outer margins is set to 0. The inner margins are equal toxmarginandymargin, respectively. Demo of the new feature in the bottom row of the image:Created with macro:
Checklist:
Also related to #20138