Skip to content

Commit

Permalink
feat(combine): read DPI from matplotlib params
Browse files Browse the repository at this point in the history
  • Loading branch information
engeir committed May 1, 2024
1 parent 33da292 commit eabbe92
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cosmoplots/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self) -> None:
self._color = "black"
self._ft: str = ".png"
self._output = pathlib.Path(f"output{self._ft}")
self._dpi = int(plt.rcParams["savefig.dpi"])
self._files: list[pathlib.Path] = []
self._labels: list[str] = []
self._w: int | None = None
Expand Down Expand Up @@ -150,14 +151,18 @@ def _create_labels(self) -> list[str]:
count += 1
return characters

def save(self, output: pathlib.Path | str | None = None) -> None:
def save(self, output: pathlib.Path | str | None = None, dpi: int | None = None) -> None:
"""Save the combined images as a png file.
Parameters
----------
output : pathlib.Path | str, optional
Give the name of the output file, default is `output.png`.
dpi : int, optional
The resolution that the input files were saved with. Default is the same as
the matplotlib savefig dpi.
"""
self._dpi = dpi or self._dpi
self._check_params_before_save(output)
self._check_cli_available()
self._run_subprocess()
Expand Down Expand Up @@ -220,7 +225,7 @@ def _run_subprocess(self) -> None:
"PixelsPerInch",
file,
"-density",
"300",
str(self._dpi),
"-font",
self._font,
"-pointsize",
Expand Down

0 comments on commit eabbe92

Please sign in to comment.