Skip to content
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

[RDF] support bar charts in RDataFrame #17057

Open
silverweed opened this issue Nov 26, 2024 · 7 comments
Open

[RDF] support bar charts in RDataFrame #17057

silverweed opened this issue Nov 26, 2024 · 7 comments

Comments

@silverweed
Copy link
Contributor

Feature description

It would be nice if RDataFrame supported bar charts (aka TH[123] with alphanumeric bins). Currently there is a way to achieve it with a user-defined helper, but having a native API would be helpful.
Internally the helper should probably use a TH1L to store the count of occurrences for the column.

Alternatives considered

No response

Additional context

This would allow modernizing tutorials such as this and avoid the use of TTree::Draw

@dpiparo
Copy link
Member

dpiparo commented Nov 26, 2024

This is an interesting feature request: thanks. The current formulation seems to hint to the need of it to modernise a tutorial. The cost benefit ratio, as it stands, does not seem too favourable. Would the feature also address an explicit need of ROOT's users?

@silverweed
Copy link
Contributor Author

@dpiparo the only user case I'm aware of is the forum thread linked above by @will-cern

@Aditya-138-12
Copy link

Hello @vepadulano I would love to help on this feature request...

@dpiparo
Copy link
Member

dpiparo commented Dec 19, 2024

Hi @Aditya-138-12 ! Thanks for reaching out. Would you like to try to propose a PR, test coverage and an example of this functionality?

@Aditya-138-12
Copy link

Hi, @dpiparo ! yeah sure, working on it!!

@dpiparo
Copy link
Member

dpiparo commented Jan 11, 2025

Hi @Aditya-138-12 did you encounter difficulties?

@Aditya-138-12
Copy link

Aditya-138-12 commented Jan 12, 2025

Hi @dpiparo,

Yes, I am facing some difficulties in implementing this functionality, but I have been working through it. Initially, I thought of asking for help, but I decided to try to resolve it on my own by searching for solutions online and try to not to disturb you. So far, I’ve made some improvements and I’ve attached a video of these improvements.

The issue I’m facing is related to installing and running ROOT from source. I ended up downloading it via the snap framework and running ROOT in my terminal, but it's been a bit of a struggle.

I’ve written a function in my code which takes the following arguments:

A RDataFrame (df) for processing data.
A std::string for the column name, which contains the data for the bar chart.
A std::string for the chart's name.
A std::string for the chart's title.
This function processes the column data by:

Extracting unique values from the specified column of the RDataFrame using Takestd::string.
It creates a set to hold unique values and generates the bin labels.
A RBarChart object is initialized, and a TH1D histogram is defined with the generated bin labels.
The function then fills the histogram with the corresponding values from the column.

While the overall structure is in place, I’m still working on debugging some edge cases related to how the bin values are being mapped in the histogram and ensuring proper data processing. I would appreciate any advice or thoughts you have.

Below is the video of the improvements, and the header file of my functionality

Operating System - Linux

out-3.mp4

Link of the Header File: https://drive.google.com/file/d/1oeVmuxMHiM1oo_OMxvd8rd2pIMA434qC/view?usp=sharing

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

5 participants