plotter: Is current "uniformness" of heatmap coloring intentional?
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- go
调研方向
从 plotter/heat.go 中热图颜色缩放相关的注释和代码开始,重点查看有关调色板缩放和单元格颜色选择的引用行。使用 gonum.org/v1/plot v0.14.0 设置运行提供的 TestHeatMap 复现程序,并将生成的图像与所述预期进行比较。当预期的颜色分布得到解决,并且该行为已被覆盖或明确时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
What are you trying to do?
Drawing heatmap.
What did you do?
func TestHeatMap(t *testing.T) {
m := offsetUnitGrid{
XOffset: -2,
YOffset: -1,
Data: mat.NewDense(3, 4, []float64{
1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
}),
}
pal := myPalette{}
h := plotter.NewHeatMap(m, pal)
p := plot.New()
p.Add(h)
p.X.Padding = 0
p.Y.Padding = 0
img := vgimg.New(250, 175)
dc := draw.New(img)
p.Draw(dc)
w, err := os.Create("golden_files/heatMap.png")
if err != nil {
log.Panic(err)
}
png := vgimg.PngCanvas{Canvas: img}
if _, err = png.WriteTo(w); err != nil {
t.Fatal(err)
}
}
type myPalette struct{}
func (myPalette) Colors() []color.Color {
return []color.Color{
color.RGBA{R: 255, A: 255},
color.RGBA{G: 255, A: 255},
color.RGBA{B: 255, A: 255},
color.RGBA{R: 255, G: 255, A: 255},
}
}
// offsetUnitGrid is copied from https://github.com/gonum/plot/blob/b4fdc267610216647ec69681d47e431cf5bbed23/plotter/heat_test.go#L21
What did you expect to happen?
Each color is used "uniformly". I consider 3 cells for each colors (3 * 4 = 12) is "unform".
Following code comments says palette is scaled uniformly across the data range.
https://github.com/gonum/plot/blob/b4fdc267610216647ec69681d47e431cf5bbed23/plotter/heat.go#L157
What actually happened?
2 cells for red, 4 cells for green, 4 cells for blue, 2 cells for yellow. This doesn't look uniform to me.
Probably first color and last color have half chance to be used compared the other colors.
In my thought, following should be ps := float64(len(pal)) / (h.Max - h.Min)
https://github.com/gonum/plot/blob/b4fdc267610216647ec69681d47e431cf5bbed23/plotter/heat.go#L157-L158
and following shouldbe col = pal[int((v-h.Min)*ps)] to get uniform.
https://github.com/gonum/plot/blob/b4fdc267610216647ec69681d47e431cf5bbed23/plotter/heat.go#L222-L224
What version of Go and Gonum/plot are you using?
go version go1.22.0 darwin/arm64
gonum.org/v1/plot v0.14.0
Does this issue reproduce with the current master?
Not experimented yet. Maybe yes.
- 主要语言
- Go
- 星标
- 3k
- 派生
- 202
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
gonum/plot 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 2/5 1-3 小时 新手友好度 52/100
-
难度 5/5 一周以上 新手友好度 32/100
-
plot/plotter: NewHist(binPoints) panic when a small negative number is used可能已有人在做 @SashaMIT 于 16 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
-
难度 3/5 1-2 天 新手友好度 35/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
enhancement
难度 1/5 1-3 小时 新手友好度 76/100
superplanehq/superplane#9007 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复