Crate poloto[][src]

poloto - plot to SVG and style with CSS

How do I change the color of the plots?

You can doing it by overriding the css. If you embed the generated svg into a html file, then you can add this example:

.poloto{
   --poloto_bg_color:"black";
   --poloto_fg_color:"white;
   --poloto_color0:"red";
   --poloto_color1:"green";
   --poloto_color2:"yellow";
   --poloto_color3:"orange";
   --poloto_color4:"purple";
   --poloto_color5:"pink";
   --poloto_color6:"aqua";
   --poloto_color7:"red";
}

By default these variables are not defined, so the svg falls back on some default colors.

Can I change the styling of the plots?

Yes! You can harness the power of CSS both in the svg, or outside in html with an embeded svg. Some things you can do:

  • Change the color scheme to fit your html theme.
  • Highlight one plot, make it dashed, or add hover effect
  • Animate things using @keyframes

Depending on whether you are adding a new style attribute or overriding an existing one, you might have to increase the specificty of your css clause to make sure it overrides the svg css clause.

Usage

  • Plots containing NaN or Infinity are ignored.
  • After 6 plots, the colors cycle back and are repeated.

Why not scale the intervals to end nicely with the ends of the axis lines?

Doing this you would have to either have more dead space, or exclude plots that the user would expect to get plotted. Neither of these sounded better than the option of just having the intervals stop not necessarily at the end of the axis lines.

Example

See the graphs in this report: broccoli_book

Structs

Plotter

Keeps track of plots. User supplies iterators that will be iterated on when render is called. BELOW IMPORTANT::: We hold the writer for type inference for the _fmt functions We don't actually write anything to it until render() is called. This way you don't need to handle formatting errors in multipe places Only when you call render. Its important to note that most of the time when this library is used, if run through the code is first accompanied by one compilation of the code. So inefficiencies in dynamically allocating strings using format!() to then be just passed to a writer are not that bad seeing as the solution would involve passing a lot of closures around. Also plotting is used a lot by data scientists, and I wanted the code to be approachable to them.

Constants

HEIGHT

Provided in case the user wants to define their own SVG tag.

WIDTH

Provided in case the user wants to define their own SVG tag.

Functions

default_header

Create the default SVG tag.

plot

Convenience function for Plotter::new()

render_svg

Convenience function to write to a T that implements std::fmt::Write

render_svg_io

Convenience function to write to a T that implements std::io::Write instead of std::fmt::Write

render_to_string

Convenience function to just write to a string.