-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
More flexible plotting (histogram, box plot...) #467
Comments
More additions to the plotting library are very much welcome from my side! I'm not sure if adding this to But maybe you can implement something that is analogous to the current |
Thanks for the answer. Glad to hear this is not out of scope! Just to see if I understand correctly, you are talking about doing another To be specific, my use case for histograms is something like that https://github.com/38/plotters-doc-data/blob/master/normal-dist2.png (curve + histo). And same with boxes: curve + box. That's why I thought about piggybacking on the existing I will try to come up with some code with your suggestion, so we can discuss on something more concrete. |
Ah, I see. Yes the curve+histo and curve+box use case mean that we shouldn't discard the idea of adding it to But I'd recommend not going with I think we should be able to make the |
I did a draft in #499 for the specific plots I mentioned. I think I have found something simple, in line with your suggestion of making |
Thanks for the suggestion @akhilman. I actually looked at plotters before opening this PR, but I did not see how to get back the interactivity in a simple way (zoom, hover, highlight, etc.). |
I've implemented this (with your help) in #863, this issue can be closed. |
Closed by #863 |
I am impressed by how nice the plotting is in egui. It would be really useful to have more capabilities, like histograms or box plots.
My attempt
I was not at all familiar with the codebase, but I tried to create such plots. A quick way I could get it done was: modify the
Points
struct, include something like a hashmap fromValue
to adyn Trait
that knows how to draw an element. Thisdyn Trait
would contain the actual values of, say, a given box. Thedyn Trait
is to provide maximum flexibility to the end user:Then at the call site (
get_shapes
inItemPlot
), one can fetch the correct drawing impl for a givenValue
and create aVec<Shape>
.There are a few problems with this approach:
Value
is notHash
norEq
, this means hacking arround itpub
(so end users can create their own drawings), this means puttingpub
onScreenTransform
andBounds
Value
is duplicated in memory, both in theValues
struct and the hashmap(I am not sharing code about what I describe because its a mess ;))
Some ideas for implementing this feature
Idea 1
Creating a new
impl
forPlotItem
similar the existingPoints
(like I describe above).Benefits: minimal code modification. Drawbacks: the ones I cited above.
Idea 2
Modifying
Value
orValues
, so they carry more data and the way they can be drawn. I am thinking about something likeBenefits: this seems to be the "conceptually correct way" to do it. In the future it can potentially be used to implement some custom axis labels (categorical data,...). Drawback: I have no idea where it leads to, there are probably some object safety issues. This might change a lot of code.
I don't know if such feature is in scope for the library. If it is, I would be glad to take a stab at it. Since this is the first time I play with eguis codebase, I am probably missing something. I am sure there are other, better ways to implement it, happy to discuss if someone thinks of one.
The text was updated successfully, but these errors were encountered: