首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError in python CoLab

TypeError in python CoLab
EN

Stack Overflow用户
提问于 2022-07-03 08:56:18
回答 2查看 50关注 0票数 -2

我用Collab网站用Python编程,我得到了这个错误,我不知道如何纠正它。我试图将代码应用于某些数据集,但遇到了此错误。下面是代码的图片和错误在这里输入图像描述的另一张图片

EN

回答 2

Stack Overflow用户

发布于 2022-07-03 10:33:54

最好是看到您的代码,以努力准确地再现您的情况。

但如果我们说的是标签颜色和面部颜色,这就是一个很小的例子:

代码语言:javascript
复制
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()
票数 1
EN

Stack Overflow用户

发布于 2022-07-03 09:31:43

初始化labelcolor变量时需要删除fig参数:

代码语言:javascript
复制
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'
)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72845168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档