summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Grebenshchikov <sgreben@gmail.com>2018-03-30 21:24:53 +0200
committerSergey Grebenshchikov <sgreben@gmail.com>2018-03-30 21:24:53 +0200
commit4a608105bcab96ca98eb405159faa626b7d8193e (patch)
treec7daf0d770675d04a746c384ff47898cd3cdaf19
parent0f9e84d2a4754c51cba79615820bcd53b0d9dd48 (diff)
Heatmap -> hist2d
-rw-r--r--README.md76
-rw-r--r--README.template.md76
-rw-r--r--cmd/jp/canvas_other.go2
-rw-r--r--cmd/jp/canvas_windows.go2
-rw-r--r--cmd/jp/hist2d.go (renamed from cmd/jp/heatmap.go)6
-rw-r--r--cmd/jp/main.go8
6 files changed, 85 insertions, 85 deletions
diff --git a/README.md b/README.md
index eafb5dc..97a5890 100644
--- a/README.md
+++ b/README.md
@@ -19,10 +19,10 @@ Dead simple terminal plots from JSON (or CSV) data. Bar charts, line charts, and
- [Array data, XY pairs](#array-data-xy-pairs)
- [Y values only (X=index)](#y-values-only-xindex-1)
- [Scatter plot](#scatter-plot)
- - [Heatmap](#heatmap)
- [Histogram](#histogram)
- [Auto bin number](#auto-bin-number)
- [Fixed bin number](#fixed-bin-number)
+ - [2D Histogram (heatmap)](#2d-histogram-heatmap)
- [CSV input](#csv-input)
- [Screenshots](#screenshots)
- [Licensing](#licensing)
@@ -283,43 +283,6 @@ $ cat examples/mvrnorm.json | jp -xy '..[x,y]' -type scatter
-4.08815 3.79083
```
-### Heatmap
-
-```
-$ cat examples/mvrnorm.json | jp -xy '..[x,y]' -type hist2d
-
- 3.3608│ ···· ········ ····
- │ ···· ········ ····
- │ ···· ········ ····
- │ ················ ····
- │ ················ ····
- │ ································
- │ ································
- │ ················░░░░░░░░░░░░················
- │ ················░░░░░░░░░░░░················
- │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
- │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
- │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
- │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
- │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
- │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
- │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
- │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
- │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
- │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
- │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
- │ ····································
- │ ····································
- │ ····························
- │ ····························
- │ ···· ···· ····
- │ ···· ···· ····
- │ ····
- │ ····
- -4.0045└───────────────────────────────────────────────────
- -3.8421 3.5909
-```
-
### Histogram
#### Auto bin number
@@ -382,6 +345,43 @@ $ cat examples/mvrnorm.json | jp -x ..x -type hist -bins 5
[-3.8421,-2.3555)[-2.3555,-0.8689)[-0.8689,0.6177) [0.6177,2.1043) [2.1043,3.5909]
```
+### 2D Histogram (heatmap)
+
+```
+$ cat examples/mvrnorm.json | jp -xy '..[x,y]' -type hist2d
+
+ 3.3608│ ···· ········ ····
+ │ ···· ········ ····
+ │ ···· ········ ····
+ │ ················ ····
+ │ ················ ····
+ │ ································
+ │ ································
+ │ ················░░░░░░░░░░░░················
+ │ ················░░░░░░░░░░░░················
+ │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
+ │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
+ │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
+ │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
+ │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
+ │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
+ │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
+ │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
+ │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
+ │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
+ │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
+ │ ····································
+ │ ····································
+ │ ····························
+ │ ····························
+ │ ···· ···· ····
+ │ ···· ···· ····
+ │ ····
+ │ ····
+ -4.0045└───────────────────────────────────────────────────
+ -3.8421 3.5909
+```
+
### CSV input
```
diff --git a/README.template.md b/README.template.md
index 6d83d29..a69ae0a 100644
--- a/README.template.md
+++ b/README.template.md
@@ -19,10 +19,10 @@ Dead simple terminal plots from JSON (or CSV) data. Bar charts, line charts, and
- [Array data, XY pairs](#array-data-xy-pairs)
- [Y values only (X=index)](#y-values-only-xindex-1)
- [Scatter plot](#scatter-plot)
- - [Heatmap](#heatmap)
- [Histogram](#histogram)
- [Auto bin number](#auto-bin-number)
- [Fixed bin number](#fixed-bin-number)
+ - [2D Histogram (heatmap)](#2d-histogram-heatmap)
- [CSV input](#csv-input)
- [Screenshots](#screenshots)
- [Licensing](#licensing)
@@ -283,43 +283,6 @@ $ cat examples/mvrnorm.json | jp -xy '..[x,y]' -type scatter
-4.08815 3.79083
```
-### Heatmap
-
-```
-$ cat examples/mvrnorm.json | jp -xy '..[x,y]' -type hist2d
-
- 3.3608│ ···· ········ ····
- │ ···· ········ ····
- │ ···· ········ ····
- │ ················ ····
- │ ················ ····
- │ ································
- │ ································
- │ ················░░░░░░░░░░░░················
- │ ················░░░░░░░░░░░░················
- │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
- │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
- │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
- │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
- │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
- │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
- │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
- │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
- │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
- │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
- │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
- │ ····································
- │ ····································
- │ ····························
- │ ····························
- │ ···· ···· ····
- │ ···· ···· ····
- │ ····
- │ ····
- -4.0045└───────────────────────────────────────────────────
- -3.8421 3.5909
-```
-
### Histogram
#### Auto bin number
@@ -382,6 +345,43 @@ $ cat examples/mvrnorm.json | jp -x ..x -type hist -bins 5
[-3.8421,-2.3555)[-2.3555,-0.8689)[-0.8689,0.6177) [0.6177,2.1043) [2.1043,3.5909]
```
+### 2D Histogram (heatmap)
+
+```
+$ cat examples/mvrnorm.json | jp -xy '..[x,y]' -type hist2d
+
+ 3.3608│ ···· ········ ····
+ │ ···· ········ ····
+ │ ···· ········ ····
+ │ ················ ····
+ │ ················ ····
+ │ ································
+ │ ································
+ │ ················░░░░░░░░░░░░················
+ │ ················░░░░░░░░░░░░················
+ │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
+ │ ············▒▒▒▒▓▓▓▓▒▒▒▒▒▒▒▒░░░░············
+ │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
+ │···············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒············
+ │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
+ │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
+ │ ········░░░░▓▓▓▓▓▓▓▓████▓▓▓▓▒▒▒▒············
+ │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
+ │ ············▒▒▒▒▒▒▒▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒············
+ │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
+ │ ············▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒················
+ │ ····································
+ │ ····································
+ │ ····························
+ │ ····························
+ │ ···· ···· ····
+ │ ···· ···· ····
+ │ ····
+ │ ····
+ -4.0045└───────────────────────────────────────────────────
+ -3.8421 3.5909
+```
+
### CSV input
```
diff --git a/cmd/jp/canvas_other.go b/cmd/jp/canvas_other.go
index db0b3d4..77f174b 100644
--- a/cmd/jp/canvas_other.go
+++ b/cmd/jp/canvas_other.go
@@ -7,5 +7,5 @@ var autoCanvas = map[string]string{
plotTypeLine: canvasTypeQuarter,
plotTypeScatter: canvasTypeBraille,
plotTypeHist: canvasTypeQuarter,
- plotTypeHeatmap: canvasTypeFull,
+ plotTypeHist2D: canvasTypeFull,
}
diff --git a/cmd/jp/canvas_windows.go b/cmd/jp/canvas_windows.go
index 56cc212..a66b02e 100644
--- a/cmd/jp/canvas_windows.go
+++ b/cmd/jp/canvas_windows.go
@@ -7,5 +7,5 @@ var autoCanvas = map[string]string{
plotTypeLine: canvasTypeFull,
plotTypeScatter: canvasTypeFull,
plotTypeHist: canvasTypeFull,
- plotTypeHeatmap: canvasTypeFull,
+ plotTypeHist2D: canvasTypeFull,
}
diff --git a/cmd/jp/heatmap.go b/cmd/jp/hist2d.go
index 9ebd2fe..1af6a69 100644
--- a/cmd/jp/heatmap.go
+++ b/cmd/jp/hist2d.go
@@ -9,7 +9,7 @@ import (
"github.com/sgreben/jp/pkg/plot"
)
-func heatmapData(xv []reflect.Value, yv []reflect.Value, nbins uint) (heatmap *data.Heatmap) {
+func hist2DData(xv []reflect.Value, yv []reflect.Value, nbins uint) (heatmap *data.Heatmap) {
var x, y []float64
for i := range xv {
if xv[i].IsValid() && xv[i].CanInterface() {
@@ -48,8 +48,8 @@ func heatmapData(xv []reflect.Value, yv []reflect.Value, nbins uint) (heatmap *d
return
}
-func heatmap(xv, yv []reflect.Value, c draw.Canvas, nbins uint) string {
- heatmap := heatmapData(xv, yv, nbins)
+func hist2D(xv, yv []reflect.Value, c draw.Canvas, nbins uint) string {
+ heatmap := hist2DData(xv, yv, nbins)
chart := plot.NewHeatMap(c.GetBuffer())
return chart.Draw(heatmap)
}
diff --git a/cmd/jp/main.go b/cmd/jp/main.go
index ac5b099..4f26ecb 100644
--- a/cmd/jp/main.go
+++ b/cmd/jp/main.go
@@ -31,7 +31,7 @@ const (
plotTypeBar = "bar"
plotTypeScatter = "scatter"
plotTypeHist = "hist"
- plotTypeHeatmap = "hist2d"
+ plotTypeHist2D = "hist2d"
)
const (
@@ -54,7 +54,7 @@ var config = configuration{
plotTypeBar,
plotTypeScatter,
plotTypeHist,
- plotTypeHeatmap,
+ plotTypeHist2D,
},
},
CanvasType: enumVar{
@@ -182,7 +182,7 @@ func main() {
fmt.Println(barPlot(x, y, c))
case plotTypeHist:
fmt.Println(histogram(x, c, config.HistBins))
- case plotTypeHeatmap:
- fmt.Println(heatmap(x, y, c, config.HistBins))
+ case plotTypeHist2D:
+ fmt.Println(hist2D(x, y, c, config.HistBins))
}
}