Skip to content

'QuadContourSet' object has no attribute 'collections' error #43

@NickCH-K

Description

@NickCH-K

Hi again!

The below code worked fine when I wrote it a few months ago, but now produces the error

'QuadContourSet' object has no attribute 'collections'

when I run it, specifically on the plotting step. Note that an extreme-type plot works fine, it's the baseline plot that doesn't.

import pandas as pd
import statsmodels.formula.api as smf
import sensemakr as smkr

from causaldata import ccdrug
cc = ccdrug.load_pandas().data

# The full set of covariates, everything but intercept and treatment
all_covs = list(cc.columns[1:])
# Regress on male and all covariates
m = smf.ols('custody ~ male + ' + ' + '.join(list(cc.columns[1:])), 
    data=cc).fit()
# Get covariate names again, this time accounting for factor names
covs = list(m.params.index)
covs.remove('male')
covs.remove('Intercept')


bounds = smkr.Sensemakr(m,treatment = "male",
                              benchmark_covariates={
                          'All Covariates': covs,
                          'Culpability': covs[15:17],
                          'Drug Class': covs[10:15]})
# Make a graph, with a big range for the "All Covariates" adjustment
bounds.plot(treatment = 'male', lim = .3, lim_y = 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions