Skip to content

kirillsaidov/tiny-plot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tiny Plot

A tiny plotting library for D, built on tiny-svg. Supports line plots, scatter plots, bar charts, histograms, and pie charts.

Library

Add library to your project using DUB:

dub add tiny-plot

Quick Start

import rk.tplot;

auto p = Plot(800, 500);

double[] x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
double[] y = [2.3, 4.1, 3.5, 6.2, 5.8, 7.1, 8.3, 7.9, 9.2, 10.1];

p.plot(x, y, "Temperature");
p.setTitle("Line Plot Example");
p.setXLabel("Day");
p.setYLabel("Value");
p.save("line_plot.svg");

Features

All chart types are methods on a single Plot struct:

Method Description
p.plot(x, y, name) Line plot
p.scatter(x, y, name) Scatter plot
p.bar(x, y, name) Bar chart
p.hist(data, numBins, name) Histogram
p.pie(values, names) Pie chart

Additional methods:

  • p.setTitle(title) — set plot title
  • p.setXLabel(label) / p.setYLabel(label) — set axis labels
  • p.setStyle(style) — customize plot appearance
  • p.save(filename) — render and save to SVG

Multiple series can be combined on the same plot:

auto p = Plot(900, 600);

p.bar(x, bars, "Volume");
p.plot(x, trend, "Trend");
p.scatter(x, actual, "Actual");
p.setTitle("Combined Plot");
p.save("combined_plot.svg");

Examples

Line Plot

Scatter Plot

Bar Chart

Histogram

Pie Chart

Combined Plot

Code can be found here.

LICENSE

All code is licensed under the MIT license.

About

A tiny plotting library for D, built on tiny-svg. Supports line plots, scatter plots, bar charts, histograms, and pie charts.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages