@@ -58,6 +58,9 @@ class Options:
5858 label_include_units: Append units to labels. Default True.
5959 label_unit_format: Format string for units. Use `{units}` as placeholder.
6060 slot_orders: Slot orders per plot type. Keys are plot types, values are tuples.
61+ dataset_variable_position: Position of "variable" dim when plotting all Dataset
62+ variables. Default 1 (second position, typically color). Set to 0 for first
63+ position (x-axis), or -1 for last position.
6164 """
6265
6366 label_use_long_name : bool = True
@@ -67,6 +70,7 @@ class Options:
6770 slot_orders : dict [str , tuple [str , ...]] = field (
6871 default_factory = lambda : dict (DEFAULT_SLOT_ORDERS )
6972 )
73+ dataset_variable_position : int = 1
7074
7175 def to_dict (self ) -> dict [str , Any ]:
7276 """Return options as a dictionary."""
@@ -76,6 +80,7 @@ def to_dict(self) -> dict[str, Any]:
7680 "label_include_units" : self .label_include_units ,
7781 "label_unit_format" : self .label_unit_format ,
7882 "slot_orders" : self .slot_orders ,
83+ "dataset_variable_position" : self .dataset_variable_position ,
7984 }
8085
8186
@@ -106,6 +111,7 @@ def set_options(
106111 label_include_units : bool | None = None ,
107112 label_unit_format : str | None = None ,
108113 slot_orders : dict [str , tuple [str , ...]] | None = None ,
114+ dataset_variable_position : int | None = None ,
109115) -> Generator [None , None , None ]:
110116 """Set xarray_plotly options globally or as a context manager.
111117
@@ -115,6 +121,8 @@ def set_options(
115121 label_include_units: Append units to labels.
116122 label_unit_format: Format string for units. Use `{units}` as placeholder.
117123 slot_orders: Slot orders per plot type.
124+ dataset_variable_position: Position of "variable" dim when plotting all Dataset
125+ variables. Default 1 (second, typically color). Use 0 for first, -1 for last.
118126
119127 Yields:
120128 None when used as a context manager.
@@ -136,6 +144,7 @@ def set_options(
136144 "label_include_units" : _options .label_include_units ,
137145 "label_unit_format" : _options .label_unit_format ,
138146 "slot_orders" : dict (_options .slot_orders ),
147+ "dataset_variable_position" : _options .dataset_variable_position ,
139148 }
140149
141150 # Apply new values (modify in place to keep reference)
@@ -149,6 +158,8 @@ def set_options(
149158 _options .label_unit_format = label_unit_format
150159 if slot_orders is not None :
151160 _options .slot_orders = dict (slot_orders )
161+ if dataset_variable_position is not None :
162+ _options .dataset_variable_position = dataset_variable_position
152163
153164 try :
154165 yield
@@ -159,6 +170,7 @@ def set_options(
159170 _options .label_include_units = old_values ["label_include_units" ]
160171 _options .label_unit_format = old_values ["label_unit_format" ]
161172 _options .slot_orders = old_values ["slot_orders" ]
173+ _options .dataset_variable_position = old_values ["dataset_variable_position" ]
162174
163175
164176def notebook (renderer : str = "notebook" ) -> None :
0 commit comments