Skip to content

Commit

Permalink
BUG: example plot compatibility with older matplotlib versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jakevdp committed Dec 20, 2011
1 parent a2bb3ff commit 0c38141
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
11 changes: 8 additions & 3 deletions examples/covariance/plot_covariance_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,20 @@

###############################################################################
# Plot results
pl.figure(-1)
pl.figure()
pl.title("Regularized covariance: likelihood and shrinkage coefficient")
pl.xlabel('Shrinkage')
pl.ylabel('Negative log-likelihood')
# range shrinkage curve
pl.loglog(shrinkages, negative_logliks)

# real likelihood reference
pl.hlines(loglik_real, pl.xlim()[0], pl.xlim()[1], color='red',
label="real covariance likelihood", linestyle='--')
# BUG: hlines(..., linestyle='--') breaks on some older versions of matplotlib
#pl.hlines(loglik_real, pl.xlim()[0], pl.xlim()[1], color='red',
# label="real covariance likelihood", linestyle='--')
pl.plot(pl.xlim(), 2*[loglik_real], '--r',
label="real covariance likelihood")

# adjust view
lik_max = np.amax(negative_logliks)
lik_min = np.amin(negative_logliks)
Expand Down
16 changes: 11 additions & 5 deletions examples/plot_permutation_test_for_classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,17 @@
# View histogram of permutation scores
pl.hist(permutation_scores, 20, label='Permutation scores')
ylim = pl.ylim()
pl.vlines(score, ylim[0], ylim[1], linestyle='--',
color='g', linewidth=3, label='Classification Score'
' (pvalue %s)' % pvalue)
pl.vlines(1.0 / n_classes, ylim[0], ylim[1], linestyle='--',
color='k', linewidth=3, label='Luck')
# BUG: vlines(..., linestyle='--') fails on older versions of matplotlib
#pl.vlines(score, ylim[0], ylim[1], linestyle='--',
# color='g', linewidth=3, label='Classification Score'
# ' (pvalue %s)' % pvalue)
#pl.vlines(1.0 / n_classes, ylim[0], ylim[1], linestyle='--',
# color='k', linewidth=3, label='Luck')
pl.plot(2 * [score], ylim, '--g', linewidth=3,
label='Classification Score'
' (pvalue %s)' % pvalue)
pl.plot(2 * [1. / n_classes], ylim, '--k', linewidth=3, label='Luck')

pl.ylim(ylim)
pl.legend()
pl.xlabel('Score')
Expand Down

0 comments on commit 0c38141

Please sign in to comment.