Spectrumize is a Go library for visualizing numerical data series as customizable color spectrums in SVG or PNG format.
- Map numerical ranges to color spectrums
- Output visualizations as SVG or PNG
- Supports legends and color annotations
go get github.com/yourusername/spectrumize
package main
import (
"os"
"github.com/yourusername/spectrumize/spectrumize"
)
func main() {
data := []float64{1.2, 4.5, 3.8, 2.9, 5.0}
colormap := spectrumize.NewLinearColormap("#3498db", "#e74c3c")
svg := spectrumize.RenderSVG(data, colormap)
os.WriteFile("output.svg", []byte(svg), 0644)
}package main
import (
"os"
"github.com/yourusername/spectrumize/spectrumize"
)
func main() {
data := []float64{1.2, 4.5, 3.8, 2.9, 5.0}
colormap := spectrumize.NewLinearColormap("#3498db", "#e74c3c")
img := spectrumize.RenderPNG(data, colormap, 400, 50)
file, _ := os.Create("output.png")
defer file.Close()
png.Encode(file, img)
}You can add annotations and legends using the LegendOptions when rendering:
options := spectrumize.LegendOptions{
Units: "mg/dL",
MinLabel: "Low",
MaxLabel: "High",
}
svg := spectrumize.RenderSVGWithLegend(data, colormap, options)See GoDoc for detailed documentation.