Ah, I didn’t expect that after so many years, Plotly still hits its limits with just a little use. Previously it couldn’t draw timeline charts, and this time I found that the customization of map markers is insufficient…
I needed to use Plotly’s Scattermap object to draw a map with some markers on it. After seeing the first version, the client wanted to use the common inverted‑teardrop icon (like a map pin) instead of the default circle. Fortunately Scattermap supports that, so I wrote:
1 | map_fig = ( |
It turned out that although the icon could be customized, its color couldn’t be changed… After some searching, I found a last‑year’s issue that gave a rather hopeless answer: up to now, plotly simply does not support this change because it uses maki‑icons, where the icons are fixed black and there is no interface to change the color via requests.
The issue is labeled P3, meaning… it’s on the schedule, but at the lowest priority… something that will be done who‑knows‑when…
But I couldn’t wait. I tortured Copilot for another morning and got an even more desperate answer: plotly.py is just a wrapper for plotly.js; it only organizes the data and parameters as required, while the actual drawing is completely handled by plotly.js. In other words, if I wanted to fix this problem, I would have to look at the JS code, and not just modify it—I would also need to expose the interface on the JS side and then connect it with the Python part… That… isn’t impossible, but I didn’t have enough time…
So I slapped my forehead and thought of a hack. From observation, plotly.js actually fetches the icon’s SVG file via an HTTPS request and uses that file for drawing. Well… is it possible to intercept that request with a userscript (like Tampermonkey) and feed it my prepared SVG file?
This time ChatGPT saved my ass, Deepseek completely failed… ChatGPT indeed gave me a script that could intercept and replace the SVG file:
1 | // ==UserScript== |
Finally… I got it working for now. The remaining problems can be dealt with later… Sigh, back to overtime work…