我用Collab网站用Python编程,我得到了这个错误,我不知道如何纠正它。我试图将代码应用于某些数据集,但遇到了此错误。下面是代码的图片和错误在这里输入图像描述的另一张图片
发布于 2022-07-03 10:33:54
最好是看到您的代码,以努力准确地再现您的情况。
但如果我们说的是标签颜色和面部颜色,这就是一个很小的例子:
from matplotlib import pyplot as plt
import pandas as pd
# Set the figure size
plt.rcParams["figure.figsize"] = [7.00, 3.50]
# plt.rcParams["figure.autolayout"] = True
# Create a figure and set of subplots
fig, ax = plt.subplots()
ax.set_ylabel('$number$ of clients')
# Get the data
df = pd.read_csv('https://raw.githubusercontent.com/tokern/piicatcher/master/tests/samples/sample-data.csv')
df.groupby(['state'])['city'].count().plot(kind='bar')
# Set the facecolor
ax.set_facecolor('black')
# Set the labelcolor
ax.xaxis.label.set_color('red')
ax.spines['bottom'].set_color('red')
ax.tick_params(axis='x', colors='red')
# Set the legend with other facecolor
ax.legend(fontsize = 11,
facecolor = 'lightgray',
edgecolor = 'red',
title = 'Clients by',
title_fontsize = '12',
)
plt.title("US Clients")
plt.show()发布于 2022-07-03 09:31:43
初始化labelcolor变量时需要删除fig参数:
fig = plt.figure(
FigureClass = Waffle,
rows = 4,
columns = 8,
values = gender,
colors = ('#B13167', '#3274A1'),
labels = ['{} - {}'.format(a, b) for a, b in zip(gender.index, gender)],
legend = {
'loc': 'upper left',
'bbox_to_anchor': (1, 1),
'fontsize': 15,
'title': 'Gender',
'title_fontsize': 15,
'facecolor': 'white'
},
font_size = 75,
icons = ['venus', 'mars'],
icon_legend = True,
figsize = (15, 8),
facecolor = 'black'
)https://stackoverflow.com/questions/72845168
复制相似问题