Settings
Starplot has a few global settings:
- Data path
- Language
- 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.config.Settings
dataclass
data_path
class-attribute
instance-attribute
Path that Starplot will use for data and the DuckDB spatial extension, which is required for the data backend.
Default = current working directory
language
class-attribute
instance-attribute
Default language for plotted labels, as an ISO-639 code. Case insensitive.
Supported values:
en-us= English (default)fa= Persian (Farsi). Make sure you have a Persian font installed that supports RTL (such as Vazir or Noto Sans Arabic) and set it as the font in your plot's style.fr= Frenchlt= Lithuanianzh-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.zh-tw= Traditional Chinese
🌐 Want to see another language available? Please help us add it! Details here.
svg_text_type
class-attribute
instance-attribute
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.