|
92 | 92 | "xpx(ds).line(facet_row=\"variable\", facet_col=\"city\")" |
93 | 93 | ] |
94 | 94 | }, |
| 95 | + { |
| 96 | + "cell_type": "markdown", |
| 97 | + "metadata": {}, |
| 98 | + "source": [ |
| 99 | + "## Configure Default \"variable\" Position\n", |
| 100 | + "\n", |
| 101 | + "By default, `\"variable\"` is placed as the **second** dimension so it maps to `color`. This keeps your first dimension (e.g., time) on the x-axis.\n", |
| 102 | + "\n", |
| 103 | + "You can change this globally with `config.set_options()`:" |
| 104 | + ] |
| 105 | + }, |
| 106 | + { |
| 107 | + "cell_type": "code", |
| 108 | + "execution_count": null, |
| 109 | + "metadata": {}, |
| 110 | + "outputs": [], |
| 111 | + "source": [ |
| 112 | + "# Default: position=1 (second) -> variable goes to color\n", |
| 113 | + "# Dimensions are: (time, variable, city)\n", |
| 114 | + "print(\"Default dimension order:\", ds.to_array().dims)\n", |
| 115 | + "xpx(ds).line(title=\"Default: variable as color (position=1)\")" |
| 116 | + ] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "code", |
| 120 | + "execution_count": null, |
| 121 | + "metadata": {}, |
| 122 | + "outputs": [], |
| 123 | + "source": [ |
| 124 | + "# Position 0: variable goes first (x-axis) - usually not what you want!\n", |
| 125 | + "with config.set_options(dataset_variable_position=0):\n", |
| 126 | + " fig = xpx(ds).line(title=\"position=0: variable on x-axis (probably not desired)\")\n", |
| 127 | + "fig" |
| 128 | + ] |
| 129 | + }, |
| 130 | + { |
| 131 | + "cell_type": "code", |
| 132 | + "execution_count": null, |
| 133 | + "metadata": {}, |
| 134 | + "outputs": [], |
| 135 | + "source": [ |
| 136 | + "# Position -1: variable goes last -> city gets color, variable gets line_dash\n", |
| 137 | + "with config.set_options(dataset_variable_position=-1):\n", |
| 138 | + " fig = xpx(ds).line(title=\"position=-1: variable as line_dash\")\n", |
| 139 | + "fig" |
| 140 | + ] |
| 141 | + }, |
95 | 142 | { |
96 | 143 | "cell_type": "markdown", |
97 | 144 | "metadata": {}, |
|
0 commit comments