wiki:soc/2007/VisualizationOfContainers

Version 18 (modified by jakevoytko, 15 years ago) ( diff )

--

0. Introduction

This project is focused on using STL containers in order to graph data on a one-dimensional and two-dimensional (and if time allows, 3D!) plot. The plot would be written in an svg image, compliant with the W3C standard. The goals of the project are as follows:

  • To let users produce a simple plot with minimal intervention by using sane defaults
  • To demonstrate how to incorporate SVG images into Boost documentation
  • To allow users to easily customize graphs to their heart's content
  • To allow the user to talk with the svg_graph class using coordinate units instead of pixels or other arbitrary measures

I have only a student's grasp of C++, so if you have a suggestion to help me with design or implementation, either leave them here or email me at jakevoytko [at] gmail [dot] com

This page will hold examples of what I have implemented thus far, and what my program will be capable of in the future. More complete documentation will be live in a few days on my personal website.

What can it do?

Example

Potential example

vector<double> data1;
deque<double> data2;


svg_plot my_plot("D:\\1D_legend_demo.svg");

// size/scale settings
my_plot.image_size(500, 350);
my_plot.x_scale(-2, 10);
    
// command settings
my_plot.draw_axis()
       .show_legend();

// color settings
my_plot.set_background_color(lightgray)
       .set_legend_background_color(whitesmoke);

// drawing
plot_range(my_plot, data2.begin(), data2.end(), "Lions",  blue);
plot_range(my_plot, data1.begin(), data1.end(), "Tigers", limegreen);

// write to file. NOTE: Will change to write(filename) soon
my_plot.write();

produces the following output:

http://www.tcnj.edu/~voytko2/svg.htm

Using Boost.Array

Because Boost.Array supports an iterator-like interface, (my_arr.begin(), my_arr.end()), Boost.Array can freely be used with the program

To-Do List

For next week

  • Create a more consistent internal name scheme (I'm starting to confuse myself)
  • Accept generic STL containers, Boost.Array
  • Begin to incorporate a key/legend into the graph
  • Allow streams to be specified as output points
  • Move files not to be consumed by users to "detail" folder

By July 2nd

  • Expand workings of program to two dimensions

3. Suggestions (No ETA as of May 28)

By Matias Capeletto:

  • Be able to choose a log scale for either the X or the Y axis
  • Proposal to include a plugable extractor to plot_range()

In general, containers will store other things than double. Starting simple, I want to be able to plot std::vector<int>. This is very easy to support. Add a function:

template<class Iter, class DoubleExtractor >
plot& plot_range( Iter start, Iter end, DoubleExtractor double_extractor)
{
    return your_old_plot_range(
       boost::make_transform_iterator(start, double_extractor),
       boost::make_transform_iterator(end  , double_extractor)
    );
}

This have other implications, for example if we have list<Human> hl, and struct get_age_functor { ... }; We can:

plot_range(svg, hl.begin(), hl.end(), get_age_functor() ); // fun stuff :)

By Paul Bristow

  • Customize background color of plot Completed
  • Customize the background border color
  • Customize the "axis area" background color
  • Title
    • Customize font
    • Customize font color
  • Axis
    • Customize line colors
    • Customize line thickness
    • Define labels for axis
    • Major ticks width, length, color
    • Minor ticks width, length, color
    • Reasonable defaults for ticks
    • Axis marker labels
    • Consider the axis for data where the origin is not in the view window
    • Consider auto-scaling
    • Grid lines
  • Data representation
    • Allow different data representation points
    • Allow appropriate customization of data points
    • Consider labels for data points (combined with exploration of hover-text features of SVG mentioned above) Completed in legend
    • Consider how to concisely represent the scale of data points
    • Multiple data series Completed
  • Legend
    • Border
    • color Partially Completed
    • position
    • border thickness
    • background colors Completed
  • Unicode strings

By Cédric Venet

  • Keep an eye towards being extensible towards multiple image formats in the future

4. Bugs D:

  • Changing or setting the x_scale after calling my_graph.draw_axis() makes the axis not be drawn.
    • This is caused because I store points after setting the graph. I will fix this by storing infinity as +NaN in the point, and when outputting, writing it at a location far off the graph

5. Acknowledgments

In no particular order, I'd like to thank Joaquín López Muñoz, Paul Bristow, Sarah Braun, John Maddock, Matias Capeletto, and anyone who's taken the time to comment on my progress / offer suggestions.

Note: See TracWiki for help on using the wiki.