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

Additional attribute plot types (dot, strip, density) #366

Merged
merged 9 commits into from
Aug 6, 2024

Conversation

JakeWags
Copy link
Member

@JakeWags JakeWags commented Jul 5, 2024

Does this PR close any open issues?

Closes #249

Give a longer description of what this PR addresses and why it's needed

This PR adds the ability to change the plot displayed in the attribute columns for a given attribute.

The options are: Box Plot, Strip Plot, Dot Plot

Question: For dot plots, should jitter be introduced? As is, there is not jitter and so these behave very similarly to the strip plot option. See photo in comments for jitter example.

Provide pictures/videos of the behavior before and after these changes (optional)

Example of dot plot, strip plot, and box plot on three different attributes:
image

Have you added or updated relevant tests?

  • Yes
  • No changes are needed

Have you added or updated relevant documentation?

  • Yes
  • No changes are needed

Are there any additional TODOs before this PR is ready to go?

No

Copy link

netlify bot commented Jul 5, 2024

Deploy Preview for upset2 ready!

Name Link
🔨 Latest commit d6a230d
🔍 Latest deploy log https://app.netlify.com/sites/upset2/deploys/66a2c326ba58b00008819d16
😎 Deploy Preview https://deploy-preview-366--upset2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@JakeWags
Copy link
Member Author

JakeWags commented Jul 10, 2024

Added jitter for dot plots in 94a7205 note that rows under or equal to size 5 will have no jitter.

Jitter is seeded based on row size and dot index. This ensures that re-renders do not trigger any jitter updates. This makes the jitter consistent for a row, no matter the context, addressing one of my main gripes about jitter in dot plots.

image

@JakeWags JakeWags force-pushed the 249-alternative-attribute-plots branch from cf1e8c1 to 94a7205 Compare July 10, 2024 16:50
@JakeWags JakeWags marked this pull request as ready for review July 10, 2024 16:57
@JakeWags JakeWags requested review from NateLanza and JackWilb July 10, 2024 16:58
Copy link
Contributor

@NateLanza NateLanza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments. I've also raised #368 after some thought on this PR; I don't think that's necessary to address here but it may be possible to ease future work.

@JakeWags JakeWags requested a review from NateLanza July 11, 2024 16:06
Copy link
Contributor

@NateLanza NateLanza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One documentation change is still needed from last PR, otherwise LGTM.

StripPlot = 'Strip Plot',
}

export type AttributePlots = Record<string, `${AttributePlotType}`>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my original comment wasn't clear: I think you should note that the string is the name of the attribute. So this record maps attribute names to their plot types.

/**
* Generates a y offset for the provided index.
* Seeded based on row size so that jitter is consistent between renders, and also varies between rows.
* Rows of the same size will have the same jitter.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks pretty good. ATM I also have a util function in my backselection PR that can hash a string, but probably not necessary here.

@JakeWags
Copy link
Member Author

image
Density Plot example:

Copy link
Member

@JackWilb JackWilb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Couple of very minor adjustments to comments

@@ -83,6 +83,13 @@ export const Upset: FC<UpsetProps> = ({
];
}

// for every visible attribute other than deviaiton and degree, add 'Box Plot' to their attribute plot type
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// for every visible attribute other than deviaiton and degree, add 'Box Plot' to their attribute plot type
// for every visible attribute other than deviaiton and degree, set their initial attribute plot type to 'Box Plot'

};

export const ATTRIBUTE_DEFAULT_COLOR = '#d3d3d3';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not already accounted for with the grey for the bars?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vega doesn't know what fill color to use for this, so I believe it will default to black if nothing is provided.

@JakeWags JakeWags changed the title Add strip plot and option to switch attribute plot Additional attribute plot types (dot, strip, density) Jul 17, 2024
@JakeWags JakeWags merged commit 09fc29c into main Aug 6, 2024
7 checks passed
@JakeWags JakeWags deleted the 249-alternative-attribute-plots branch August 6, 2024 21:21
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

Successfully merging this pull request may close these issues.

Add alternative visual encodings for attributes
3 participants