Skip to content

#25 make the plots better#31

Merged
Asifdotexe merged 3 commits into
mainfrom
25-make-the-plots-better
Oct 11, 2025
Merged

#25 make the plots better#31
Asifdotexe merged 3 commits into
mainfrom
25-make-the-plots-better

Conversation

@Asifdotexe

@Asifdotexe Asifdotexe commented Oct 11, 2025

Copy link
Copy Markdown
Owner

This PR aims to improve the plot's aesthetics.

Plot type Old New
Barplot image image
Histogram image image
Boxplot (Univariate) image image
Scatterplot image image
Boxplot (Bivariate) image image
Multivariate analysis image image

Summary by CodeRabbit

  • New Features

    • Unified plot styling for a consistent look across all charts.
    • Chart directory can be provided as a string or path-like object; outputs now return relative file paths.
  • Style

    • Enhanced visuals: clearer titles and axis labels, improved scatter transparency, diverging heatmap colormap with gridlines, consistent primary color usage, and bar annotations for categorical plots.
  • Refactor

    • Standardized path handling for chart generation and saving.
    • Early checks and warnings when no numeric columns are available for multivariate plots.

@Asifdotexe Asifdotexe self-assigned this Oct 11, 2025
@Asifdotexe Asifdotexe linked an issue Oct 11, 2025 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Oct 11, 2025

Copy link
Copy Markdown

Walkthrough

Adds a new styling module and integrates it across univariate, bivariate, and multivariate plotting. All three plot generators now accept Path-like directories, use pathlib for path construction, return relative string paths, and apply standardized styling. Visual tweaks were made per plot type, and multivariate adds a guard for missing numeric columns.

Changes

Cohort / File(s) Summary
Plot generation API and path handling
src/dora/plots/bivariate.py, src/dora/plots/multivariate.py, src/dora/plots/univariate.py
Update generate_plots signatures to accept Union[str, Path] and return list[str]; convert charts_dir to Path; build save paths via pathlib; return relative string paths; invoke styling setup at start.
Per-plot visual adjustments
src/dora/plots/bivariate.py
Add scatter alpha, titles/axis labels, and PRIMARY_COLOR for categorical plots; collect relative plot paths.
Heatmap and guards
src/dora/plots/multivariate.py
Use diverging colormap, linewidths, descriptive title; compute relative path via Path.relative_to; add early exit with warning if no numeric columns.
Univariate aesthetics and annotations
src/dora/plots/univariate.py
Apply PRIMARY_COLOR to hist/box/bar; enhanced titles/labels/grid; annotate bar counts; construct paths via Path and return relative strings.
Styling module introduction
src/dora/plots/styling.py
Add constants PRIMARY_COLOR, GRAY_COLOR, BACKGROUND_COLOR, TEXT_COLOR; add apply_custom_styling() configuring seaborn style/palette and matplotlib rcParams.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Caller
    participant PlotModule as generate_plots(...)
    participant Styling as apply_custom_styling()
    participant FS as Filesystem
    participant Viz as Matplotlib/Seaborn

    Caller->>PlotModule: generate_plots(df, charts_dir, config_params)
    Note over PlotModule: New/changed: Path-like handling
    PlotModule->>Styling: apply_custom_styling()
    Styling-->>PlotModule: rcParams/seaborn configured

    PlotModule->>PlotModule: charts_dir_path = Path(charts_dir)
    alt For each feature/plot type
        PlotModule->>Viz: create plot (titles/labels/colors updated)
        Viz-->>PlotModule: Axes/Figure
        PlotModule->>FS: savefig(charts_dir_path / "...png")
        FS-->>PlotModule: file saved
        PlotModule->>PlotModule: collect relative string path
    end

    Note over PlotModule: Multivariate: guard if no numeric columns → early return
    PlotModule-->>Caller: list[str] of relative plot paths
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I hop through paths of Path and string,
With palettes set, I style everything.
A grid of plots, neat titles shine,
Heatmaps hum in a diverging line.
I nibble warnings, save each chart—
A tidy warren, artisanal art. 🐇🖼️

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title Check ❓ Inconclusive The title “#25 make the plots better” references an issue and broadly indicates improvements to plotting, but it is too generic to convey the key updates such as adding custom styling, type-flexible path handling, and enhanced annotations across univariate, bivariate, and multivariate plots. Please update the title to clearly summarize the main change in one concise sentence, for example: “Enhance plot generation with custom styling, Path support, and improved annotations.”
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 25-make-the-plots-better

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 48f74fa and b28bcd3.

📒 Files selected for processing (4)
  • src/dora/plots/bivariate.py (3 hunks)
  • src/dora/plots/multivariate.py (3 hunks)
  • src/dora/plots/styling.py (1 hunks)
  • src/dora/plots/univariate.py (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
src/dora/plots/univariate.py (3)
src/dora/plots/styling.py (1)
  • apply_custom_styling (19-62)
src/dora/plots/bivariate.py (1)
  • generate_plots (16-85)
src/dora/plots/multivariate.py (1)
  • generate_plots (16-63)
src/dora/plots/bivariate.py (3)
src/dora/plots/styling.py (1)
  • apply_custom_styling (19-62)
src/dora/plots/multivariate.py (1)
  • generate_plots (16-63)
src/dora/plots/univariate.py (1)
  • generate_plots (16-100)
src/dora/plots/multivariate.py (3)
src/dora/plots/styling.py (1)
  • apply_custom_styling (19-62)
src/dora/plots/bivariate.py (1)
  • generate_plots (16-85)
src/dora/plots/univariate.py (1)
  • generate_plots (16-100)
🔇 Additional comments (14)
src/dora/plots/styling.py (3)

1-9: LGTM! Clear documentation and appropriate imports.

The module docstring effectively communicates the design philosophy, and the imports are minimal and well-chosen.


11-16: LGTM! Well-chosen color palette.

The color constants provide a cohesive, professional palette with good contrast and visual hierarchy.


19-61: LGTM! Well-structured styling configuration.

The function effectively centralizes visual styling with thoughtful choices:

  • Removes chart clutter (top/right spines, tick marks)
  • Adds appropriate padding for readability
  • Uses accessible font choices with fallbacks

Note: The grid color is set to white ("grid.color": "#ffffff" on line 30) matching the white background, making the grid invisible. This appears intentional per the "de-cluttering" principle in the module docstring.

src/dora/plots/bivariate.py (3)

6-7: LGTM! Improved type annotations and imports.

The function signature now accepts both string and Path objects for charts_dir, improving flexibility while maintaining backward compatibility. The explicit return type annotation list[str] clarifies the API contract.

Also applies to: 13-13, 16-21


30-30: LGTM! Proper styling initialization and path handling.

The styling is applied early, ensuring consistent visual appearance. Converting charts_dir to a Path object enables robust path operations throughout the function.

Also applies to: 39-39


51-72: LGTM! Enhanced plot aesthetics and proper path handling.

The visual improvements are well-executed:

  • Alpha transparency on scatter plots helps with overplotting
  • Consistent title formatting across plot types
  • Proper use of pathlib for path construction and relative path conversion

Note: The scatter plot doesn't explicitly use PRIMARY_COLOR like the boxplot does (line 64). This appears intentional to rely on matplotlib's default color cycle, which provides automatic color variation when multiple features are plotted.

Also applies to: 76-76, 80-80

src/dora/plots/multivariate.py (3)

6-7: LGTM! Consistent type annotations and imports.

The function signature now accepts both string and Path objects, aligning with the other plotting modules (univariate and bivariate) for a consistent API across the plotting subsystem.

Also applies to: 13-13, 16-18


27-27: LGTM! Consistent initialization pattern.

The styling application and path conversion follow the same pattern established in the univariate and bivariate modules, promoting consistency.

Also applies to: 29-29


47-54: LGTM! Effective heatmap styling improvements.

The visual enhancements are well-chosen:

  • Diverging color palette (blue-to-red) is a standard, intuitive choice for correlation matrices
  • Cell line widths improve readability by separating values
  • Title formatting is consistent with the other plotting modules

The path operations correctly use pathlib's / operator and convert to relative paths for the return value.

Also applies to: 57-57, 60-60

src/dora/plots/univariate.py (5)

6-7: LGTM! Consistent API improvements.

The function signature and imports align perfectly with the patterns established in the bivariate and multivariate modules, ensuring a unified API across all plotting functions.

Also applies to: 13-13, 16-18


27-27: LGTM! Standard initialization pattern.

Consistent with the other plotting modules in applying styling early and converting the directory path.

Also applies to: 29-29


39-48: LGTM! Well-styled histogram with clear labeling.

The enhancements effectively improve readability:

  • PRIMARY_COLOR ensures consistent visual branding
  • Title formatting matches the other plot types
  • Axis labels and grid aid interpretation

The grid is a particularly good addition for histograms, helping viewers align bins with the frequency axis.


51-58: LGTM! Effective boxplot styling.

The styling improvements are well-applied. Note that unlike the histogram (line 48), no grid is added for the boxplot. This is appropriate since boxplots are less dependent on precise axis alignment than histograms.


60-60: LGTM! Comprehensive barplot improvements and proper path handling.

The changes significantly enhance the barplot:

  • Capturing the axes object (ax = sns.countplot(...)) enables the value annotations
  • The annotations (lines 84-92) display count values directly on bars, improving accessibility
  • Removing the y-axis label (line 82) is appropriate since the category names are self-explanatory
  • Path operations correctly use pathlib throughout

This is a particularly effective enhancement, as the direct labeling reduces cognitive load for readers.

Also applies to: 64-64, 71-92, 94-94, 97-97


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Asifdotexe
Asifdotexe marked this pull request as ready for review October 11, 2025 10:06
@Asifdotexe

Copy link
Copy Markdown
Owner Author

@coderabbitai help

@coderabbitai

coderabbitai Bot commented Oct 11, 2025

Copy link
Copy Markdown

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit configuration file (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@Asifdotexe
Asifdotexe merged commit 3d430e0 into main Oct 11, 2025
2 checks passed
@Asifdotexe
Asifdotexe deleted the 25-make-the-plots-better branch October 12, 2025 07:21
@coderabbitai coderabbitai Bot mentioned this pull request Jan 4, 2026
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.

make the plots better

1 participant