spt


Namespt JSON
Version 0.2.4 PyPI version JSON
download
home_pagehttps://github.com/Bit-Part-Young/spt
SummaryScientific matplotlib plot rcParams configuration template python package.
upload_time2024-10-25 15:27:39
maintaineryangsl
docs_urlNone
authoryangsl
requires_python>=3.9
licenseNone
keywords matplotlib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # spt

[![CI Status](https://github.com/Bit-Part-Young/spt/actions/workflows/mkdocs-deploy.yml/badge.svg)](https://github.com/Bit-Part-Young/spt/actions/workflows/mkdocs-deploy.yml)
[![PyPi](https://img.shields.io/pypi/v/spt?logo=pypi&logoColor=white&label=PyPI)](https://pypi.org/project/spt/)
[![PyPI Downloads](https://img.shields.io/pypi/dm/spt?logo=pypi&logoColor=white&color=blue&label=PyPI%20downloads)](https://pypi.org/project/spt)
[![Requires Python 3.8+](https://img.shields.io/badge/Python-3.8+-blue.svg?logo=python&logoColor=white)](https://python.org/downloads)

<pre style="text-align: center;">
           _
 ___ _ __ | |_
/ __| '_ \| __|
\__ \ |_) | |_
|___/ .__/ \__|
    |_|
</pre>

spt: A Scientific matplotlib plot rcParams configuration template python package.

- **Repo**: [https://github.com/Bit-Part-Young/spt](https://github.com/Bit-Part-Young/spt)
- **Full Documentation**: [README.md](https://github.com/Bit-Part-Young/spt) / [Web](https://seekanotherland.xyz/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

# 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:

![sin.png](./assets/figures/sin.png)

---

### 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:

![sin_roman.png](./assets/figures/sin_roman.png)

---

- 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:

![scatter_3d.png](./assets/figures/scatter_3d.png)

---

### 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

![sin_zh.png](./assets/figures/sin_zh.png)

---

## 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:

![dot_line.png](./assets/figures/dot_line.png)

---

- 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:

![substitution_energy_Nb3Si.png](./assets/figures/substitution_energy_Nb3Si.png)

---

- 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:

![b_fit_cal.png](./assets/figures/b_fit_cal.png)

---

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

Figure:

![xrd.png](./assets/figures/xrd.png)

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

Figure:

![AlMoZr_ternary.png](./assets/figures/AlMoZr_ternary.png)

- 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:

![AlMoZr_convex_hull.png](./assets/figures/AlMoZr_convex_hull.png)

            

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": "330839708@qq.com",
    "keywords": "matplotlib",
    "author": "yangsl",
    "author_email": "3304839708@qq.com",
    "download_url": "https://files.pythonhosted.org/packages/df/75/516095592e324ac31fbf52b77b7732a0731962094d21f8b09ba39261fd88/spt-0.2.4.tar.gz",
    "platform": "all",
    "description": "# spt\n\n[![CI Status](https://github.com/Bit-Part-Young/spt/actions/workflows/mkdocs-deploy.yml/badge.svg)](https://github.com/Bit-Part-Young/spt/actions/workflows/mkdocs-deploy.yml)\n[![PyPi](https://img.shields.io/pypi/v/spt?logo=pypi&logoColor=white&label=PyPI)](https://pypi.org/project/spt/)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/spt?logo=pypi&logoColor=white&color=blue&label=PyPI%20downloads)](https://pypi.org/project/spt)\n[![Requires Python 3.8+](https://img.shields.io/badge/Python-3.8+-blue.svg?logo=python&logoColor=white)](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**: [https://github.com/Bit-Part-Young/spt](https://github.com/Bit-Part-Young/spt)\n- **Full Documentation**: [README.md](https://github.com/Bit-Part-Young/spt) / [Web](https://seekanotherland.xyz/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# 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![sin.png](./assets/figures/sin.png)\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![sin_roman.png](./assets/figures/sin_roman.png)\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![scatter_3d.png](./assets/figures/scatter_3d.png)\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![sin_zh.png](./assets/figures/sin_zh.png)\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![dot_line.png](./assets/figures/dot_line.png)\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![substitution_energy_Nb3Si.png](./assets/figures/substitution_energy_Nb3Si.png)\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![b_fit_cal.png](./assets/figures/b_fit_cal.png)\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![xrd.png](./assets/figures/xrd.png)\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![AlMoZr_ternary.png](./assets/figures/AlMoZr_ternary.png)\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![AlMoZr_convex_hull.png](./assets/figures/AlMoZr_convex_hull.png)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Scientific matplotlib plot rcParams configuration template python package.",
    "version": "0.2.4",
    "project_urls": {
        "Homepage": "https://github.com/Bit-Part-Young/spt"
    },
    "split_keywords": [
        "matplotlib"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "730a459a6217be26d5b4cbb9a0a818db1b6252c556cf7351a5e741bae80abf4e",
                "md5": "d475527c949fd3bb3bc92a7c0a9cd411",
                "sha256": "177d6428eafeb0a6e5db8a3af9bf03fa5e659ba695b9cdb27c83bc5b703869a5"
            },
            "downloads": -1,
            "filename": "spt-0.2.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d475527c949fd3bb3bc92a7c0a9cd411",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 5103,
            "upload_time": "2024-10-25T15:27:37",
            "upload_time_iso_8601": "2024-10-25T15:27:37.819824Z",
            "url": "https://files.pythonhosted.org/packages/73/0a/459a6217be26d5b4cbb9a0a818db1b6252c556cf7351a5e741bae80abf4e/spt-0.2.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "df75516095592e324ac31fbf52b77b7732a0731962094d21f8b09ba39261fd88",
                "md5": "4878bb140f4a019319959f70274a53e5",
                "sha256": "db4fc35c7cb087c20fdd3d2a84cecc3eba30df416a15125bfb328561670b6a10"
            },
            "downloads": -1,
            "filename": "spt-0.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "4878bb140f4a019319959f70274a53e5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 5728,
            "upload_time": "2024-10-25T15:27:39",
            "upload_time_iso_8601": "2024-10-25T15:27:39.094122Z",
            "url": "https://files.pythonhosted.org/packages/df/75/516095592e324ac31fbf52b77b7732a0731962094d21f8b09ba39261fd88/spt-0.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-25 15:27:39",
    "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": [],
    "lcname": "spt"
}
        
Elapsed time: 0.68518s