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

PoC: Document each rcParam individually#28930

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

Draft
QuLogic wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromQuLogic:doc-rcparams
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletiondoc/conf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -124,8 +124,9 @@ def _parse_skip_subdirs_file():
'sphinxext.math_symbol_table',
'sphinxext.missing_references',
'sphinxext.mock_gui_toolkits',
'sphinxext.skip_deprecated',
'sphinxext.rcparams',
'sphinxext.redirect_from',
'sphinxext.skip_deprecated',
'sphinx_copybutton',
'sphinx_design',
'sphinx_tags',
Expand Down
62 changes: 62 additions & 0 deletionsdoc/sphinxext/rcparams.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
import enum

from docutils.parsers.rst import Directive

from matplotlib import rcParams, rcParamsDefault, rcsetup


def determine_type(validator):
if isinstance(validator, enum.EnumType):
return f'`~._enums.{validator.__name__}`'
elif docstr := getattr(validator, '__doc__'):
return docstr
else:
return str(validator)


def run(state_machine):
lines = []
current_section = None
for rc in sorted(rcParams.keys()):
if rc[0] == '_':
continue

# This would be much easier with #25617.
section = rc.rsplit('.', maxsplit=1)[0]
if section != current_section:
lines.append(f'.. _rc-{section}:')
current_section = section

type_str = determine_type(rcsetup._validators[rc])
if rc in rcParamsDefault and rc != "backend":
default = f', default: {rcParamsDefault[rc]!r}'
else:
default = ''
lines += [
f'.. _rc-{rc}:',
'',
rc,
'^' * len(rc),
f'{type_str}{default}',
f' Documentation for {rc}.'
]
state_machine.insert_input(lines, "rcParams table")
return []


class RcParamsDirective(Directive):
has_content = False
required_arguments = 0
optional_arguments = 0
final_argument_whitespace = False
option_spec = {}

def run(self):
return run(self.state_machine)


def setup(app):
app.add_directive("rcparams", RcParamsDirective)

metadata = {'parallel_read_safe': True, 'parallel_write_safe': True}
return metadata
17 changes: 8 additions & 9 deletionsgalleries/users_explain/customizing.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -108,10 +108,10 @@ def plotting_function():
# ignored in style sheets see `matplotlib.style.use`.
#
# There are a number of pre-defined styles :doc:`provided by Matplotlib
# </gallery/style_sheets/style_sheets_reference>`. For
#example, there's a pre-definedstyle called "ggplot", which emulates the
#aesthetics of ggplot_(a popular plotting package forR_). To use this
# style, add:
# </gallery/style_sheets/style_sheets_reference>`. For example, there's a pre-defined
# style called "ggplot", which emulates the aesthetics of `ggplot
#<https://ggplot2.tidyverse.org/>`_(a popular plotting package for`R
#<https://www.r-project.org/>`_). To use thisstyle, add:

plt.style.use('ggplot')

Expand DownExpand Up@@ -259,11 +259,10 @@ def plotting_function():
#
# .. _matplotlibrc-sample:
#
#The default :file:`matplotlibrc` file
# -------------------------------------
#Available ``rcParams``
# ----------------------
#
# .. literalinclude:: ../../../lib/matplotlib/mpl-data/matplotlibrc
#
# .. rcparams::
#
#
# .. _ggplot: https://ggplot2.tidyverse.org/
# .. _R: https://www.r-project.org/
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp