ITADN

Defaults for `colorrange`

#5601Openthchr 创建于 2026-04-17
enhancement
T
thchrcommented
Right now, supplying a colormap and a numbered color from that map appears to require that one also specifies `colorrange` explicitly. E.g., the following doesn't do what I had hoped (pick out the 3rd color - green - from the 10-color colormap `:tab10`): ```jl scatter(1:10, 1:10; color = 3, colormap = :tab10) ``` <img width="300" alt="Image" src="https://github.com/user-attachments/assets/f479c408-7914-46ea-ae33-238e65ea6417" /> Instead requiring the caller must explicitly provide `colorrange = (1,10)`: ```jl scatter(1:10, 1:10; color = 3, colormap = :tab10) ``` <img width="300" alt="Image" src="https://github.com/user-attachments/assets/e605b8df-b767-41b3-a01c-ce8141d3b9ef" /> Surprisingly, if one passes `color = 1:10`, things work out sensibly, even without `colorrange`: ```jl scatter(1:10, 1:10; color = 1:10, colormap = :tab10) ``` <img width="300" alt="Image" src="https://github.com/user-attachments/assets/d70c41b5-0022-4954-b2f6-a76d55ea6086" /> (but then, it doesn't work again for `scatter(1:10, 1:10; color = fill(3, 10), colormap = :tab10)`) **Question:** would it be reasonable to default `colorrange` equal to `(1, length(ColorSchemes.colorschemes[colormap]))` if colormap is provided? It might not make a lot of sense for non-categorical colormaps, but then, it's also not clear to me that there is a sensible default in those cases (and, at least, I think this would probably be among the more reasonable ones one might imagine) - and it least, this would be a sensible choice for categorical ones?
0 条评论