Skip to content

Settings

Starplot has a few global settings:

  • Language
  • Data download path
  • DuckDB extension path
  • SVG text rendering method

You can override these values in two ways: through code or through environment variables.

Code

To set values through code, just import the settings object:

from starplot import settings

settings.svg_text_type = "element"

# Create your plot and enjoy your editable text :)

There's also a context manager that lets you temporarily override settings:

from starplot import override_settings

with override_settings(language="zh-cn"):
    ...
    # all default labels plotted in here will be in Chinese

# after exiting the context manager, language will revert to the default (en-us)

Environment Variables

To set values through environment variables, just add the STARPLOT_ prefix to the setting name (and uppercase the entire name):

STARPLOT_DOWNLOAD_PATH=/home/myuser/downloads

starplot.config.Settings dataclass

download_path class-attribute instance-attribute

download_path: Path = field(
    default_factory=_get_path("STARPLOT_DOWNLOAD_PATH", DATA_PATH / "downloads")
)

Path for downloaded data, including the Big Sky catalog, ephemeris files, etc.

Default = <starplot_source_path>/data/library/downloads/

duckdb_extension_path class-attribute instance-attribute

duckdb_extension_path: Path = field(
    default_factory=_get_path(
        "STARPLOT_DUCKDB_EXTENSION_PATH", DATA_PATH / "duckdb-extensions"
    )
)

Path for the DuckDB spatial extension, which is required for the data backend.

Default = <starplot_source_path>/data/library/duckdb-extensions/

language class-attribute instance-attribute

language: str = field(default_factory=lambda: get("STARPLOT_LANGUAGE", "en-US"))

Default language for plotted labels, as an ISO-639 code. Case insensitive.

Supported values:

  • en-US = English
  • fr = French
  • zh-CN = Chinese. Make sure you have a good Chinese font installed (such as Noto Sans SC) and you'll also need to set that as the font in your plot's style.
  • lt = Lithuanian

🌐 Want to see another language available? Please help us add it! Details here.

svg_text_type class-attribute instance-attribute

svg_text_type: SvgTextType = field(
    default_factory=lambda: get("STARPLOT_SVG_TEXT_TYPE", PATH)
)

Method for rendering text in SVG exports:

  • "path" (default) will render all text as paths. This will increase the filesize, but allow all viewers to see the font correctly (even if they don't have the font installed on their system).

  • "element" will render all text as an SVG <text> element, which means the text will be editable in graphic design applications but the text may render in a system default font if the original font isn't available. Important: when using the "element" method, text borders will be turned OFF.

__init__

__init__(
    download_path: Path = _get_path(
        "STARPLOT_DOWNLOAD_PATH", DATA_PATH / "downloads"
    )(),
    duckdb_extension_path: Path = _get_path(
        "STARPLOT_DUCKDB_EXTENSION_PATH", DATA_PATH / "duckdb-extensions"
    )(),
    svg_text_type: SvgTextType = lambda: get("STARPLOT_SVG_TEXT_TYPE", PATH)(),
    language: str = lambda: get("STARPLOT_LANGUAGE", "en-US")(),
) -> None