# spt
[](https://pypi.org/project/spt/)
[](https://pypi.org/project/spt)
[](https://python.org/downloads)
<pre style="text-align: center;">
_
___ _ __ | |_
/ __| '_ \| __|
\__ \ |_) | |_
|___/ .__/ \__|
|_|
</pre>
spt: A Scientific Matplotlib plot rcParams configuration template Python package.
- **Repo**: [GitHub](https://github.com/Bit-Part-Young/spt) | [Gitee](https://gitee.com/yangsl306/spt)
---
## Installation
- via pip:
```bash
pip install -U spt
# install spt and examples dependencies
pip install ".[examples]"
```
- via git:
```bash
pip install git+https://github.com/Bit-Part-Young/spt.git
# or
pip install git+https://gitee.com/yangsl306/spt.git
```
- via source code:
```bash
git clone https://github.com/Bit-Part-Young/spt.git
# or
git clone https://gitee.com/yangsl306/spt.git
cd spt
# create virtual environment
python -m venv venv
source venv/bin/activate
pip install .
# or
pip install -r requirements.txt
# editable mode
pip install -e .
```
---
## Usage
Full example codes can be found in [examples](https://github.com/Bit-Part-Young/spt/tree/master/examples) folder.
---
### fonts
- **Times New Roman**: Copy `TimesNewRoman*.ttf` fonts to `~/.fonts` or `~/.local/share/fonts` or matplotlib font path in specific conda env, then remove matplotlib cache, relogin.
```bash
cp fonts/TimesNewRoman*.ttf ~/.fonts
# or
cp fonts/TimesNewRoman*.ttf ~/.local/share/fonts
# or
cp fonts/TimesNewRoman*.ttf <conda_env>/lib/pythonXXX/site-packages/matplotlib/mpl-data/fonts/ttf/
# remove matplotlib cache
rm -rf ~/.cache/matplotlib
# check fonts
fc-list lang:en | grep -i "Times New Roman"
```
- **Chinese**: Copy `SimHei.ttf` font to `~/.fonts` or `~/.local/share/fonts` or matplotlib font path in specific conda env, backup original matplotlibrc file, copy modified matplotlibrc file to `mpl-data` path, then remove matplotlib cache, relogin.
```bash
cp fonts/SimHei.ttf ~/.fonts
# or
cp fonts/SimHei.ttf ~/.local/share/fonts
# or
cp fonts/SimHei.ttf <conda_env>/lib/pythonXXX/site-packages/matplotlib/mpl-data/fonts/ttf/
# backup matplotlibrc file
cp fonts/matplotlibrc <conda_env>/lib/pythonXXX/site-packages/matplotlib/mpl-data/
# remove matplotlib cache
rm -rf ~/.cache/matplotlib
# check fonts
fc-list lang:zh | grep -i "SimHei"
```
---
`matplotlibrc` modification:
```bash
# Original
font.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif
axes.unicode_minus: True # use Unicode for the minus symbol rather than hyphen. See
# Modification
font.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif, SimHei, Times New Roman, Times
axes.unicode_minus: False # use Unicode for the minus symbol rather than hyphen. See
```
---
### set_plot_params()
- code snippets (complete script: [plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot.py)):
```python
import matplotlib.pyplot as plt
from spt.plot_params import set_plot_params
...
set_plot_params()
fig, ax = plt.subplots()
...
```
---
Figure:

---
### set_roman_plot_params()
- code snippets (complete script: [plot_roman.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot_roman.py)):
```python
import matplotlib.pyplot as plt
from spt.plot_params import set_roman_plot_params
...
set_roman_plot_params()
fig, ax = plt.subplots()
...
```
---
Figure:

---
- 3d plot code snippets (complete script: [plot_3d.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot_3d.py)):
```python
import matplotlib.pyplot as plt
from spt.plot_params import set_roman_plot_params
...
set_roman_plot_params(
axes_labelpad=15,
legend_handletextpad=0.0,
legend_fontsize=22,
savefig_bbox="standard",
)
fig, ax = plt.subplots(subplot_kw={"projection": "3d"}, figsize=(10, 8))
...
```
---
Figure:

---
### Chinese characters plot
- code snippets (complete script: [plot_zh.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot_zh.py))
```python
import matplotlib.pyplot as plt
from spt.plot_params import set_roman_plot_params
...
set_roman_plot_params()
fig, ax = plt.subplots()
ax.plot(x, y, label="正弦函数")
ax.set(xlabel="x", ylabel="y")
# legend 字体设置为 SimHei
ax.legend(prop={"family": "SimHei"})
...
```
---
Figure

---
## Scientific Figure Examples
- Example 1 (complete script: [dot_line_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/dot-line-plot/dot_line_plot.py)):
Figure:

---
- Example 2 (complete script: [phase_stability_Nb3Si_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/phase-stability-Nb3Si-plot/phase_stability_Nb3Si_plot.py)):
Figure:

---
- Example 3 (complete script: [b_fit_cal.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/fit-cal-b-plot/b_fit_cal.py)):
Figure:

---
- Example 4 (complete script: [xrd_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/xrd-plot/xrd_plot.py)):
Figure:

- Example 5 (complete script: [ternary_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/ternary-plot/ternary_plot.py)):
Figure:

- Example 5 (complete script: [ternary_convex_hull.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/ternary-convex-hull/ternary_convex_hull.py)):
Figure:

Raw data
{
"_id": null,
"home_page": "https://github.com/Bit-Part-Young/spt",
"name": "spt",
"maintainer": "yangsl",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "yangsl2126@sjtu.edu.cn",
"keywords": "scientific plot, Matplotlib",
"author": "yangsl",
"author_email": "yangsl2126@sjtu.edu.cn",
"download_url": "https://files.pythonhosted.org/packages/03/66/c1813e2ee9cbf899c7f77e5271651041f9a02b1ecc246b7b574a5d0c2783/spt-0.2.5.tar.gz",
"platform": "all",
"description": "# spt\n\n[](https://pypi.org/project/spt/)\n[](https://pypi.org/project/spt)\n[](https://python.org/downloads)\n\n<pre style=\"text-align: center;\">\n _\n ___ _ __ | |_\n/ __| '_ \\| __|\n\\__ \\ |_) | |_\n|___/ .__/ \\__|\n |_|\n</pre>\n\nspt: A Scientific Matplotlib plot rcParams configuration template Python package.\n\n- **Repo**: [GitHub](https://github.com/Bit-Part-Young/spt) | [Gitee](https://gitee.com/yangsl306/spt)\n\n---\n\n## Installation\n\n- via pip:\n\n```bash\npip install -U spt\n\n# install spt and examples dependencies\npip install \".[examples]\"\n```\n\n- via git:\n\n```bash\npip install git+https://github.com/Bit-Part-Young/spt.git\n# or\npip install git+https://gitee.com/yangsl306/spt.git\n```\n\n- via source code:\n\n```bash\ngit clone https://github.com/Bit-Part-Young/spt.git\n# or\ngit clone https://gitee.com/yangsl306/spt.git\n\ncd spt\n\n# create virtual environment\npython -m venv venv\nsource venv/bin/activate\n\npip install .\n# or\npip install -r requirements.txt\n\n# editable mode\npip install -e .\n```\n\n---\n\n## Usage\n\nFull example codes can be found in [examples](https://github.com/Bit-Part-Young/spt/tree/master/examples) folder.\n\n---\n\n### fonts\n\n- **Times New Roman**: Copy `TimesNewRoman*.ttf` fonts to `~/.fonts` or `~/.local/share/fonts` or matplotlib font path in specific conda env, then remove matplotlib cache, relogin.\n\n```bash\ncp fonts/TimesNewRoman*.ttf ~/.fonts\n# or\ncp fonts/TimesNewRoman*.ttf ~/.local/share/fonts\n# or\ncp fonts/TimesNewRoman*.ttf <conda_env>/lib/pythonXXX/site-packages/matplotlib/mpl-data/fonts/ttf/\n\n# remove matplotlib cache\nrm -rf ~/.cache/matplotlib\n\n# check fonts\nfc-list lang:en | grep -i \"Times New Roman\"\n```\n\n- **Chinese**: Copy `SimHei.ttf` font to `~/.fonts` or `~/.local/share/fonts` or matplotlib font path in specific conda env, backup original matplotlibrc file, copy modified matplotlibrc file to `mpl-data` path, then remove matplotlib cache, relogin.\n\n```bash\ncp fonts/SimHei.ttf ~/.fonts\n# or\ncp fonts/SimHei.ttf ~/.local/share/fonts\n# or\ncp fonts/SimHei.ttf <conda_env>/lib/pythonXXX/site-packages/matplotlib/mpl-data/fonts/ttf/\n\n# backup matplotlibrc file\ncp fonts/matplotlibrc <conda_env>/lib/pythonXXX/site-packages/matplotlib/mpl-data/\n\n# remove matplotlib cache\nrm -rf ~/.cache/matplotlib\n\n# check fonts\nfc-list lang:zh | grep -i \"SimHei\"\n```\n\n---\n\n`matplotlibrc` modification:\n\n```bash\n# Original\nfont.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif\naxes.unicode_minus: True # use Unicode for the minus symbol rather than hyphen. See\n\n# Modification\nfont.sans-serif: DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif, SimHei, Times New Roman, Times\naxes.unicode_minus: False # use Unicode for the minus symbol rather than hyphen. See\n```\n\n---\n\n### set_plot_params()\n\n- code snippets (complete script: [plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot.py)):\n\n```python\nimport matplotlib.pyplot as plt\nfrom spt.plot_params import set_plot_params\n\n...\n\nset_plot_params()\n\nfig, ax = plt.subplots()\n\n...\n\n```\n\n---\n\nFigure:\n\n\n\n---\n\n### set_roman_plot_params()\n\n- code snippets (complete script: [plot_roman.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot_roman.py)):\n\n```python\nimport matplotlib.pyplot as plt\nfrom spt.plot_params import set_roman_plot_params\n\n...\n\nset_roman_plot_params()\n\nfig, ax = plt.subplots()\n\n...\n\n```\n\n---\n\nFigure:\n\n\n\n---\n\n- 3d plot code snippets (complete script: [plot_3d.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot_3d.py)):\n\n```python\nimport matplotlib.pyplot as plt\nfrom spt.plot_params import set_roman_plot_params\n\n...\n\nset_roman_plot_params(\n axes_labelpad=15,\n legend_handletextpad=0.0,\n legend_fontsize=22,\n savefig_bbox=\"standard\",\n)\n\nfig, ax = plt.subplots(subplot_kw={\"projection\": \"3d\"}, figsize=(10, 8))\n\n...\n\n```\n\n---\n\nFigure:\n\n\n\n---\n\n### Chinese characters plot\n\n- code snippets (complete script: [plot_zh.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/plot_zh.py))\n\n```python\nimport matplotlib.pyplot as plt\nfrom spt.plot_params import set_roman_plot_params\n\n...\n\nset_roman_plot_params()\n\nfig, ax = plt.subplots()\n\nax.plot(x, y, label=\"\u6b63\u5f26\u51fd\u6570\")\n\nax.set(xlabel=\"x\", ylabel=\"y\")\n\n# legend \u5b57\u4f53\u8bbe\u7f6e\u4e3a SimHei\nax.legend(prop={\"family\": \"SimHei\"})\n\n...\n\n```\n\n---\n\nFigure\n\n\n\n---\n\n## Scientific Figure Examples\n\n- Example 1 (complete script: [dot_line_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/dot-line-plot/dot_line_plot.py)):\n\nFigure:\n\n\n\n---\n\n- Example 2 (complete script: [phase_stability_Nb3Si_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/phase-stability-Nb3Si-plot/phase_stability_Nb3Si_plot.py)):\n\nFigure:\n\n\n\n---\n\n- Example 3 (complete script: [b_fit_cal.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/fit-cal-b-plot/b_fit_cal.py)):\n\nFigure:\n\n\n\n---\n\n- Example 4 (complete script: [xrd_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/xrd-plot/xrd_plot.py)):\n\nFigure:\n\n\n\n- Example 5 (complete script: [ternary_plot.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/ternary-plot/ternary_plot.py)):\n\nFigure:\n\n\n\n- Example 5 (complete script: [ternary_convex_hull.py](https://github.com/Bit-Part-Young/spt/blob/master/examples/ternary-convex-hull/ternary_convex_hull.py)):\n\nFigure:\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "Scientific Matplotlib plot rcParams configuration template python package.",
"version": "0.2.5",
"project_urls": {
"Homepage": "https://github.com/Bit-Part-Young/spt"
},
"split_keywords": [
"scientific plot",
" matplotlib"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6ff16b72138d590473e1a42add9b2bc6bc4255a9690f5b088ff83e662909336c",
"md5": "d886c7475900bfb9a0113bbdaaaf2893",
"sha256": "1ed352679a4205059242c2014e4f0b29d99dd459d21a7db568f58fd1c2f0659b"
},
"downloads": -1,
"filename": "spt-0.2.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d886c7475900bfb9a0113bbdaaaf2893",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 5106,
"upload_time": "2025-08-18T07:51:28",
"upload_time_iso_8601": "2025-08-18T07:51:28.310107Z",
"url": "https://files.pythonhosted.org/packages/6f/f1/6b72138d590473e1a42add9b2bc6bc4255a9690f5b088ff83e662909336c/spt-0.2.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0366c1813e2ee9cbf899c7f77e5271651041f9a02b1ecc246b7b574a5d0c2783",
"md5": "b7116177be6dccd98e561c6cfcd751ce",
"sha256": "5b2087596dee798c2ba13a73d988f479598d62461531182a5157657e6f6a0299"
},
"downloads": -1,
"filename": "spt-0.2.5.tar.gz",
"has_sig": false,
"md5_digest": "b7116177be6dccd98e561c6cfcd751ce",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 5881,
"upload_time": "2025-08-18T07:51:29",
"upload_time_iso_8601": "2025-08-18T07:51:29.619508Z",
"url": "https://files.pythonhosted.org/packages/03/66/c1813e2ee9cbf899c7f77e5271651041f9a02b1ecc246b7b574a5d0c2783/spt-0.2.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-18 07:51:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Bit-Part-Young",
"github_project": "spt",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "matplotlib",
"specs": []
}
],
"lcname": "spt"
}