Esempio n. 1
0
def plot_model(data):
    N = 5
    #初始化
    theta = radar_factory(N, frame='polygon')

    fig = plt.figure(figsize=(8, 6))
    fig.subplots_adjust(wspace=0.25, hspace=0.20, top=0.85, bottom=0.05)

    colors = ['b', 'r', 'g', 'm', 'y']
    # Plot the four cases from the example data on separate axes
    #['L', 'R', 'F', 'M', 'C']('ZL', 'ZC', 'ZM', 'ZF', 'ZR')

    spoke_labels = ('ZL', 'ZC', 'ZM', 'ZF', 'ZR')
    ax = fig.add_subplot(111, projection='radar')
    plt.rgrids([0.1, 0.5, 1, 1.5, 2.0, 2.5])
    ax.set_title(u'客户群分析',
                 weight='bold',
                 size='medium',
                 position=(0.5, 1.1),
                 horizontalalignment='center',
                 verticalalignment='center')
    for d, color in zip(data, colors):
        ax.plot(theta, d, color=color)
        ax.fill(theta, d, facecolor=color, alpha=0.25)
    ax.set_varlabels(spoke_labels)

    labels = ('1', '2', '3', '4', '5')
    legend = plt.legend(labels, loc=(0.9, .95), labelspacing=0.1)
    plt.setp(legend.get_texts(), fontsize='small')
    plt.show()
Esempio n. 2
0
def renderRadarFigure(dFrame, teamName, taskNames, outFileName):
    #the index of the current team in the dataFrame is needed to access the scores quickly
    teamIndex = list(dFrame.index).index(teamName)
    scores = [dFrame[curTask][teamIndex] for curTask in taskNames]

    font = {'family': 'normal', 'weight': 'normal', 'size': 25}

    rc('font', **font)

    theta = radar_factory(len(taskNames), frame='polygon')
    fig = plt.figure(figsize=(9, 9))
    plt.axes(projection='radar')
    plt.rgrids([0.1, 1, 2], ['0', '1', '2'])
    plt.plot(theta, scores, color='r', linewidth=2)
    plt.ylim(-1.5, 3)
    plt.gca().set_varlabels(taskNames)
    plt.gca().fill(theta, scores, facecolor='r', alpha=0.25)
    plt.tight_layout(pad=0.4, w_pad=0.8, h_pad=1.0)
    plt.savefig(outFileName)
    plt.close()
Esempio n. 3
0
    return averageStats


r1 = requests.get(
    "http://www.kelanyll.com/fpl-wrapper/player?name=Reece%20James")
r2 = requests.get(
    "http://www.kelanyll.com/fpl-wrapper/player?name=Trent%20Alexander-Arnold")
jamesStats = r1.json()
trentStats = r2.json()

stats = ['Influence', 'Creativity', 'Threat']
lowerStats = list(map(lambda x: x.lower(), stats))
jamesAverageStats = getAverageStats(lowerStats, jamesStats['history'])
trentAverageStats = getAverageStats(lowerStats, trentStats['history'])

theta = radar_chart.radar_factory(3)
fig, ax = plt.subplots(figsize=(5, 6), subplot_kw=dict(projection='radar'))
ax.set_varlabels(stats, position=[0, 0.1])
ax.set_rlabel_position(60)
ax.set_title("Reece James vs Trent Alexander-Arnold ICT",
             weight='bold',
             size='large',
             position=(0.5, 1.15),
             horizontalalignment='center')
ax.plot(theta, jamesAverageStats, label="Reece James", color="blue")
ax.fill(theta, jamesAverageStats, facecolor="blue", alpha=0.25)
ax.plot(theta, trentAverageStats, label="Trent Alexander-Arnold", color="red")
ax.fill(theta, trentAverageStats, facecolor="red", alpha=0.25)
ax.legend(loc=(0.7, 1), fontsize="x-small")
plt.show()
Esempio n. 4
0
def main():

    # ID the top ten by lowest average MAPE
    top10 = df.loc[df.filter(regex="mape*").mean(
        axis=1).sort_values()[:10].index]
    data = top10[list(R32.param_names)].values

    N = 6
    #theta = radar_factory(N, frame='polygon')
    theta = radar_factory(N, frame='circle')

    spoke_labels = [
        "$\mathregular{\sigma_C}$",
        "$\mathregular{\sigma_F}$",
        "$\mathregular{\sigma_H}$",
        "$\mathregular{\epsilon_C}$",
        "$\mathregular{\epsilon_F}$",
        "$\mathregular{\epsilon_H}$",
    ]

    fig, ax = plt.subplots(figsize=(9, 9), subplot_kw=dict(projection='radar'))

    colors = seaborn.color_palette('bright', n_colors=len(data))
    # Plot the four cases from the example data on separate axes
    ax.set_rgrids([0.2, 0.4, 0.6, 0.8, 1.0])
    for d, color in zip(data, colors):
        ax.plot(theta,
                d,
                '-o',
                markersize=12,
                color=color,
                linewidth=3,
                zorder=-5,
                alpha=0.65,
                markeredgewidth=4)
        ax.fill(theta, d, facecolor=color, alpha=0.11, zorder=-5)
    ax.set_theta_direction(-1)
    ax.set_theta_offset(np.pi / 2)
    ax.set_ylim(0, 1.0)
    ax.set_yticklabels([0.2, 0.4, 0.6, 0.8, 1.0], fontsize=22)
    for label in ax.get_yticklabels():
        label.set_bbox(
            dict(facecolor='white',
                 edgecolor='none',
                 alpha=0.25,
                 boxstyle=mpatch.BoxStyle("round4")))

    ax.set_varlabels(spoke_labels, fontsize=50)
    ax.set_rlabel_position(180 / N)

    for label in ax.get_xticklabels():
        x, y = label.get_position()
        label.set_position((x, y - 0.1))
    ax.yaxis.grid(linewidth=3, alpha=0.75)
    ax.spines['polar'].set_linewidth(4)

    fig.savefig("pdfs/fig_r32-top10-radar.pdf")

    # Plot all
    data = df[list(R32.param_names)].values

    N = 6
    #theta = radar_factory(N, frame='polygon')
    theta = radar_factory(N, frame='circle')

    fig, ax = plt.subplots(figsize=(9, 9), subplot_kw=dict(projection='radar'))

    colors = seaborn.color_palette('bright', n_colors=len(data))
    # Plot the four cases from the example data on separate axes
    ax.set_rgrids([0.2, 0.4, 0.6, 0.8, 1.0])
    for d, color in zip(data, colors):
        ax.plot(theta,
                d,
                '-o',
                markersize=10,
                color=color,
                linewidth=3,
                zorder=-5,
                alpha=0.65,
                markeredgewidth=2)
        ax.fill(theta, d, facecolor=color, alpha=0.06)
    ax.set_theta_direction(-1)
    ax.set_theta_offset(np.pi / 2)
    ax.set_ylim(0, 1.0)
    ax.set_yticklabels([0.2, 0.4, 0.6, 0.8, 1.0], fontsize=26)
    for label in ax.get_yticklabels():
        label.set_bbox(
            dict(facecolor='white',
                 edgecolor='none',
                 alpha=0.25,
                 boxstyle=mpatch.BoxStyle("round4")))

    ax.set_varlabels(spoke_labels, fontsize=50)
    ax.set_rlabel_position(180 / N)

    for label in ax.get_xticklabels():
        x, y = label.get_position()
        label.set_position((x, y - 0.1))

    ax.yaxis.grid(linewidth=3, alpha=0.65)
    ax.spines['polar'].set_linewidth(4)

    fig.savefig("pdfs/fig_r32-all-radar.pdf")
Esempio n. 5
0
                     [0.07, 0.95, 0.05, 0.04, 0.00, 0.02, 0.12, 0.00, 0.00],
                     [0.01, 0.02, 0.86, 0.27, 0.16, 0.19, 0.00, 0.00, 0.00],
                     [0.01, 0.03, 0.00, 0.32, 0.29, 0.27, 0.00, 0.00, 0.95],
                     [0.02, 0.00, 0.03, 0.37, 0.56, 0.47, 0.87, 0.00, 0.00]]),
        ('CO & O3', [[0.87, 0.01, 0.08, 0.00, 0.00, 0.04, 0.00, 0.00, 0.01],
                     [0.09, 0.95, 0.02, 0.03, 0.00, 0.01, 0.13, 0.06, 0.00],
                     [0.01, 0.02, 0.71, 0.24, 0.13, 0.16, 0.00, 0.50, 0.00],
                     [0.01, 0.03, 0.00, 0.28, 0.24, 0.23, 0.00, 0.44, 0.88],
                     [0.02, 0.00, 0.18, 0.45, 0.64, 0.55, 0.86, 0.00, 0.16]])
    ]
    return data


if __name__ == '__main__':
    N = 9
    theta = radar_factory(N, frame='polygon')

    data = example_data()
    spoke_labels = data.pop(0)

    fig, axs = plt.subplots(figsize=(9, 9),
                            nrows=2,
                            ncols=2,
                            subplot_kw=dict(projection='radar'))
    fig.subplots_adjust(wspace=0.25, hspace=0.20, top=0.85, bottom=0.05)

    colors = ['b', 'r', 'g', 'm', 'y']
    # Plot the four cases from the example data on separate axes
    for ax, (title, case_data) in zip(axs.flat, data):
        ax.set_rgrids([0.2, 0.4, 0.6, 0.8])
        ax.set_title(title,