Skip to content

Commit b7f3d1d

Browse files
committed
Allow the dimension of text plots to be set
1 parent 8ab818b commit b7f3d1d

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

examples/histogram_text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ fn main() {
44
let data = [0.3, 0.5, 6.4, 5.3, 3.6, 3.6, 3.5, 7.5, 4.0];
55
let h = plotlib::histogram::Histogram::from_slice(&data, 10);
66
let v = plotlib::view::ContinuousView::new().add(&h);
7-
println!("{}", plotlib::page::Page::single(&v).to_text().unwrap());
7+
println!("{}", plotlib::page::Page::single(&v).dimensions(60, 15).to_text().unwrap());
88
}

src/page.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ impl<'a> Page<'a> {
7777
Render the plot to an `String`
7878
*/
7979
pub fn to_text(&self) -> Result<String> {
80+
let (width, height) = self.dimensions;
8081
// TODO compose multiple views into a plot
8182
let view = self.views[0];
82-
view.to_text(90, 30)
83+
view.to_text(width, height)
8384
}
8485

8586
/**

0 commit comments

Comments
 (0)