loony-bean / textplots-rs

Terminal plotting library for Rust
238 stars 24 forks source link

Wrong graph produced #8

Closed bazzb closed 4 years ago

bazzb commented 5 years ago

They should only intersect at 0,0

⠑⢄                     ⣀⠤⠔⠒⠊⠉⠉⡉⠉⠉⠒⠒⠤⢄⡀                    ⢀⠔  100.0
  ⠑⢄⡀              ⢀⡠⠒⠉       ⠄      ⠈⠑⠢⣀               ⣀⠔⠁
    ⠈⠢⡀          ⡠⠔⠁          ⠂          ⠑⠤⡀          ⡠⠊
      ⠈⠑⢄⡀     ⡠⠊             ⡁            ⠈⠢⡀     ⣀⠔⠉
         ⠈⠒⢄⡀⡠⠊               ⠄              ⠈⠢⡀⣀⠔⠊
           ⢀⠎⠑⠢⢄⡀             ⠂             ⣀⠤⠒⠙⢄
          ⡔⠁    ⠈⠑⠢⠤⣀⡀        ⡁        ⣀⡠⠤⠒⠉     ⠱⡀
⠄⠠ ⠄⠠ ⠄⠠⢠⠎⠠ ⠄⠠ ⠄⠠ ⠄⠠ ⠌⠩⠑⠖⠲⠢⠤⠤⠤⠤⠤⠤⠤⠲⠒⠖⠩⠉⠄⠠ ⠄⠠ ⠄⠠ ⠄⠠⠈⢆⠠ ⠄⠠ ⠄⠠ ⠄
       ⡰⠁                     ⠂                     ⠣⡀
     ⢀⠜                       ⡁                      ⠑⡄
    ⢀⠎                        ⠄                       ⠘⢄
   ⢠⠃                         ⠂                        ⠈⢆
  ⡠⠃                          ⡁                         ⠈⢢
 ⡰⠁                           ⠄                           ⢣
⡰⠁                            ⠂                            ⠣
⠁                             ⠁                               -100.0
-10.0                                                    10.0
extern crate textplots;

use textplots::{Chart, Plot, Shape};

fn main() {
    Chart::default()
    .lineplot( Shape::Continuous( |x| { (-x.powf(2.0)) } ))
    .lineplot( Shape::Continuous( |x| { (x.powf(2.0)) } ))
    .display();
}
loony-bean commented 5 years ago

Hey @bazzb My apologies for keeping this without progress for long time, I understand this bug could be annoying.

If you think it is something you can fix, I'd be happy to merge it.