Skip to content
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

[FIX] Fix long titles overlapping plot contents #3797

Merged
merged 10 commits into from Jul 10, 2023

Conversation

ymzayek
Copy link
Member

@ymzayek ymzayek commented Jun 30, 2023

Supersedes and closes #2804
Relates to #3728
Closes #2054 .

Changes proposed in this pull request:

  • Increasing default figsize in different slicers to prevent long titles from overlapping plot contents

@github-actions
Copy link
Contributor

👋 @ymzayek Thanks for creating a PR!

Until this PR is ready for review, you can include the [WIP] tag in its title, or leave it as a github draft.

Please make sure it is compliant with our contributing guidelines. In particular, be sure it checks the boxes listed below.

  • PR has an interpretable title.
  • PR links to Github issue with mention Closes #XXXX (see our documentation on PR structure)
  • Code is PEP8-compliant (see our documentation on coding style)
  • Changelog or what's new entry in doc/changes/latest.rst (see our documentation on PR structure)

For new features:

  • There is at least one unit test per new function / class (see our documentation on testing)
  • The new feature is demoed in at least one relevant example.

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

We will review it as quick as possible, feel free to ping us with questions if needed.

@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Merging #3797 (139a734) into main (01cfa3d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #3797   +/-   ##
=======================================
  Coverage   91.53%   91.53%           
=======================================
  Files         133      133           
  Lines       15623    15626    +3     
  Branches     3250     3250           
=======================================
+ Hits        14301    14304    +3     
  Misses        774      774           
  Partials      548      548           
Flag Coverage Δ
macos-latest_3.10 91.46% <100.00%> (+<0.01%) ⬆️
macos-latest_3.11 91.46% <100.00%> (+<0.01%) ⬆️
macos-latest_3.8 ?
macos-latest_3.9 ?
ubuntu-latest_3.10 91.46% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.11 91.46% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.8 91.42% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.9 91.42% <100.00%> (+<0.01%) ⬆️
windows-latest_3.10 ?
windows-latest_3.11 ?
windows-latest_3.8 ?
windows-latest_3.9 91.37% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
nilearn/plotting/displays/_projectors.py 98.24% <100.00%> (+0.01%) ⬆️
nilearn/plotting/displays/_slicers.py 89.48% <100.00%> (+0.03%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ymzayek
Copy link
Member Author

ymzayek commented Jul 5, 2023

For review see the artifacts: https://output.circle-artifacts.com/output/job/cde255e7-0a62-4aff-8607-6a8301a138ec/artifacts/0/dev/index.html

An example of what to look for where plots are improved:

Some other issues like the titles being cut off will be resolved in #3753 or follow-up PRs

@bthirion
Copy link
Member

bthirion commented Jul 5, 2023

I'm wondering whether it's a good idea to change default size: Wouldn't it be better to work with fontsize or figsize (and do so in some examples to teach this) ?
(This is a naive question, to be discussed)

@ymzayek
Copy link
Member Author

ymzayek commented Jul 6, 2023

I'm wondering whether it's a good idea to change default size: Wouldn't it be better to work with fontsize or figsize (and do so in some examples to teach this) ? (This is a naive question, to be discussed)

Yea it would work to just set figsize in a figure object in the examples. But this way at least guarantees that if you add a title it will fit correctly and without it doesn't look worse (but maybe I missed some cases where it does?). It is always possible to override the figsize in any case. TBH I have no strong opinion one way or the other. Any thoughts @jeromedockes ?

@ymzayek
Copy link
Member Author

ymzayek commented Jul 6, 2023

On second thought, I just went through all the examples and there were a lot of them that were affected by this and they look much better. Going through to manually change each one in the examples code is much more of a hassle. At least this way we have a default that looks nice with or without a title

@jeromedockes
Copy link
Member

I think the proposal in #2804 was to also move the y position of the title, besides increasing the figsize, is this not needed anymore?

@@ -1816,7 +1818,7 @@ class MosaicSlicer(BaseSlicer):

_cut_displayed = "yxz"
_axes_class = CutAxes
_default_figsize = [11.1, 7.2]
_default_figsize = [11.1, 20.0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a large increase, why is it necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like a large increase, why is it necessary?

It was hard to get the title not to overlap and then to me the rendering in the examples seemed better since the brains are bigger and closer together so less white space. See the mosaic plots in this example (old vs new).

@ymzayek
Copy link
Member Author

ymzayek commented Jul 6, 2023

I think the proposal in #2804 was to also move the y position of the title, besides increasing the figsize, is this not needed anymore?

No IIUC that was abandoned for the default figsize approach because increasing the y value will lead to the title getting cut out of the figure, #2804 (comment). I've tested it and it's indeed the case. It seems to me those default x and y position values were chosen to keep the title box "snapped" to the top left corner of the figure.

Copy link
Member

@bthirion bthirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thx.

Copy link
Member

@jeromedockes jeromedockes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ymzayek !

@ymzayek
Copy link
Member Author

ymzayek commented Jul 10, 2023

Thanks for the reviews! Merging

@ymzayek ymzayek merged commit 4f67c91 into nilearn:main Jul 10, 2023
29 checks passed
@ymzayek ymzayek deleted the overlapping-titles branch July 10, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plot title overlays the image
3 participants