def curvelinear_test1(fig):
    """Grid for custom transform."""
    def tr(x, y):
        sgn = np.sign(x)
        x, y = np.abs(np.asarray(x)), np.asarray(y)
        return sgn * x**.5, y

    def inv_tr(x, y):
        sgn = np.sign(x)
        x, y = np.asarray(x), np.asarray(y)
        return sgn * x**2, y

    grid_helper = GridHelperCurveLinear(
        (tr, inv_tr),
        extreme_finder=ExtremeFinderSimple(20, 20),
        # better tick density
        grid_locator1=MaxNLocator(nbins=6),
        grid_locator2=MaxNLocator(nbins=6))

    ax1 = Subplot(fig, 111, grid_helper=grid_helper)
    # ax1 will have a ticks and gridlines defined by the given
    # transform (+ transData of the Axes). Note that the transform of the Axes
    # itself (i.e., transData) is not affected by the given transform.

    fig.add_subplot(ax1)

    ax1.imshow(np.arange(25).reshape(5, 5),
               vmax=50,
               cmap=plt.cm.gray_r,
               origin="lower")
def test_axis_direction():
    # Check that axis direction is propagated on a floating axis
    fig = plt.figure()
    ax = Subplot(fig, 111)
    fig.add_subplot(ax)
    ax.axis['y'] = ax.new_floating_axis(nth_coord=1, value=0,
                                        axis_direction='left')
    assert ax.axis['y']._axis_direction == 'left'
def test_Subplot():
    fig = plt.figure()

    ax = Subplot(fig, 1, 1, 1)
    fig.add_subplot(ax)

    xx = np.arange(0, 2 * np.pi, 0.01)
    ax.plot(xx, np.sin(xx))
    ax.set_ylabel("Test")

    ax.axis["top"].major_ticks.set_tick_out(True)
    ax.axis["bottom"].major_ticks.set_tick_out(True)

    ax.axis["bottom"].set_label("Tk0")
def lineGraph(all_data, eps):
    fig = plt.figure(1, (18 * 2, 9 * 2))
    ax = Subplot(fig, 111)
    fig.add_subplot(ax)

    ax.plot(eps, all_data, 'ro-', label='POI聚类总数')
    ax.axis["right"].set_visible(False)
    ax.axis["top"].set_visible(False)
    ax.set_xlabel('聚类距离', fontsize=30)
    ax.set_ylabel('聚类总数', fontsize=30)
    ax.tick_params(labelsize=20)

    plt.legend()
    plt.savefig(os.path.join(savingFig, "lineGraph"))
    plt.show()
def curvelinear_test1(fig):
    """
    grid for custom transform.
    """
    def tr(x, y):
        sgn = np.sign(x)
        x, y = np.abs(np.asarray(x)), np.asarray(y)
        return sgn * x**.5, y

    def inv_tr(x, y):
        sgn = np.sign(x)
        x, y = np.asarray(x), np.asarray(y)
        return sgn * x**2, y

    extreme_finder = angle_helper.ExtremeFinderCycle(
        20,
        20,
        lon_cycle=None,
        lat_cycle=None,
        # (0, np.inf),
        lon_minmax=None,
        lat_minmax=None,
    )

    grid_helper = GridHelperCurveLinear((tr, inv_tr),
                                        extreme_finder=extreme_finder)

    ax1 = Subplot(fig, 111, grid_helper=grid_helper)
    # ax1 will have a ticks and gridlines defined by the given
    # transform (+ transData of the Axes). Note that the transform of
    # the Axes itself (i.e., transData) is not affected by the given
    # transform.

    fig.add_subplot(ax1)

    ax1.imshow(np.arange(25).reshape(5, 5),
               vmax=50,
               cmap=plt.cm.gray_r,
               interpolation="nearest",
               origin="lower")

    # tick density
    grid_helper.grid_finder.grid_locator1._nbins = 6
    grid_helper.grid_finder.grid_locator2._nbins = 6
def curvelinear_test1(fig):
    """
    grid for custom transform.
    """

    def tr(x, y):
        sgn = np.sign(x)
        x, y = np.abs(np.asarray(x)), np.asarray(y)
        return sgn*x**.5, y

    def inv_tr(x, y):
        sgn = np.sign(x)
        x, y = np.asarray(x), np.asarray(y)
        return sgn*x**2, y

    extreme_finder = angle_helper.ExtremeFinderCycle(20, 20,
                                                     lon_cycle=None,
                                                     lat_cycle=None,
                                                     # (0, np.inf),
                                                     lon_minmax=None,
                                                     lat_minmax=None,
                                                     )

    grid_helper = GridHelperCurveLinear((tr, inv_tr),
                                        extreme_finder=extreme_finder)

    ax1 = Subplot(fig, 111, grid_helper=grid_helper)
    # ax1 will have a ticks and gridlines defined by the given
    # transform (+ transData of the Axes). Note that the transform of
    # the Axes itself (i.e., transData) is not affected by the given
    # transform.

    fig.add_subplot(ax1)

    ax1.imshow(np.arange(25).reshape(5, 5),
               vmax=50, cmap=plt.cm.gray_r,
               interpolation="nearest",
               origin="lower")

    # tick density
    grid_helper.grid_finder.grid_locator1._nbins = 6
    grid_helper.grid_finder.grid_locator2._nbins = 6
Esempio n. 7
0
def test_Subplot():
    fig = plt.figure()

    ax = Subplot(fig, 1, 1, 1)
    fig.add_subplot(ax)

    xx = np.arange(0, 2 * np.pi, 0.01)
    ax.plot(xx, np.sin(xx))
    ax.set_ylabel("Test")

    ax.axis["top"].major_ticks.set_tick_out(True)
    ax.axis["bottom"].major_ticks.set_tick_out(True)

    ax.axis["bottom"].set_label("Tk0")
Esempio n. 8
0
def test_Subplot():
    # Remove this line when this test image is regenerated.
    plt.rcParams['text.kerning_factor'] = 6

    fig = plt.figure()

    ax = Subplot(fig, 1, 1, 1)
    fig.add_subplot(ax)

    xx = np.arange(0, 2 * np.pi, 0.01)
    ax.plot(xx, np.sin(xx))
    ax.set_ylabel("Test")

    ax.axis["top"].major_ticks.set_tick_out(True)
    ax.axis["bottom"].major_ticks.set_tick_out(True)

    ax.axis["bottom"].set_label("Tk0")
def test_subplot():
    fig = plt.figure(figsize=(5, 5))
    ax = Subplot(fig, 111)
    fig.add_subplot(ax)
Esempio n. 10
0
server_type_category = cursor.fetchall()
print(server_type_category)

first_image_frequency_x = [15, 16, 17, 19, 20, 21]
first_image_vcpu_count = [4, 6, 8, 10, 12, 14]
line_color = ['dimgrey', 'black', 'slategray']
line_marker = ['v', '^', 's', 'p']

figure = plt.figure(figsize=(10, 10))
# fig, axes = plt.subplots(int(len(first_image_vcpu_count) / 2), 2)
# ax=axisartist.Subplot(fig,2,2,1)
# fig.add_axes(ax)
# ax.axis["bottom"].set_axisline_style("-|>", size = 1.5)
# ax.axis["left"].set_axisline_style("->", size = 1.5)
for cpu_count_index in range(0, len(first_image_vcpu_count)):
    ax = Subplot(figure, int(len(first_image_vcpu_count) / 2), 2,
                 cpu_count_index + 1)
    figure.add_subplot(ax)
    values = {}
    values["memory_count"] = "4"
    for server_type_index in range(0, len(server_type_category)):
        values["server_type"] = server_type_category[server_type_index][0]
        # ax = axes[int(cpu_count_index / 2), cpu_count_index % 2]
        values["cpu_number"] = first_image_vcpu_count[cpu_count_index]
        result = []
        for cpu_frequency_index in range(0, len(first_image_frequency_x)):
            values["cpu_frequency"] = first_image_frequency_x[
                cpu_frequency_index]
            cursor_DictCursor.execute(select_record, values)
            print(values)
            select_result = cursor_DictCursor.fetchall()
            print(select_result)
Esempio n. 11
0
standard_average_energy = np.nan*np.ones(shape=(len(accuracy_required),len(no_of_hidden_nodes)))
caching_average_energy = np.nan*np.ones(shape=(len(accuracy_required),len(no_of_hidden_nodes)))
for iAccu in range(len(accuracy_required)):
    for iNode in range(len(no_of_hidden_nodes)):
        tmp = ~np.isnan(standard_energy[iAccu][iNode])
        standard_average_energy[iAccu][iNode] = np.mean(standard_energy[iAccu][iNode][tmp])
        tmp = ~np.isnan(caching_energy[iAccu][iNode])
        caching_average_energy[iAccu][iNode] = np.mean(caching_energy[iAccu][iNode][tmp])


arr_color = ['red','black']
arr_linestyle = ['-','--',':']
arr_label = ['No caching','Synaptic caching']

fig = plt.figure(facecolor="white",figsize=(4.5,4))
ax = Subplot(fig,111)
fig.add_subplot(ax)
for iAccu in range(len(accuracy_required)):
    plt.plot(no_of_hidden_nodes,standard_average_energy[iAccu],color=arr_color[0],linewidth=3,linestyle=arr_linestyle[iAccu],label=arr_label[0]+', '+str(accuracy_required[iAccu]))
    plt.plot(no_of_hidden_nodes,caching_average_energy[iAccu],color=arr_color[1],linewidth=3,linestyle=arr_linestyle[iAccu],label=arr_label[1]+', '+str(accuracy_required[iAccu]))
plt.xlabel('# hidden units',fontsize=24)
#plt.ylabel('Energy [arbitrary unit]',fontsize=28)
plt.yscale('log')
plt.xlim(0,no_of_hidden_nodes[0])
#plt.xticks(np.linspace(0,10,11))
plt.ylim(1e3,1e6)
plt.xticks([0,50,100,150,200])
plt.yticks([1e3,1e4,1e5,1e6])
ax.axis["right"].set_visible(False)
ax.axis["top"].set_visible(False)
#ax.axis["bottom"].label.set_text('# hidden units')
Esempio n. 12
0
DFs = []
for root, dirs, files in os.walk(
        dir_path):  #第一个为起始路径,第二个为起始路径下的文件夹,第三个是起始路径下的文件。
    for file in files:
        file_path = os.path.join(root, file)  #将路径名和文件名组合成一个完整路径
        df = pd.read_excel(file_path)  #excel转换成DataFrame
        DFs.append(df)

df = pd.concat(DFs)
df = df.query('50>胸径>20')
"""
胸径树高频率频数分布拟合
"""
x = np.array(df['胸径'])
fig = plt.figure(figsize=(10, 6))
ax = Subplot(fig, 221)
fig.add_subplot(ax)
ax.axis["right"].set_visible(False)
ax.axis["top"].set_visible(False)
n, bins, c = ax.hist(df['胸径'], bins=range(23, 51, 2), edgecolor='black')
y = n
x = bins[:-1]
ztfb = get_curve_fit_param(x, y, func, p0=[5, 35, 6])
ztfbpre = func(x, *ztfb)
# ax.plot(x,y,'r*',ls='-')
ax.plot(x, ztfbpre, 'b+', ls='-', color='orange')
wbfb = get_curve_fit_param(x, y, weib, p0=[20, 20, 5])
wbfbpre = weib(x, *wbfb)
# plt.plot(x,y,'r*')
ax.plot(x, wbfbpre, 'b+', ls='-')
plt.xticks(range(24, 51, 2))
Esempio n. 13
0
server_type_category = cursor.fetchall()
print(server_type_category)

first_image_frequency_x = [15, 16, 17, 19, 20, 21]
first_image_vcpu_count = [1, 2, 4, 6, 8, 10]
line_color = ['dimgrey', 'black', 'silver']
line_marker = ['v', '^', 's', 'p']

figure = plt.figure(figsize=(11, 11))
# fig, axes = plt.subplots(int(len(first_image_vcpu_count) / 2), 2)
# ax=axisartist.Subplot(fig,2,2,1)
# fig.add_axes(ax)
# ax.axis["bottom"].set_axisline_style("-|>", size = 1.5)
# ax.axis["left"].set_axisline_style("->", size = 1.5)
for cpu_count_index in range(0, len(first_image_vcpu_count)):
    ax = Subplot(figure, int(len(first_image_vcpu_count) / 2), 2,
                 cpu_count_index + 1)
    figure.add_subplot(ax)
    values = {}
    values["memory_count"] = "4"
    line_list = []
    server_type_list = []
    for server_type_index in range(0, len(server_type_category) - 1):
        values["server_type"] = server_type_category[server_type_index][0]
        server_type_list.append(server_type_category[server_type_index][0])
        # ax = axes[int(cpu_count_index / 2), cpu_count_index % 2]
        values["cpu_number"] = first_image_vcpu_count[cpu_count_index]
        result = []
        for cpu_frequency_index in range(0, len(first_image_frequency_x)):
            values["cpu_frequency"] = first_image_frequency_x[
                cpu_frequency_index]
            cursor_DictCursor.execute(select_record, values)
Esempio n. 14
0
def tbme_plot(r_name, bg_ham, curr_ham, vlc_num):
    # I want a TBME scatter plot for fitted TBME
    a = bg_ham.strong.copy()
    a = a[a['group'] != 'other']
    b = curr_ham.strong.copy()
    b = b[b['group'] != 'other']
    c = a.merge(b,
                left_on=['k1', 'k2', 'k3', 'k4', 'j', 't'],
                right_on=['k1', 'k2', 'k3', 'k4', 'j', 't'])

    fig = plt.figure(figsize=(6, 6))
    matplotlib.rcParams.update({'font.size': 12})
    ax = Subplot(fig, 111)
    fig.add_subplot(ax)
    ax.set_xlabel('TBME (MeV) starting')
    ax.set_ylabel('TBME (MeV) with {} vlc'.format(vlc_num))
    ax.set_aspect('equal')
    x, y = c['v_x'].tolist(), c['v_y'].tolist()
    min, max = -3, 1.
    plt.xticks(np.arange(min, max, 0.5))
    plt.yticks(np.arange(min, max, 0.5))
    plt.plot([min, max], [min, max], ls='--', color='black')
    ax.scatter(x, y)
    ax.axhline(0., ls='-', color='black')
    ax.axvline(0., ls='-', color='black')
    plt_name = r_name + '\\tbme-vlc-{}.png'.format(vlc_num)
    plt.savefig(plt_name)
    plt.close(fig)

    return
Esempio n. 15
0
"""
================
Simple Axisline3
================

"""
import matplotlib.pyplot as plt
from mpl_toolkits.axisartist.axislines import Subplot

fig = plt.figure(1, (3,3))

ax = Subplot(fig, 111)
fig.add_subplot(ax)

ax.axis["right"].set_visible(False)
ax.axis["top"].set_visible(False)

plt.show()
Esempio n. 16
0
select_record = "select * from pi5000 where server_type=%(server_type)s and cpu_number=%(cpu_number)s and cpu_frequency=%(cpu_frequency)s and memory_count=%(memory_count)s"

select_server_type_category = "select distinct server_type from pi5000 "
cursor.execute(select_server_type_category)
server_type_category = cursor.fetchall()
print(server_type_category)

first_image_frequency_x = [12, 13, 15, 16, 17, 19, 20, 21]
first_image_vcpu_count = [8]
line_color = ['dimgrey', 'black', 'silver']
line_marker = ['v', '^', 's', 'p']

figure = plt.figure(figsize=(5, 5))

for cpu_count_index in range(0, len(first_image_vcpu_count)):
    ax = Subplot(figure, 1, 1, 1)
    figure.add_subplot(ax)
    values = {}
    values["memory_count"] = "4"
    line_list = []
    server_type_list = []
    for server_type_index in range(0, len(server_type_category) - 1):
        values["server_type"] = server_type_category[server_type_index][0]
        server_type_list.append(server_type_category[server_type_index][0])
        # ax = axes[int(cpu_count_index / 2), cpu_count_index % 2]
        values["cpu_number"] = first_image_vcpu_count[cpu_count_index]
        result = []
        for cpu_frequency_index in range(0, len(first_image_frequency_x)):
            values["cpu_frequency"] = first_image_frequency_x[
                cpu_frequency_index]
            cursor_DictCursor.execute(select_record, values)