Skip to content

Commit e0af7dc

Browse files
committed
Improve frame
1 parent 7f3f709 commit e0af7dc

File tree

1 file changed

+60
-7
lines changed

1 file changed

+60
-7
lines changed

pygmt/params/frame.py

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
"""
44

55
import dataclasses
6+
from typing import Any, Literal
7+
68
from pygmt.alias import Alias
79
from pygmt.params.base import BaseParam
8-
from typing import Any
910

1011

1112
@dataclasses.dataclass(repr=False)
@@ -53,25 +54,77 @@ class Axis(BaseParam):
5354
"""
5455
Class for setting up one axis of a plot.
5556
57+
Attributes
58+
----------
59+
interval
60+
Intervals for annotations and major tick spacing, minor tick spacing, and/or
61+
grid line spacing.
62+
angle
63+
Plot slanted annotations (for Cartesian plots only), where *angle* is measured
64+
with respect to the horizontal and must be in the -90 <= *angle* <= 90 range.
65+
Default is normal (i.e., ``angle=90``) for y-axis and parallel (i.e.,
66+
``angle=0``) for x-axis annotations. These defaults can be changed via
67+
:gmt-term:`MAP_ANNOT_ORTHO`.
68+
skip_edge
69+
Skip annotations that fall exactly at the ends of the axis. Choose from ``left``
70+
or ``right`` to skip only the lower or upper annotation, respectively, or
71+
``True`` to skip both.
72+
fancy
73+
Give fancy annotations with W|E|S|N suffixes encoding the sign (for geographic
74+
axes only).
75+
label/hlabel
76+
Add a label to the axis (for Cartesian plots only). The label is placed parallel
77+
to the axis by default; use **hlabel** to force a horizontal label for y-axis,
78+
which is useful for very short labels.
79+
alt_label/alt_hlabel
80+
Add an alternate label for the right or upper axes. The label is placed parallel
81+
to the axis by default; use **alt_hlabel** to force a horizontal label for
82+
y-axis, which is useful for very short labels. [For Cartesian plots only].
83+
prefix
84+
Add a leading text prefix for axis annotation (e.g., dollar sign for plots
85+
related to money) (for Cartesian plots only). For geographic maps the addition
86+
of degree symbols, etc. is automatic and controlled by
87+
:gmt-term:`FORMAT_GEO_MAP`.
88+
unit
89+
Append a unit to the annotations (for Cartesian plots only). For geographic maps
90+
the addition of degree symbols, etc. is automatic and controlled by
91+
:gmt-term:`FORMAT_GEO_MAP`.
92+
5693
Examples
5794
--------
5895
>>> from pygmt.params import Axis
5996
>>> str(Axis(10, angle=30, label="X axis", unit="km"))
6097
'10+a30+lX axis+ukm'
6198
"""
6299

63-
interval: float | str
64-
angle: float | str | None = None
100+
interval: float | str # How to make it more Pythonic?
101+
angle: float | None = None
102+
skip_edge: Literal["left", "right"] | bool = False
103+
fancy: bool = False
65104
label: str | None = None
105+
hlabel: str | None = None
106+
alt_label: str | None = None
107+
alt_hlabel: str | None = None
108+
prefix: str | None = None
66109
unit: str | None = None
67110

68111
@property
69112
def _aliases(self):
70113
return [
71-
Alias(self.interval),
72-
Alias(self.angle, prefix="+a"),
73-
Alias(self.label, prefix="+l"),
74-
Alias(self.unit, prefix="+u"),
114+
Alias(self.interval, name="interval"),
115+
Alias(self.angle, name="angle", prefix="+a"),
116+
Alias(
117+
self.skip_edge,
118+
name="skip_edge",
119+
prefix="+e",
120+
mapping={True: True, "left": "l", "right": "r"},
121+
),
122+
Alias(self.fancy, name="fancy", prefix="+f"),
123+
Alias(self.label, name="label", prefix="+l"),
124+
Alias(self.hlabel, name="hlabel", prefix="+L"),
125+
Alias(self.alt_label, name="alt_label", prefix="+s"),
126+
Alias(self.alt_hlabel, name="alt_hlabel", prefix="+S"),
127+
Alias(self.unit, name="unit", prefix="+u"),
75128
]
76129

77130

0 commit comments

Comments
 (0)