|
159 | 159 | "xpx(change).imshow(color_continuous_scale=\"RdBu_r\", color_continuous_midpoint=0)" |
160 | 160 | ] |
161 | 161 | }, |
| 162 | + { |
| 163 | + "cell_type": "markdown", |
| 164 | + "metadata": {}, |
| 165 | + "source": [ |
| 166 | + "## colors (unified parameter)\n", |
| 167 | + "\n", |
| 168 | + "The `colors` parameter provides a simpler way to set colors without remembering the exact Plotly parameter name. It automatically maps to the correct parameter based on the input type:\n", |
| 169 | + "\n", |
| 170 | + "| Input | Maps To |\n", |
| 171 | + "|-------|---------|\n", |
| 172 | + "| `\"Viridis\"` (continuous scale name) | `color_continuous_scale` |\n", |
| 173 | + "| `\"D3\"` (qualitative palette name) | `color_discrete_sequence` |\n", |
| 174 | + "| `[\"red\", \"blue\"]` (list) | `color_discrete_sequence` |\n", |
| 175 | + "| `{\"A\": \"red\"}` (dict) | `color_discrete_map` |" |
| 176 | + ] |
| 177 | + }, |
| 178 | + { |
| 179 | + "cell_type": "code", |
| 180 | + "execution_count": null, |
| 181 | + "metadata": {}, |
| 182 | + "outputs": [], |
| 183 | + "source": [ |
| 184 | + "# Named qualitative palette\n", |
| 185 | + "xpx(stocks).line(colors=\"D3\")" |
| 186 | + ] |
| 187 | + }, |
| 188 | + { |
| 189 | + "cell_type": "code", |
| 190 | + "execution_count": null, |
| 191 | + "metadata": {}, |
| 192 | + "outputs": [], |
| 193 | + "source": [ |
| 194 | + "# List of custom colors\n", |
| 195 | + "xpx(stocks).line(colors=[\"#E63946\", \"#457B9D\", \"#2A9D8F\", \"#E9C46A\", \"#F4A261\"])" |
| 196 | + ] |
| 197 | + }, |
| 198 | + { |
| 199 | + "cell_type": "code", |
| 200 | + "execution_count": null, |
| 201 | + "metadata": {}, |
| 202 | + "outputs": [], |
| 203 | + "source": [ |
| 204 | + "# Dict for explicit mapping\n", |
| 205 | + "xpx(stocks).line(\n", |
| 206 | + " colors={\n", |
| 207 | + " \"GOOG\": \"red\",\n", |
| 208 | + " \"AAPL\": \"blue\",\n", |
| 209 | + " \"AMZN\": \"green\",\n", |
| 210 | + " \"FB\": \"purple\",\n", |
| 211 | + " \"NFLX\": \"orange\",\n", |
| 212 | + " \"MSFT\": \"brown\",\n", |
| 213 | + " }\n", |
| 214 | + ")" |
| 215 | + ] |
| 216 | + }, |
| 217 | + { |
| 218 | + "cell_type": "code", |
| 219 | + "execution_count": null, |
| 220 | + "metadata": {}, |
| 221 | + "outputs": [], |
| 222 | + "source": [ |
| 223 | + "# Continuous scale for heatmaps\n", |
| 224 | + "xpx(stocks).imshow(colors=\"Plasma\")" |
| 225 | + ] |
| 226 | + }, |
162 | 227 | { |
163 | 228 | "cell_type": "markdown", |
164 | 229 | "metadata": {}, |
|
0 commit comments