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

The legend colors do not match the Pie chart colors #1062

Closed
ajay1685 opened this issue Sep 26, 2022 · 3 comments · Fixed by #1068
Closed

The legend colors do not match the Pie chart colors #1062

ajay1685 opened this issue Sep 26, 2022 · 3 comments · Fixed by #1068
Labels

Comments

@ajay1685
Copy link
Contributor

ajay1685 commented Sep 26, 2022

Bug report

Describe the bug
When using Charts.pieChart() the colors of the chart match the colors for that class of objects. However, the colors of the legend do not match!

To Reproduce
Steps to reproduce the behavior:

  1. Run Positive cell detection on an image
  2. Use the following code to create a pie chart:
    chartData = getDetectionObjects().countBy(p -> p.getPathClass())
    Charts.pieChart()
        .title('Test Chart')
        .data(chartData)
        .show()

Expected behavior
The colors of the legend shall match the colors of the pie.

Screenshots

Desktop (please complete the following information):

  • OS: Windows 10
  • QuPath Version: Tested on v2.3 and the latest snapshot

Additional context
More details on the forum:
https://forum.image.sc/t/pie-chart-legend-colors/72051

@ajay1685 ajay1685 added the bug label Sep 26, 2022
@ajay1685 ajay1685 changed the title The colors in the legend do not match the Pie chart colors The legend colors do not match the Pie chart colors Sep 26, 2022
@petebankhead
Copy link
Member

Thanks @ajay1685 for reporting this!

@petebankhead
Copy link
Member

Just adding for reference that this self-contained script shows the problem as well:

def chartData =
     [(getPathClass('Negative')): 5,
     (getPathClass('1+')): 2,
     (getPathClass('2+')): 3,
     (getPathClass('3+')): 4]
     
Charts.pieChart()
    .title('Test Chart')
    .data(chartData)
    .show()

[Also learned that non-string keys in Groovy need to be in (brackets)...]

petebankhead added a commit to petebankhead/qupath that referenced this issue Oct 4, 2022
Addresses qupath#1062 *but*
* only for 8 chart colors (inconsistency returns if there are more slices in the pie chart)
* only if modena.css is the base
petebankhead added a commit to petebankhead/qupath that referenced this issue Oct 4, 2022
Fixes qupath#1062 - at least when using modena.css as a basis.

Also addresses two issues with the pie charts shown when training a pixel/object classifier:
* the legend should now be correct even when more than 8 classes are used
* there is no longer any need to write a temporary css file for styling
@petebankhead
Copy link
Member

This should be fixed now... along with a hidden bug that gave the wrong legend colors with pixel/object classifiers if more than 8 classes were used (which admittedly would probably not work well anyway).

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

Successfully merging a pull request may close this issue.

2 participants