Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Horizontal radio buttons#13374
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Horizontal radio buttons#13374
Conversation
Uh oh!
There was an error while loading.Please reload this page.
jklymak commentedFeb 6, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
flake8 needs to pass 😉https://travis-ci.org/matplotlib/matplotlib/jobs/489577517 |
NelleV left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for the PR@mromanie !
Here are a couple of comments. I'll do a more thorough review once these are addressed.
Can you in addition add a what's new entry? See doc/users/next_whats_new/README.rst
lib/matplotlib/widgets.py Outdated
| The orientation of the buttons: 'vertical' (default), or 'horizontal'. | ||
| """ | ||
| iforientationnotin ['vertical','horizontal']: | ||
| raiseValueError("Invalid RadioButton orientation: %s"%orientation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you add what are the possible values here?
Can you also add a mock test to make sure it runs, as well as a test to make sure this exception is raised properly.
I also think we need to update the examples to show case this (examples/widgets/radio_buttons.py)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We have a shortcut function to check options like this and raise an appropriate error now,cbook._check_in_list
lib/matplotlib/widgets.py Outdated
| activecolor : color | ||
| The color of the selected button. | ||
| orientation : str | ||
| The orientation of the buttons: 'vertical' (default), or 'horizontal'. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The keyword being a bit confusing here, I think it's worth detailing a bit more what orientation means (which is the set of radio buttons are on the same horizontal axis or vertical axis).
NelleV commentedFeb 6, 2019
For the failing flake8 test, I would suggest adding the check directly to your text editor. |
timhoffm commentedFeb 16, 2019
Milestoning 3.2 as there has not been activity recently.@mromanie are you still interested to work on this? |
mromanie commentedFeb 17, 2019
@timhoffm Apologies for my inactivity. I am indeed still very much interested in working on this. In fact, I think I managed to do it properly by using patches.Ellipse instead of patches.Circle and stretching them to look circular using the aspects of the axes and figure. In this way, the entire surface of the buttons is sensitive, unlike the current implementation with patches.Circle. I still need to clean up the auto-scaling of the size of the symbols, which at the moment still results in the symbols to overlap under certain circumstances, and I'll submit the whole lot for review. Shall I use the same PR for this? |
ImportanceOfBeingErnest commentedFeb 17, 2019
What about using a |
mromanie commentedFeb 17, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@ImportanceOfBeingErnest I'm not familiar with
Plus a couple more things to make it backwards compatible. Like I said earlier, setting circle_radius to a fixed value is not always satisfactory and I' fine-tuning it. |
mromanie commentedFeb 17, 2019
...forgot to say, the condition to activate the Ellipse button is:
|
ImportanceOfBeingErnest commentedFeb 17, 2019
If you plot a |
mromanie commentedFeb 18, 2019
OK, thanks! All things considered, I would stick to the solution with Ellipse because:
|
ImportanceOfBeingErnest commentedMar 11, 2019
Not sure what the status is here. Since someone asked a question about horizontal buttons on stackoverflow, I thought it might be worth showing a solution over there:https://stackoverflow.com/questions/55095111/displaying-radio-buttons-horizontally-in-matplotlib/55102639#55102639 Of course this could also be used for this update. |
QuLogic commentedOct 3, 2020
This looks mostly done, but needs a rebase and a small tweak to the checks. The squashing is something that affects vertical buttons too, so could be a separate PR. |
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| The `.RadioButtons` widget's primary layout direction may now be specified with | ||
| the *orientation* keyword argument: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Isorientation the right name? I know we use it in some places, but more in the sense of rotation than arrangement.
Possible alternatives: arrangement, direction, layout, ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We use orientation for direction of grouped things in boxplot (and internally in bars)
https://matplotlib.org/devdocs/users/next_whats_new/boxplot_orientation.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Boxplot is a counter example. There (as well as bar) it's associated with the rotation of the box = direction of the whiskers. "Vertical" means the distribution is along the y axis and multiple boxes are arranged side-by-side horizontally.
In contrast, here "vertical" would mean multiple radio buttons are arranged stacked vertically.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah, I'd say "pack_direction" or "layout_direction". This isn't going to be a heavily used kwarg, so we can be verbose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
"layout_direction" sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
With respect to#27946 (comment), is that something we want to useorientation for (giving that this change would be moving towardlayout_direction)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Do you mean text above or to the side of the button? I would not make this configurable but always put the text to the side. This is marginally more work, but the standard look and feel of radio buttons. If we want to add the horizontal layout, IMHO we have to do it properly.
A new optional keyword argument 'layout_direction' is introduced tocontrol it. The new parameter defaults to 'vertical' for backwardscompatibility.
f76df0a tob82537aComparerbroders commentedMar 12, 2025
Are you guys still working on this? Its been 5 years for what seems like a trivial (but very useful) feature |
doronbehar commentedMar 12, 2025
I'm using this patch locally and it has been working fine for me for a while now. |
mromanie commentedMar 12, 2025 via email
Yeah, sorry: I originated this and then overlooked to complete it. Anything I should do now? Thanks!Ciao,Martino--Due to my own family/work balance, you may receive emails from me outside of normal working hours. I do not expect a response from you outside of your own working pattern, nor do I expect an immediate response when you are working.From: Doron Behar ***@***.***>Reply to: matplotlib/matplotlib ***@***.***>Date: Wednesday, 12. March 2025 at 08:56To: matplotlib/matplotlib ***@***.***>Cc: Martino Romaniello ***@***.***>, Mention ***@***.***>Subject: Re: [matplotlib/matplotlib] Horizontal radio buttons (#13374)This email was sent from outside of ESO from the address ***@***.***. If it looks suspicious, please report it to ***@***.***I'm using this patch locally and it has been working fine for me for a while now.—Reply to this email directly, view it on GitHub<#13374 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AE5K2YYOOHOR4BRYUT6QMVD2T7R7RAVCNFSM6AAAAABY2HAI2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJWHE3DCNBXGI>.You are receiving this because you were mentioned.Message ID: ***@***.***>[Image removed by sender. doronbehar]doronbehar left a comment (matplotlib/matplotlib#13374)<#13374 (comment)>I'm using this patch locally and it has been working fine for me for a while now.—Reply to this email directly, view it on GitHub<#13374 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AE5K2YYOOHOR4BRYUT6QMVD2T7R7RAVCNFSM6AAAAABY2HAI2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDOMJWHE3DCNBXGI>.You are receiving this because you were mentioned.Message ID: ***@***.***> |
| .. versionadded:: 3.7 | ||
| layout_direction : {'vertical', 'horizontal'} | ||
| The orientation of the buttons: 'vertical' places buttons from top | ||
| to bottom, 'horizontal' places buttons from left to right. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| tobottom,'horizontal'placesbuttonsfromlefttoright. | |
| tobottom,'horizontal'placesbuttonsfromlefttoright,distributing | |
| thebuttonsacrossthewholeAxes.TheAxesisdividedintoequal-sized | |
| boxes,andeachbuttonisleft-alignedinthebox.Thereiscurrentlyno | |
| sizecheckwiththeassociatedlabels,sothatlonglabelsmayoverlap | |
| withthenextbox. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sorry, I did not check what this actually does:
I strongly think we should follow standard conventions that labels are right of the button not above, because I consider the unusual layout a UX issue. See also#27946 (comment).
| The orientation of the buttons: 'vertical' places buttons from top | ||
| to bottom, 'horizontal' places buttons from left to right. | ||
| .. versionadded:: 3.10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
| ..versionadded::3.10 | |
| ..versionadded::3.11 |
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
story645 commentedJun 6, 2025
It looks like there isn't much left to do here,@mromanie do you have the bandwidth to do so or are you okay w/ someone else closing this out? |
timhoffm commentedJun 6, 2025
Um, I disagree#13374 (comment) |
mromanie commentedJun 6, 2025 via email
I’m off for three weeks now, so I’d be very happy with someone closing this out … thanks! …--Due to my own family/work balance, you may receive emails from me outside of normal working hours. I do not expect a response from you outside of your own working pattern, nor do I expect an immediate response when you are working.From: hannah ***@***.***>Reply to: matplotlib/matplotlib ***@***.***>Date: Friday, 6. June 2025 at 16:40To: matplotlib/matplotlib ***@***.***>Cc: Martino Romaniello ***@***.***>, Mention ***@***.***>Subject: Re: [matplotlib/matplotlib] Horizontal radio buttons (#13374)This email was sent from outside of ESO from the address ***@***.***. If it looks suspicious, please report it to ***@***.***[Image removed by sender.]story645 left a comment (matplotlib/matplotlib#13374)<#13374 (comment)>It looks like there isn't much left to do here,@mromanie<https://github.com/mromanie> do you have the bandwidth to do so or are you okay w/ someone else closing this out?—Reply to this email directly, view it on GitHub<#13374 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AE5K2Y2H7GWEDE7C7QSEOVL3CGR6PAVCNFSM6AAAAABY2HAI2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNBZGQ3TKMRRGI>.You are receiving this because you were mentioned.Message ID: ***@***.***> |
story645 commentedJun 6, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
To me put labels next to rather than on top reads like a relatively small/clear change if there's agreement that that should be the position. What am I missing here? |
mromanie commentedJun 6, 2025 via email
My two cents … I had put them on top to make the layout more compact and save space, I think, but either way is fine … …--Due to my own family/work balance, you may receive emails from me outside of normal working hours. I do not expect a response from you outside of your own working pattern, nor do I expect an immediate response when you are working.From: hannah ***@***.***>Reply to: matplotlib/matplotlib ***@***.***>Date: Friday, 6. June 2025 at 17:54To: matplotlib/matplotlib ***@***.***>Cc: Martino Romaniello ***@***.***>, Mention ***@***.***>Subject: Re: [matplotlib/matplotlib] Horizontal radio buttons (#13374)This email was sent from outside of ESO from the address ***@***.***. If it looks suspicious, please report it to ***@***.***[Image removed by sender.]story645 left a comment (matplotlib/matplotlib#13374)<#13374 (comment)>It looks like there isn't much left to do hereUm, I disagree#13374 (comment)<#13374 (comment)>To me put labels next to rather than on top reads like a small change if there's agreement that that should be the position.What am I missing here?—Reply to this email directly, view it on GitHub<#13374 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AE5K2Y7WHZ6EZ25PZCGLBRD3CG2T3AVCNFSM6AAAAABY2HAI2KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNBZG4ZDENRSHA>.You are receiving this because you were mentioned.Message ID: ***@***.***> |
timhoffm commentedJun 6, 2025
That depends on your size of small 😆. Putting the buttons above the text a bit simpler because you only calculate the centers and center-align text and button to these coordianates. For horizontal, you have to think a bit more: What is the starting point for each buttom+text group, how much offset does the text need from the button? It's not terribly complicated, but needs a bit more effort. |
marko-pi commentedOct 22, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
For my purposes, I would prefer the labels to the right of the circles. Horizontal radio buttons are supposed to be used when vertical space is limited. Placing labels above the circles reduces the efficiency of the solution. |
timhoffm commentedOct 22, 2025
This is not a priority of the core developers. So unless somebody steps up to contribute, it won’t be implemented soon. |
story645 commentedOct 22, 2025
Just to add to this, one way to contribute is to take over this orphaned PR and get it to the finish line by addressing/implementing the feedback in#13374 (comment) |


PR Summary
Add the option to have horizontal RadioButtons. A new optional keyword argument 'direction' is introduced to control it. The new parameter defaults to 'vertical' for backwards compatibility.
PR Checklist