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

Plot recipes #582

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

irregular-rhomboid
Copy link

This PR builds on the discussion in #581 and provides summary plots of LinearModels for both Plots and Makie. The plots are based on those from R's plot.lm function. While one new lightweight dependency is needed for RecipesBase, the plots are implemented as extensions for StatsPlots and Makie.

Implemented features

  • Plots are implemented for the equivalent of R's Residual plot, Scale-Location plot, Q-Q plot, Residuals-Leverage plot and Cook's distance vs leverage plot. The interface for these functions is the same for both plotting packages.
  • A summary plot function lmplot displaying the residual plot, Q-Q plot, scale-location plot and residuals-leverage plot. The configurability of this function is limited, however.
  • The computation of the leverages has been factored out into a function in lm.jl.
  • For the StatsPlots extension, default values for the axis labels and title are provided. This is not available for the Makie extension, except in lmplot.
  • Basic docstrings are provided for all the new functions

Not implemented

  • Documentation in docs/. This seems like a good thing to add.
  • Tests (it is not clear how to test for both plotting packages at the same time)
  • Loess smoothing. This is a feature in the R plots which would require another dependency to implement, for unclear benefits.
  • Outlier labelling (see last image)

Examples

StatsPlots:

using GLM
using StatsPlots
using RDatasets

data = dataset("datasets", "trees")

l = lm(@formula(Height ~ Girth + Volume), data)

lmplot(l; size = (700,500))

plotlmJulia

Makie:

using GLM
using CairoMakie
using RDatasets

data = dataset("datasets", "trees")

l = lm(@formula(Height ~ Girth + Volume), data)

lmplot(l; size = (700,500))

makie

R equivalent:
lmplotsR

Copy link

codecov bot commented Jan 1, 2025

Codecov Report

Attention: Patch coverage is 3.78378% with 178 lines in your changes missing coverage. Please review.

Project coverage is 77.88%. Comparing base (89493a4) to head (45c3ff2).

Files with missing lines Patch % Lines
ext/StatsPlotsExt.jl 0.00% 114 Missing ⚠️
ext/MakieExt.jl 0.00% 60 Missing ⚠️
src/plots.jl 0.00% 4 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #582       +/-   ##
===========================================
- Coverage   90.33%   77.88%   -12.45%     
===========================================
  Files           8       11        +3     
  Lines        1107     1289      +182     
===========================================
+ Hits         1000     1004        +4     
- Misses        107      285      +178     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

1 participant