plotters-rs / guide

The Plotters Guide
MIT License
7 stars 5 forks source link

First code example doesn't compile #3

Open Rik-de-Kort opened 4 years ago

Rik-de-Kort commented 4 years ago

Working on Ubuntu Eoan. Unsure what to do as I am very new to Rust.

Code

use plotters::prelude::*;

fn main() {
    let root_drawing_area = BitMapBackend::new("result.png", (1024, 768))
        .into_drawing_area();

    root_drawing_area.fill(&WHITE);

    let chart = ChartBuilder::on(&root_drawing_area)
        .build_ranged(-3.14..3.14, -1.2..1.2)
        .unwrap();

    chart.draw(LineSeries::new(
        (-314..314).map(|x| x as f64 / 100.0).map(|x| (x, x.sin())),
        &RED
    )).unwrap();
}

yields error:

   Compiling mcmc v0.1.0 (/home/rik/mcmc)
error[E0599]: no method named `draw` found for type `plotters::chart::context::ChartContext<'_, plotters::drawing::backend_impl::bitmap::BitMapBackend<'_>, plotters::coord::ranged::RangedCoord<_, _>>` in the current scope
  --> src/main.rs:16:11
   |
16 |     chart.draw(LineSeries::new(
   |           ^^^^ method not found in `plotters::chart::context::ChartContext<'_, plotters::drawing::backend_impl::bitmap::BitMapBackend<'_>, plotters::coord::ranged::RangedCoord<_, _>>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `mcmc`.

To learn more, run the command again with --verbose.

shell returned 101
38 commented 4 years ago

Hi, you should use draw_series rather than draw. Please let me know if it's still broken.