mpl-interactions 项目教程
1. 项目的目录结构及介绍
mpl-interactions/
├── LICENSE
├── README.md
├── setup.py
├── mpl_interactions/
│ ├── __init__.py
│ ├── controller.py
│ ├── deprecations.py
│ ├── generic.py
│ ├── pyplot.py
│ ├── utils.py
│ ├── widgets.py
│ ├── examples/
│ │ ├── basic_example.py
│ │ ├── heatmap_slicer.py
│ │ ├── zooming_panning.py
│ │ └── ...
│ └── tests/
│ ├── test_controller.py
│ ├── test_deprecations.py
│ ├── test_generic.py
│ ├── test_pyplot.py
│ ├── test_utils.py
│ ├── test_widgets.py
│ └── ...
└── docs/
├── conf.py
├── index.rst
├── installation.rst
├── usage.rst
└── ...
目录结构介绍
- LICENSE: 项目的开源许可证文件。
- README.md: 项目的介绍和使用说明。
- setup.py: 项目的安装脚本。
- mpl_interactions/: 项目的主要代码目录。
- init.py: 模块初始化文件。
- controller.py: 控制器相关代码。
- deprecations.py: 废弃功能相关代码。
- generic.py: 通用功能相关代码。
- pyplot.py: Matplotlib 的交互功能实现。
- utils.py: 工具函数。
- widgets.py: 交互控件相关代码。
- examples/: 示例代码目录,包含多个示例脚本。
- tests/: 测试代码目录,包含多个测试脚本。
- docs/: 项目文档目录,包含配置文件和文档文件。
2. 项目的启动文件介绍
项目的启动文件主要是 setup.py
,它是一个标准的 Python 安装脚本,用于安装和配置项目。通过运行 python setup.py install
可以安装项目及其依赖项。
3. 项目的配置文件介绍
项目的配置文件主要有两个:
- setup.py: 用于配置项目的安装选项、依赖项和元数据。
- docs/conf.py: 用于配置项目的文档生成选项,如 Sphinx 文档生成器的配置。
setup.py
setup.py
文件的主要内容包括:
from setuptools import setup, find_packages
setup(
name='mpl_interactions',
version='0.24.1',
description='Easy interactive Matplotlib plots',
long_description=open('README.md').read(),
long_description_content_type='text/markdown',
author='Ian Hunt-Isaak',
author_email='ianhuntisaak@gmail.com',
url='https://github.com/mpl-extensions/mpl-interactions',
packages=find_packages(),
install_requires=[
'matplotlib',
'numpy',
'ipywidgets',
'ipympl',
],
extras_require={
'jupyter': ['jupyterlab', 'notebook'],
},
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
],
)
docs/conf.py
docs/conf.py
文件的主要内容包括:
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
project = 'mpl_interactions'
copyright = '2023, Ian Hunt-Isaak'
author = 'Ian Hunt-Isaak'
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
]
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
html_theme = 'alabaster'
html_static_path = ['_static']
以上是 mpl-interactions
项目的基本教程,涵盖了项目的目录结构、启动文件和配置文件的介绍。