小编Tre*_*ney的帖子

如何向计数图中添加百分比?

我需要显示条形图的百分比。但是我不知道该怎么做。

sns.set_style('whitegrid')
sns.countplot(y='type',data=df,palette='colorblind')
plt.xlabel('Count')
plt.ylabel('Type')
plt.title('Movie Type in Disney+')
plt.show()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

python matplotlib seaborn plot-annotations countplot

0
推荐指数
1
解决办法
1186
查看次数

创建带有实心正方形和加号的自定义标记

我想创建具有自定义标记样式的线图。我特别想要一个带有加号或乘积符号的正方形(填充/未填充)。这个怎么做。下面的代码不起作用

import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
import numpy as np

# Sample data
x = np.linspace(0, 10, 100)
y = np.sin(x)

# Create a figure and axis
fig, ax = plt.subplots()

# Define the custom marker as a combination of a filled square and a plus symbol
def custom_marker():
    square = mpatches.Rectangle((-0.5, -0.5), 1, 1, linewidth=0, edgecolor='none', facecolor='red', zorder=2)
    plus = plt.Line2D([0, 0], [-0.4, 0.4], color='white', linewidth=2, zorder=3)
    plus2 = plt.Line2D([-0.4, 0.4], [0, 0], color='white', linewidth=2, zorder=3) …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

0
推荐指数
1
解决办法
180
查看次数

Http获取响应更新HTML,但在控制台中给出了未定义的错误

当我使用HttpClient使用响应Obj 更新html时,它会更新值,但会出现多个错误。

文件名-auth-service.ts。

    import { any } from 'codelyzer/util/function';
    import { Injectable } from '@angular/core';
    import { HttpClient } from '@angular/common/http';

    @Injectable()
    export class AuthService {

      constructor(private httpClient: HttpClient) { }
      get() {
        return this.httpClient.get<any>('/capi/v2/users/me', {
          observe: 'body',
          responseType: 'json'
        });
      }
    };
Run Code Online (Sandbox Code Playgroud)

文件名-dashboard.component.ts

    import { AuthService } from './../../services/api/auth-service';

    import { Component, Injectable, OnInit } from '@angular/core';

    @Component({
        selector: 'app-dashboard',
        templateUrl: './dashboard.component.html'
    })

    @Injectable()
    export class DashBoardComponent implements OnInit {
        user;
        constructor(private authService: AuthService) {}; …
Run Code Online (Sandbox Code Playgroud)

angular2-template angular2-services angular angular4-httpclient

-1
推荐指数
1
解决办法
531
查看次数

当我通过 Composer 安装 ckeditor 时出现错误。我该如何解决?

C:\xampp\htdocs\tutorial>composer require unisharp/laravel-ckeditor
Using version ^4.7 for unisharp/laravel-ckeditor
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Run Code Online (Sandbox Code Playgroud)

问题一

    - Installation request for unisharp/laravel-ckeditor ^4.7 -> satisfiable by unisharp/laravel-ckeditor[4.7.2].
    - Conclusion: remove laravel/framework v6.0.3
    - Conclusion: don't install laravel/framework v6.0.3
    - unisharp/laravel-ckeditor 4.7.2 requires illuminate/support ~5.0 -> satisfiable by illuminate/support[5.0.x-dev, 5.1.x-dev, 5.2.x-dev, 5.3.x-dev, 5.4.x-dev, 5.5.x-dev, 5.6.x-dev, 5.7.17, 5.7.18, 5.7.19, 5.7.x-dev, 5.8.x-dev, v5.0.0, v5.0.22, v5.0.25, …
Run Code Online (Sandbox Code Playgroud)

laravel

-1
推荐指数
1
解决办法
2612
查看次数

有没有办法在字符串中替换一次字母?

我遇到了一个问题,它要么将所有 Gs 替换为 Cs,但不将 C 替换为 Gs,我该怎么做才能解决这个问题?我现在得到的输出是“GUGAGGGGAG”我正在寻找的输出是“CUCAGCGCAG”这是我到目前为止的代码:

a_string = "GAGTCGCGTC" 
remove_characters = ["G", "A", "T", "C"]
ch1 = "G"
ch2 = "A"
ch3 = "T"
ch4 = "C"
a_string = a_string.replace (ch1, "C")
a_string = a_string.replace (ch2, "U")
a_string = a_string.replace (ch3, "A")
a_string = a_string.replace (ch4, "G")
print (a_string)
Run Code Online (Sandbox Code Playgroud)
  • 我正在做 DNA 到 RNA 的翻译代码!所以A替换为U,G替换为C,T替换为A,C替换为G

python bioinformatics biopython python-3.x

-2
推荐指数
1
解决办法
129
查看次数

值计数的饼图(显示百分比)

我有一个如下所示的数据框-

df = pd.DataFrame([
    ['Fully Paid',1,1],
    ['Fully Paid',1,1],
    ['Fully Paid',1,0],
    ['Defaulted',1,0],
    ['Defaulted',1,0]
], columns=['LoanStatus', 'B', 'C'])
Run Code Online (Sandbox Code Playgroud)

我希望将其绘制在饼图中,显示 60% 的贷款状态已全额支付,而 40% 为违约。我可以在计数图中执行此操作,但无法在饼图中执行此操作 -

COUNT PLOT: 

sns.countplot(x="LoanStatus",data=df)
Run Code Online (Sandbox Code Playgroud)

预期的:

饼图显示有多少个值以及贷款状态和百分比。

python matplotlib pandas

-2
推荐指数
1
解决办法
2万
查看次数