Skip to main content

array_plot

Function array_plot 

Source
pub fn array_plot<T: PartialOrd + Copy + Debug>(
    data: &Vec<Vec<T>>,
) -> ArrayPlotBuilder<'_, T>
Expand description

Displays a table of values with different shades.

§Examples

§Example 1

use cgrustplot::plots::array_plot::array_plot;
 
let data = vec![vec![0, 1, 2, 1, 0, 1, 2], vec![1, 2, 1, 0, 1, 2, 1], vec![2, 1, 0, 1, 2, 1, 0]];
array_plot(&data).print();
// Standard Output:
// 
// 2.500 ┼ ▒█▒ ▒█
//       │▒█▒ ▒█▒
// 0.500 ┼█▒ ▒█▒ 
//       └┼──┼───
//        0. 4   

§Example 2

use cgrustplot::plots::array_plot::*;
 
// Table of x.sin() * y.sin()
let data = bin_arr(&((0..20).map(|r| (0..30).map(|c| (0.5 * r as f64).sin() * (0.333 * c as f64).sin()).collect()).collect()), 8);
 
array_plot(&data).print();
 
// Standard Output:
//       │++++++++++++++++++++++++++++++
// 18.50 ┼++******++==------=++******++=
//       │+*%%@@@%*+=-.   .-=+*%%@@@%*+=
// 16.50 ┼+*%@@@@%*+=-     .-+*%@@@@%*+=
//       │+*%@@@@%*+=-.   ..-+*%@@@@%*+=
// 14.50 ┼++*%%%%**+=--...--=++*%%%%**+=
//       │++++++++++=========++++++++++=
// 12.50 ┼+==-----==++*****++===----===+
//       │+=-.. ..-=+*%%@%%*+=--.. ..-=+
// 10.50 ┼+-.    .-=+*%@@@@%*=-.    .-=+
//       │+-.    .-=+*%@@@@%*=-.    .-=+
// 8.500 ┼+=-.....-=+*%%%%%*+=--....--=+
//       │+===---===+++***+++====--====+
// 6.500 ┼++++++++++=========++++++++++=
//       │++*%%%%**+=--....-=++*%%%%**+=
// 4.500 ┼+*%@@@@%*+=-.    .-+*%@@@@%*+=
//       │+*%@@@@%*+=-.    .-+*%@@@@%*+=
// 2.500 ┼+**%@@%%*+=-..  .-=+*%%@@%%*+=
//       │++******++==-----==++******++=
// 0.500 ┼+=========+++++++++==========+
//       └┼──────┼──────┼──────┼────────
//        0.5000 7.5000 14.500 21.500   
 

§Options

  • data - Input data representing the array.
  • title - Optional title for the plot. Default is None.
  • axes - Whether or not to display axes and axes labels. Default is true.
  • chars - Charset to be used for plotting. Any set in cgrustplot::helper::charset::gradient_chars works. Default is computed.