plotters-rs / plotters

A rust drawing library for high quality data plotting for both WASM and native, statically and realtimely 🦀 📈🚀
https://plotters-rs.github.io/home/
MIT License
3.89k stars 281 forks source link

Feature that allows axis inside the plot #33

Closed 38 closed 5 years ago

38 commented 5 years ago

See discuss under issue #31

serzhiio commented 5 years ago

Any idea how to inset chart axis and labels while its not implemented?

38 commented 5 years ago

The fastest way, you may already know is draw it yourself. Since Plotters expose full drawing API to developer.

Things may be helpful to you is:

First, we can use this https://docs.rs/plotters/0.2.7/plotters/chart/struct.ChartContext.html#method.plotting_area To get the plotting area.

Then, you can use https://docs.rs/plotters/0.2.7/plotters/drawing/struct.DrawingArea.html#method.draw to draw anything you want on to it.

So the thing may looks like:

      let mut chart ....;
      let pda = chart.plotting_area();
      let range: RangedCoordi32 = (0..100).into();
      for y in range.key_points(5) {
                // In here we get desired location for the tick marks. 
                pda.draw(.....);
      }

Hopefully you can draw anything you want. Feel free to ask me if you have any question :)

In addition, please check this page on what element you can draw: https://docs.rs/plotters/0.2.7/plotters/element/index.html#structs

serzhiio commented 5 years ago

I have almost done this feature. Hope will PR soon...

38 commented 5 years ago

Merged #50