Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[MNT]: Refactor kwargs of Tick constructor #26008

Open
@anntzer

Description

@anntzer

Summary

Currently, the Tick constructor smashes together kwargs specific to it, kwargs for the tickmarkers, for the labels, and for the gridline:

def__init__(self,axes,loc,*,# globalsize=None,# tickmarker propertywidth=None,# tickmarker propertycolor=None,# globaltickdir=None,# tickmarker (not a property)pad=None,# globallabelsize=None,# label propertylabelcolor=None,# label propertylabelfontfamily=None,# label propertyzorder=None,# globalgridOn=None,# gridline (property: ~visible)tick1On=True,# tick (property, but specific to each tick)tick2On=True,# tick (property, but specific to each tick)label1On=True,# label (property, but specific to each label)label2On=False,# label (property, but specific to each label)major=True,# globallabelrotation=0,# label propertygrid_color=None,# grid propertygrid_linestyle=None,# grid propertygrid_linewidth=None,# grid propertygrid_alpha=None,# grid property**kwargs,# grid properties    ):

The remaining kwargs are implicitly assumed to all start with "grid_" and further interpreted as grid properties (viagrid_kw = {k[5:]: v for k, v in kwargs.items()}) -- note that this prefix is internally added byAxis.grid() to kwargs passed to it.

Proposed fix

We should at least check whether remaining kwargs indeed start with "grid_" and error out if that's not the case (Probably few people actually manually construct Ticks, but Tick(abcdecolor="k")) should certainly not be interpreted as Tick(grid_color="k") anyways.)

It may make sense to try to group the kwargs a bit more and not try to repeat all relevant properties in the Tick constructor, e.g. (not writing out the defaults)

def__init__(self,axes,loc,*,major,tickdir,pad,color,zorder,# globaltick_props,tick1On,tick2On,# tick propertieslabel_props,label1On,label2On,# label propertiesgrid_props,# grid properties):

(probably kwargs could be normalized in this form as soon as one populates Axis._major_tick_kw/_minor_tick_kw)

Inspired by#25910.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp