I'm pretty new to python, so I am working through the nltk book. I am also trying to become familiar with manipulating graphs and plots. I plotted a conditional frequency distribution, and I would like to start by removing the top and left spines. This is what I have:
import nltk
import sys
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.pyplot import show
from nltk.corpus import state_union
#cfdist1
cfd = nltk.ConditionalFreqDist(
(word, fileid[:4])
for fileid in state_union.fileids()
for w in state_union.words(fileid)
for word in ['men', 'women', 'people']
if w.lower().startswith(word))
cfd.plot()
for loc, spine in cfd.spines.items():
if loc in ['left','bottom']:
spine.set_position(('outward',0)) # outward by 0
elif loc in ['right','top']:
spine.set_color('none') # don't draw spine
else:
raise ValueError('unknown spine location: %s'%loc)
I get the following error:
AttributeError: 'ConditionalFreqDist' object has no attribute 'spines'
Is there any way to manipulate a conditonal frequency distribution? Thank you!