Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroJacobLi committed Jul 8, 2023
1 parent eddafaf commit 7ef5489
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ or
```bash
git clone
cd smplotlib
pip install -e .
pip install -e . --user
```

## Usage
Expand All @@ -23,6 +23,11 @@ Then just use `matplotlib.pyplot` as usual. For a quick start, you can use `smpl

![example](two_phase.png)

### More advanced usage
You can use the function ``smplotlib.set_style(fontweight='normal', usetex=False, fontsize=15, figsize=(6, 6), dpi=120)`` to customize the global seetings including font weight, font size, default figure size and resolution, and whether using LaTeX for math. The default font weight is ``'normal'``, and the default setting for LaTeX is ``False``. You can specify font weight as ``'light'`` or ``'heavy'``. Current support for LaTeX is not quite satisfying, so it is recommended to set ``usetex=False``.

You can turn off the black edgecolor of scatter plots by ``smplotlib.set_style(edgecolor='face')``. This is useful when you want to plot a large number of points.

## Hershey font
SuperMongo uses [Hershey fonts](https://www.astro.princeton.edu/~rhl/sm/sm.html#TOC73). The [``ttf`` files](https://github.com/yangcht/Hershey_font_TTF) are from a compilation by astronomer [`yangcht`](https://github.com/yangcht). Thanks for the great work!

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "smplotlib"
version = "0.0.8"
version = "0.0.9"
authors = [
{ name="Jiaxuan Li", email="jiaxuanl@princeton.edu" },
]
Expand Down
20 changes: 13 additions & 7 deletions src/smplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Load style
plt.style.use(os.path.join(pkg_path, 'smplot.mplstyle'))

def set_style(usetex=False, fontsize=15, fontweight='normal', figsize=(6, 6), dpi=120):
def set_style(usetex=False, fontsize=15, fontweight='normal', figsize=(6, 6), dpi=120, edgecolor='black'):
'''
Set matplotlib parameters for SuperMongo style.
Expand All @@ -47,6 +47,8 @@ def set_style(usetex=False, fontsize=15, fontweight='normal', figsize=(6, 6), dp
Figure size. Default is (6, 6).
dpi : int, optional.
Dots per inch. Default is 100.
edgecolor : str, optional.
Edge color. Default is 'black'. If you don't like the black edge, you can set it to 'face'.
'''
rcParams.update({'font.size': fontsize,
'figure.figsize': "{0}, {1}".format(figsize[0], figsize[1]),
Expand All @@ -57,7 +59,15 @@ def set_style(usetex=False, fontsize=15, fontweight='normal', figsize=(6, 6), dp
rcParams.update({
"font.weight": "normal",
"axes.labelweight": "normal",
"mathtext.fontset": "custom"
"mathtext.fontset": "custom",
"mathtext.bf": "AVHershey Complex:medium",
"mathtext.cal": "AVHershey Complex:medium",
"mathtext.it": "AVHershey Complex:italic",
"mathtext.rm": "AVHershey Complex:medium",
"mathtext.sf": "AVHershey Duplex:medium",
"mathtext.tt": "AVHershey Complex:medium",
"mathtext.fallback": "cm",
"mathtext.default": 'it'
})

elif fontweight == 'light':
Expand Down Expand Up @@ -93,11 +103,6 @@ def set_style(usetex=False, fontsize=15, fontweight='normal', figsize=(6, 6), dp
elif fontweight == 'heavy':
rcParams.update({
"axes.linewidth": 0.7,
"xtick.major.width": 0.6,
"xtick.minor.width": 0.5,
"ytick.major.width": 0.6,
"ytick.minor.width": 0.5,
"font.family": "AVHershey Complex",
"font.weight": "heavy",
"axes.labelweight": "heavy",
"mathtext.fontset": "custom",
Expand All @@ -122,6 +127,7 @@ def set_style(usetex=False, fontsize=15, fontweight='normal', figsize=(6, 6), dp
])
})

rcParams.update({'scatter.edgecolors': edgecolor})
smplotlib.set_style()

from .demo import demo_plot

0 comments on commit 7ef5489

Please sign in to comment.