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

Grouping factors in barplot are not showing correctly #169

Open
TheWildParamecium opened this issue Jul 29, 2024 · 11 comments
Open

Grouping factors in barplot are not showing correctly #169

TheWildParamecium opened this issue Jul 29, 2024 · 11 comments

Comments

@TheWildParamecium
Copy link

Good morning, I hope you are well.

I was writing this issue because I have found an unexpected behavior in the way grouping factors are generated for a barplot.

When I use the grouping factors inside the config in the following order:

'groupingFactors': ['dataset', 'doc_type']

The plot comes out as you would expect:

cX-obj_10_ (1)

However, when I use the opposite grouping order:

'groupingFactors': ['doc_type', 'dataset']

I get the following plot:

cX-obj_10_ (2)

Where you can see that the arrangement of the bars in the plot has not changed and that only the values of the grouping labels below the X-axis have been changed, although it is still the order ['dataset', 'doc_type' ] instead of ['doc_type' , 'dataset'].

I leave all the additional information of how the graphic has been created in the figure itself generated with CanvasXpress, but if you need any additional information just let me know.

Thank you very much for your help.

Best wishes,
Jesus

@TheWildParamecium
Copy link
Author

I have just noticed that the same anomalous behavior also occurs when trying to use the grouping factors with boxplots.

It works fine with grouping factors given in one way:
cX-obj_0_ (1)

But not when given in the inverse way:
cX-obj_0_

@neuhausi
Copy link
Owner

neuhausi commented Aug 5, 2024

What am I missing? You are grouping the data by the same groups so the data is not going to change. The only thing that will change is the order in which the factors are displayed. Can you please explain what you were expecting?

@TheWildParamecium
Copy link
Author

TheWildParamecium commented Sep 3, 2024

Yes, you are right about that.

The problem is precisely that the grouping order is not being done correctly in the second case, since by the given grouping factors order, I would expect the labels (and the 4 bars of grouped data displayed) to be ‘abstracts, paper, abstract, paper’ for the first level/row on the X-axis labels and ‘DO, Ehrhart’ for the second level/row of the X-axis labels, with the data also being displayed that way respectively.

I don't know if I'm making myself clear, but I can try to manually modify the figure to show it visually if necessary.

Edit: I finally did a mock example to illustrate it.

Captura desde 2024-09-03 15-19-34

@TheWildParamecium
Copy link
Author

Good morning Isaac.

I am sorry to bother you again. Is there any update on this issue?

@neuhausi
Copy link
Owner

Ooops. I drop the ball here sorry

@neuhausi
Copy link
Owner

Is this the expected behavior?
cX-obj_0_ (1)
cX-obj_0_

@TheWildParamecium
Copy link
Author

Good afternoon.

Please don't worry, it is fine. So sorry by my side, I was the one that completely forgot about this issue.

Yes, exactly! Now I see that the boxplots are being properly displayed according to the order of the grouping factors, so I am completely satisfied with that.

Just a minor matter to comment on (nothing of concern, it would be fine anyway), it is just that I expected the style of labels on the X-axis to follow the format of the second image you have shown.

Applied to the first image, it would be like to flip the labels shown above (do and ehrhart)x2 to the bottom level, and conversely, the labels on the top level (closest to the graph) would be (abstracts and papers)x4.

I am attaching below a modified image of how I would have expected the first image:
Captura desde 2024-10-03 16-11-18

@TheWildParamecium
Copy link
Author

Good afternoon Isaac. It has been a long time. I hope you had a good year.

I was checking my github and just noticed this issue again. I just realised that I totally misunderstood your last message, and yes it would be fixed with the change you showed me in the last two images. Thank you very much for that. Is that fix already implemented in the current version of CanvasXpress?

Best wishes,
Jesús

@neuhausi
Copy link
Owner

Oh. I just understood the issue. You meant the lines. Right?

@neuhausi
Copy link
Owner

I can't reproduce it. Can you share a small dataset so I can debug?

@TheWildParamecium
Copy link
Author

TheWildParamecium commented Feb 13, 2025

Good morning. I am sorry for the delay.

Exactly. The lines failed to show in my example.

I dragged the two images you linked in the message in Sep 18-2024 into an interactive html canvasxpress container and I was looking at the changes in the reproducible code you used to be able to recreate those two images.

The question I have is that I don't see that you reverse the order of the grouping factors in the config (‘groupingFactors’: [‘dataset’, ‘doc_type’] vs ‘groupingFactors’: [‘doc_type’, ‘dataset’]) to get the grouping orders to be the ones you show in those two images. Maybe that's not how it's supposed to work and I misunderstood. After a while of checking what could be the difference to get the figure as you showed it, I saw that there was a difference in the ‘afterRender’ stack for one of the two images:

(...) [ ‘sortSamplesByCategory’, [ [doc_type"], null ] ] (...)

the problem is that I've seen that ‘sortSamplesByCategory’ doesn't exist as a parameter to use inside ‘config’, and I've seen that afterRender can no longer be used when instantiating a CanvasXpress class Object, so I don't know how I could recreate the two images programmatically (without having to generate the image first and then adjust the order of the two factors interactively).

I have recreated a toy dataset example with few values for this case. For this case I am not able to flip the order of the factors (with the latest version of CanvasXpress available).

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants