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] improve colorbar in mosaic display #4284

Merged
merged 3 commits into from Feb 27, 2024
Merged

Conversation

Remi-Gau
Copy link
Collaborator

Changes proposed in this pull request:

  • increase width of colorbar in mosaic display

Copy link
Contributor

👋 @Remi-Gau 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.

@Remi-Gau
Copy link
Collaborator Author

Too big I guess.
Also the font size needs to be adapted.

test

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.06%. Comparing base (abb80ff) to head (8963dad).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4284      +/-   ##
==========================================
+ Coverage   91.85%   92.06%   +0.20%     
==========================================
  Files         144      144              
  Lines       16419    16423       +4     
  Branches     3434     3436       +2     
==========================================
+ Hits        15082    15120      +38     
+ Misses        792      761      -31     
+ Partials      545      542       -3     
Flag Coverage Δ
macos-latest_3.10_test_plotting 91.85% <100.00%> (?)
macos-latest_3.11_test_plotting 91.85% <100.00%> (+<0.01%) ⬆️
macos-latest_3.12_test_plotting 91.85% <100.00%> (?)
macos-latest_3.8_test_plotting 91.81% <100.00%> (?)
macos-latest_3.9_test_plotting 91.82% <100.00%> (?)
ubuntu-latest_3.10_test_plotting 91.85% <100.00%> (+<0.01%) ⬆️
ubuntu-latest_3.11_test_plotting 91.85% <100.00%> (?)
ubuntu-latest_3.12_test_plotting 91.85% <100.00%> (?)
ubuntu-latest_3.12_test_pre 91.85% <100.00%> (?)
ubuntu-latest_3.8_test_min 68.92% <0.00%> (?)
ubuntu-latest_3.8_test_plot_min 91.56% <100.00%> (?)
ubuntu-latest_3.8_test_plotting 91.81% <100.00%> (?)
ubuntu-latest_3.9_test_plotting 91.82% <100.00%> (?)
windows-latest_3.10_test_plotting 91.83% <100.00%> (?)
windows-latest_3.11_test_plotting 91.83% <100.00%> (?)
windows-latest_3.12_test_plotting 91.83% <100.00%> (?)
windows-latest_3.8_test_plotting 91.79% <100.00%> (?)
windows-latest_3.9_test_plotting 91.80% <100.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Remi-Gau
Copy link
Collaborator Author

To try a few different cuts

from nilearn import datasets, plotting

stat_img = datasets.load_sample_motor_activation_image()
for i in range(1, 15):
    display = plotting.plot_stat_map(stat_img, display_mode="mosaic", 
                                     annotate=True, 
                                     cut_coords=i, 
                                     output_file=f"test_{i}.png")

@Remi-Gau
Copy link
Collaborator Author

with different number of cuts

test_1
test_7
test_14

@Remi-Gau Remi-Gau requested a review from tsalo February 23, 2024 13:31
Copy link
Member

@tsalo tsalo left a comment

Choose a reason for hiding this comment

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

It looks awesome, thank you! Any chance you could modify the labels as well?

@Remi-Gau
Copy link
Collaborator Author

will do
juggling with a bunch of bug fixes and also trying to deal with admonition in the bids spec and there is only 24 hours in one day... sigh...

@tsalo
Copy link
Member

tsalo commented Feb 23, 2024

There's definitely no rush on my part. Tedana will bump its nilearn requirement only once 0.10.4 is released, which will probably be a couple of months from now.

@Remi-Gau
Copy link
Collaborator Author

probably sooner than this actually

we want to have a quick new release that will just be bug fixes

@tsalo
Copy link
Member

tsalo commented Feb 23, 2024

Ah, in that case, maybe something like the following at line 566?

-        for tick in self._colorbar_ax.yaxis.get_ticklabels():
-            tick.set_color(tick_color)
-        self._colorbar_ax.yaxis.set_tick_params(width=0)
+        self._colorbar_ax.yaxis.set_tick_params(
+            width=0,
+            color=tick_color,
+            labelsize=self._colorbar_width * 100,
+        )

@bthirion
Copy link
Member

Just wondering: isn't it ultimately simpler to reduce the figsize in order to have all labels not dwarfed by the plot size ?

@Remi-Gau Remi-Gau marked this pull request as ready for review February 26, 2024 09:03
@Remi-Gau
Copy link
Collaborator Author

Just wondering: isn't it ultimately simpler to reduce the figsize in order to have all labels not dwarfed by the plot size ?

thanks for the hint @bthirion, changing the default figure size seems easier.

will copy paste a few examples to let you judge

@Remi-Gau
Copy link
Collaborator Author

test_2
test_7
test_10
test_14

@Remi-Gau
Copy link
Collaborator Author

The default figure size is now much more in the range of that of the other displays.

@tsalo
Copy link
Member

tsalo commented Feb 26, 2024

Wow, changing the figure size worked wonders!

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.

@Remi-Gau Remi-Gau merged commit 11db24d into nilearn:main Feb 27, 2024
32 checks passed
@Remi-Gau Remi-Gau deleted the fix/4283 branch February 27, 2024 08:22
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.

[BUG] Colorbar is unreadable with plot_stat_map in mosaic mode
3 participants