loony-bean / textplots-rs

Terminal plotting library for Rust
238 stars 24 forks source link

Add y_label option #5

Closed ccakes closed 5 years ago

ccakes commented 5 years ago

Just something quick to be able to throw a Y-axis label on the generated plot. Happy to change anything if you don't like the implementation, I went with the Option<String> to make it work safely with existing code.

loony-bean commented 5 years ago

Thanks for making this pull request ❤️ After some thinking I'm still concerned whether we should add labels to the chart internals.

First of all, because the space is very limited, and resolution is low (and we cannot really draw labels orthogonally) -- the labels interfere with axes ticks, cluttering the plot.

Second, I'd like to avoid expanding the API, to keep it minimalistic. Maybe we could add a method to return the frame (with all the decorations), and you could add label directly to the frame in the client code?

ccakes commented 5 years ago

Ok - would you rather return a reference to the drawille::Canvas object so the library user can really dig into it, or just the string returned from self.canvas.frame()?

Something like pub fn canvas(&mut self) -> &mut BrailleCanvas seems like it'd be the most flexible but maybe too much?

loony-bean commented 5 years ago

I'd return just the string.

ccakes commented 5 years ago

I don't entirely agree but sure, changed as requested.