Skip to content
DSL and C Library to generate SVG Plot
C Meson
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
gallery Better code Jan 16, 2018
src removed fixed locale settings: Jun 30, 2018
test LaTeX pgfplot rendering Feb 15, 2018
.gitignore Initial release Jan 10, 2018
.gitmodules Added tinyexpr submodule Jan 15, 2018 Create Jan 15, 2018
LICENSE Create LICENSE Jan 10, 2018 Update Feb 16, 2018
marker_charter_support.png New release Jan 10, 2018 LaTeX pgfplot rendering Feb 15, 2018


A simple markdown DSL and C Library to generate svg and pgfplot (LaTeX) plot from a minimal syntax.


Few examples are available in the gallery page of the wiki.

Simple syntax example:

title: reconstruction error vs compression
	label: compression
	mode: log
	label: mse
	x: 1 10    100
	y: 0 0.01  0.05
	label: f_avg
 	marker: s
 	ls: --

Resutls in:


Note: as the image is an svg the rendering of it is browser dependent.

DSL Syntax

syntax description
plot create a new line plot
scatter create a new scatter plot
scatter create a new bar plot
x-axis parameters for the x axis
y-axis parameters for the y axis
label label for axis or plot
x x values of a plot
y y values of a plot
color colour of a plot
line-width or lw plot line width
line-style or ls plot line style ('--' or 'dashed', '-' or 'normal', ':' or dotted, '/' or 'none')
bar-width or bw bar plot width
line-color bar plot line color
marker marker style of a plot ('o', 'x', '+', 's', ' ')
range min and max value for an axis
mode axis mode ('linear' or 'log')
title plot title
width plot width
height plot height
csv://file_path#tag load a csv and use column tag as values
range: min max nstep linear range to use as values
logrange: min max nstep log range to use as values
math: f(x) math expression based on x to use as y value

commas and spaces are valid separator for arrays and the sytax in general. For the definitions spaces, tabs and : are equivalents. So x: 1 2 3 is equal to x 1,2,3.

Use as a library

if you want to include charter as a library here a simple example

#include "charter/parser.h"
#include "charter/renderer.h"

 chart * parsed = parse_chart(string_to_parse);
 /* chart is the structure you can also create it programmatically in your code
    and render it to svg using chart_to_svg */
 char * svg = chart_to_svg(parsed);

Use as SVG generator

The build process generate as well an executable: charter. It is capable of generate an svg plot from a charter dsl file:

charter your_dsl_file > output.svg

Build and install

Use meson and ninja:

mkdir build
cd build
meson ..
sudo ninja install

Future improvements

In the next future I will improve the svg quality, the memory performance, and the look and feel of the output plus the following features:

  • more options on grid
  • more styling options
  • better typesettings

Marker integration

At the moment charter is integrated in Marker!

marker and charter


You can’t perform that action at this time.