diff --git a/docs/index.rst b/docs/index.rst index e71195d..ebd2c55 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -29,6 +29,8 @@ The `modflow-devtools` package provides a set of tools for developing and testin :caption: Miscellaneous md/download.md + md/figspec.md + md/latex.md md/ostags.md md/zip.md md/timed.md diff --git a/docs/md/figspec.md b/docs/md/figspec.md index e69de29..1399bae 100644 --- a/docs/md/figspec.md +++ b/docs/md/figspec.md @@ -0,0 +1,33 @@ +# Plot styles + +Matplotlib is an optional dependency, installable via e.g. `pip install modflow_devtools[optional]`. + +## `USGSFigure` + +A convenience class `modflow_devtools.figspec.USGSFigure` is provided to create figures with the default USGS style sheet. For instance: + +```python +# create figure +fs = USGSFigure(figure_type="graph", verbose=False) + +# ...add some plots + +# add a heading +title = f"Layer {ilay + 1}" +letter = chr(ord("@") + idx + 2) +fs.heading(letter=letter, heading=title) + +# add an annotation +fs.add_annotation( + ax=ax, + text="Well 1, layer 2", + bold=False, + italic=False, + xy=w1loc, + xytext=(w1loc[0] - 3200, w1loc[1] + 1500), + ha="right", + va="center", + zorder=100, + arrowprops=arrow_props, +) +``` \ No newline at end of file diff --git a/docs/md/latex.md b/docs/md/latex.md index e69de29..61d76a5 100644 --- a/docs/md/latex.md +++ b/docs/md/latex.md @@ -0,0 +1,3 @@ +# LaTeX utilities + +The `modflow_devtools.latex` module provides utility functions for building LaTeX tables from arrays. \ No newline at end of file diff --git a/modflow_devtools/latex.py b/modflow_devtools/latex.py index 8639f59..5d6f5eb 100644 --- a/modflow_devtools/latex.py +++ b/modflow_devtools/latex.py @@ -24,11 +24,8 @@ def build_table(caption, fpth, arr, headings=None, col_widths=None): # footer line += get_footer() - f = open(fpth, "w") - f.write(line) - f.close() - - return + with open(fpth, "w") as f: + f.write(line) def get_header(