Skip to content

[Feature Request] Bar Graphs #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
caemor opened this issue Jan 8, 2020 · 5 comments
Closed

[Feature Request] Bar Graphs #98

caemor opened this issue Jan 8, 2020 · 5 comments

Comments

@caemor
Copy link

caemor commented Jan 8, 2020

What is the feature ?

Add support for bar graphs which are similar to histograms but slightly different ;-)

Examples for bar graphs:

image

(image from https://www.mathsisfun.com/data/bar-graphs.html)

or
image

(Optional) Why this feature is useful and how people would use the feature ?

It's similar to histograms but is more focused on categories/... and doesn't only work for continous data.

@38
Copy link
Member

38 commented Jan 9, 2020

Hi there, thanks for the feature request. If my understanding is correct, the feature is already supported by Plotters.

Plotters is actually a drawing library that makes plotting easier, which means it doesn't limits you on predefined plot types. In general, we abstract a series as a iterator of drawable elements.

Thus the feature can be supported by passing an iterator of rectangles to ChartContext::draw_series.

I am documenting all those stuff (but very slowly). And this may be more detailed answer to how to draw the chart. https://plotters-rs.github.io/book/basic/basic_data_plotting.html#histogram

@caemor
Copy link
Author

caemor commented Jan 9, 2020

Thanks for your response :-)
I already tried it with the histogram type yesterday but I wasn't able to either add specific labels to each rectangle (so I wouldn't need any floats) or to use float values in my histogram. So it's more a program to label my data correctly (or alternatively to draw it on the correct position of the diagram. But maybe I tried it the wrong way and would be happy to get some pointers if this is already possible with the current version.

@matiu2
Copy link

matiu2 commented Feb 12, 2020

I too would like to draw bar graphs. My X axis is a Category axis with values (in days): <1, 1-3, 3-6, 6-9 days, >9 days

I've spent almost a whole day trying to figure out how to do it. I think I want to use a plotters::coord::Category but Histogram's don't support that because it doesn't implement plotters::coord::DiscreteRanged

And of course I can't implement it in my own code; I'll try hacking the source..

matiu2 pushed a commit to matiu2/plotters that referenced this issue Feb 12, 2020
matiu2 pushed a commit to matiu2/plotters that referenced this issue Feb 12, 2020
@matiu2
Copy link

matiu2 commented Feb 12, 2020

Sorry I found a bug and force pushed.

It's still not working 100% for me; I'm getting an extra column on the left, and I have no idea why :(

All help appreciated.

image

matiu2 pushed a commit to matiu2/plotters that referenced this issue Feb 12, 2020
matiu2 pushed a commit to matiu2/plotters that referenced this issue Jul 5, 2020
@38
Copy link
Member

38 commented Sep 10, 2020

I suppose this is already supported by v0.3 when using slice as coord spec, so closing the issue

@38 38 closed this as completed Sep 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants