-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
feature request: relative linewidth and markersize #10173
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
Comments
I think something like that is doable and probably worth the extra code complexity if its well designed, but we'd need to work out a spec. I doubt it needs a whole MEP, but can you sketch out more fullsomely the API you'd like to see? After that, if you wanted to take a try at implimenting it, folks here could help. |
@jklymak : here is a first attempt to work out the spec Basically, the user would be able to specify linewidth/markersize/markeredgewidth property values as either a float (in points) or a text string. In the latter case, the user can either specify:
Examples: obj.set_linewidth(2.) # set width in points
obj.set_linewdith('3.5 pt') # set width in points
obj.set_linewidth('1 mm') # set width in mm
obj.set_linewidth('0.01 in') # set width in inch
obj.set_linewidth('20%') # set width to 20% of base value
obj.set_linewidth('0.2x') # set width to 0.2 * base value
obj.set_linewidth('x-thick') # set width to base value * base scale**exp['x-thick']
obj.set_markersize('x-small') # for sizes use small/large, for widths use thin/thick For each property two new rcParams would be needed, e.g. for linewidth
Here is a gist of what a parser of these width/size values could look like, as well as the possible changes needed to set/get_linewidth methods. Looking forward to your feedback and suggestions. |
I would also put the If we do this for My biggest concern with this is that the scope will quickly balloon. If we can specify the linewidth as '1 in', then for consistency people will expect to be able to specify other sizes that way as well. Off the top of my head I think 'fontsize' (which already does the relative sizes), marker size and markeredgewidth would also need this. Are there others I am missing? May be Why not just use the current linewith rcParams as the base? I am not sure that we also need a scale rcparam (do we have one of those for the relative text scaling?). |
The artists with a set_linewidth method are Line2D, Patch and Collection, and Line2D is the only artist with set_markeredgewidth and set_markersize methods. Ticks.set_ticksize would be another one to consider and so is FontProperties.set_size (to be consistent, like you said). So, yes, all these methods would see (minor) changes without altering their default behavior (I think). I suppose it is possible to use lines.linewidth rcParams as the base width, instead of creating a new rcParams entry. From what I understand, this is basically how it is done for text font size. There would be a slight inconsistency in that lines.linewidth can only take absolute width values, whereas other line width rcParams can be set to either absolute or relative widths. The scale parameter just provides extra flexibility, but it may not be needed if we can find a good fixed scale that works well. For font sizes the scale is fixed to 1.2 |
I think being able to specify absolute units ('in', 'cm', 'em' etc) is a wishlist item that shouldn't hold back this idea. See #9226 For now I think
If there is a separate |
@jklymak Initially, I added fractional sizes (represented as string) as well, but I ran into problems when running the tests. It turns out that when rcParams are loaded from style files through Let me know if the PR is going in the right direction. |
One issue that needs to be taken care of is (as always with styling proposals) when does the relative size actually get converted to an actual size? i.e. if I later change the base size, is that supposed to modify what gets drawn? |
@anntzer |
I think that's reasonable. While I'm sure it happens that users change the rcParam in their code, I think its reasonable to not expect it to retroactively change a line width. |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
It would be nice to be able to specify line widths, marker edge width and marker size relative to a configurable base value (similar to 'small' / 'medium' / 'large' font size). This would be particularly helpful when working with style sheets.
The text was updated successfully, but these errors were encountered: