Skip to content

m0nirul/spectrumize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Spectrumize

Spectrumize is a Go library for visualizing numerical data series as customizable color spectrums in SVG or PNG format.

Features

  • Map numerical ranges to color spectrums
  • Output visualizations as SVG or PNG
  • Supports legends and color annotations

Installation

go get github.com/yourusername/spectrumize

Usage

1. Visualize Data as SVG

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)
}

2. Visualize Data as PNG

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)
}

3. Annotate Legend

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)

API Reference

See GoDoc for detailed documentation.

About

A Go library for visualizing numerical data series as color spectrums in SVG or PNG format.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages