Я пытаюсь сделать круговую диаграмму из данных в этом CSV-файле.Проблема в том, что он работает, но отображает текст перед круговой диаграммой, и я хотел бы от него избавиться.
Кроме того, как я могу масштабировать гистограмму, чтобы она идеально вписывалась в рабочую книгу?
#imports for pandas and numpy
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import*
from collections import OrderedDict
from collections import Counter
#Importing the file where I get the data from
df = pd.read_csv('file.csv',delimiter=',', skipinitialspace = True)
df['artist genre'].value_counts()
genreArray = np.array(df['artist genre'])
keys = Counter(genreArray).keys()
values = Counter(genreArray).values()
#counts =Counter(genreArray)
plt.pie([float(v) for v in values], labels=[k for k in keys],
autopct=None,frame=True)
Результаты:
([<matplotlib.patches.Wedge at 0x28d57bec160>,
<matplotlib.patches.Wedge at 0x28d57bec6a0>,
<matplotlib.patches.Wedge at 0x28d57becbe0>,
<matplotlib.patches.Wedge at 0x28d57bf5160>,
<matplotlib.patches.Wedge at 0x28d57bf56a0>,
<matplotlib.patches.Wedge at 0x28d57bf5be0>,
<matplotlib.patches.Wedge at 0x28d57bfc160>,
<matplotlib.patches.Wedge at 0x28d57bfc6a0>,
<matplotlib.patches.Wedge at 0x28d57bfcc88>,
<matplotlib.patches.Wedge at 0x28d57c09208>,
<matplotlib.patches.Wedge at 0x28d5796acc0>,
<matplotlib.patches.Wedge at 0x28d57c09c50>,
<matplotlib.patches.Wedge at 0x28d57c101d0>,
<matplotlib.patches.Wedge at 0x28d57c10710>],
[Text(0.801866,0.753002,'Pop'),
Text(-0.646564,0.889919,'Hip Hop'),
Text(-1.08052,-0.206119,'Electronic Dance Music'),
Text(-0.753002,-0.801865,'Latin Pop'),
Text(-0.273559,-1.06544,'R&B'),
Text(0.172078,-1.08646,'Pop Rock'),
Text(0.339919,-1.04616,'Electronic Music'),
Text(0.468357,-0.99531,'Deep House'),
Text(0.701166,-0.847565,'Reggaeton'),
Text(0.946816,-0.559946,'Progressive House'),
Text(1.04616,-0.339919,'Dance Pop'),
Text(1.08052,-0.20612,'Electropop'),
Text(1.09512,-0.103519,'Country'),
Text(1.09946,-0.0345519,'Indie Pop')])
