Exemple #1
0
def _blank_plot(domain, ran):
    # make the plot
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    # thicken the axis lines
    ax.axhline(linewidth=1.7, color="k")
    ax.axvline(linewidth=1.7, color="k")

    x_lower, x_upper = int(domain.left), int(
        domain.right)  # needs to be changed, is just a temporary type changer
    y_lower, y_upper = int(ran.left), int(ran.right)

    # remove tick lines on the axes
    plt.xticks([])
    plt.yticks([])
    plt.ylim(y_lower, y_upper)
    plt.xlim(x_lower, x_upper)

    # add axes labels
    ax.text(1.05,
            0,
            r'$x$',
            transform=BlendedGenericTransform(ax.transAxes, ax.transData),
            va='center')
    ax.text(0,
            1.05,
            r'$y$',
            transform=BlendedGenericTransform(ax.transData, ax.transAxes),
            ha='center')

    # end-of-axis arrows
    x_width = (abs(plt.xlim()[0]) + abs(plt.xlim()[1]))
    y_width = (abs(plt.ylim()[0]) + abs(plt.ylim()[1]))
    plt.arrow(plt.xlim()[1],
              -0.003,
              0.00000000001,
              0,
              width=x_width * 0.0015 * 0.5,
              color="k",
              clip_on=False,
              head_width=y_width * 0.12 / 7,
              head_length=x_width * 0.024 * 0.5)
    plt.arrow(0.003,
              plt.ylim()[1],
              0,
              0.00000000001,
              width=y_width * 0.0015 * 0.5,
              color="k",
              clip_on=False,
              head_width=x_width * 0.12 / 7,
              head_length=y_width * 0.024 * 0.5)

    # only show cartesian axes
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
Exemple #2
0
def _blank_plot(domain, ran):
    # make the plot
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    # thicken the axis lines
    ax.axhline(linewidth=1.7, color="k")
    ax.axvline(linewidth=1.7, color="k")

    x_lower, x_upper = int(domain.left), int(domain.right)  # needs to be changed, is just a temporary type changer
    y_lower, y_upper = int(ran.left), int(ran.right)

    # remove tick lines on the axes
    plt.xticks([])
    plt.yticks([])
    plt.ylim(y_lower, y_upper)
    plt.xlim(x_lower, x_upper)

    # add axes labels
    ax.text(1.05, 0, r'$x$', transform=BlendedGenericTransform(ax.transAxes, ax.transData), va='center')
    ax.text(0, 1.05, r'$y$', transform=BlendedGenericTransform(ax.transData, ax.transAxes), ha='center')

    # end-of-axis arrows
    x_width = (abs(plt.xlim()[0]) + abs(plt.xlim()[1]))
    y_width = (abs(plt.ylim()[0]) + abs(plt.ylim()[1]))
    plt.arrow(plt.xlim()[1], -0.003, 0.00000000001, 0,
              width=x_width*0.0015*0.5, color="k", clip_on=False,
              head_width=y_width*0.12/7, head_length=x_width*0.024*0.5)
    plt.arrow(0.003, plt.ylim()[1], 0, 0.00000000001,
              width=y_width*0.0015*0.5, color="k", clip_on=False,
              head_width=x_width*0.12/7, head_length=y_width*0.024*0.5)

    # only show cartesian axes
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)
Exemple #3
0
             'C{}'.format(i),
             label=label + r', $r_%i=%i$ mm' % (i + 1, r / 1000),
             clip_on=False)

# draw measurement points
ax3.plot(foursphereParams['r'][:, 0],
         foursphereParams['r'][:, 2],
         'ko',
         label='EEG/MEG sites')
for i, (x, y, z) in enumerate(foursphereParams['r']):
    # theta = np.arcsin(x / foursphereParams['radii'][-1])
    # if x >= 0:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi))
    # else:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi), ha='right')
    ax3.text(x, z + 2500, r'{}'.format(i + 1), ha='center')

# dipole location
ax3.plot([0], [dipole_position[-1]], 'k.', label='dipole site')
ax3.axis('equal')
ax3.set_xticks(np.r_[-np.array(foursphereParams['radii']), 0,
                     foursphereParams['radii']])
ax3.set_xticklabels([])
ax3.legend(loc=(0.25, 0.15), frameon=False)

# four-sphere volume conductor
sphere = LFPy.FourSphereVolumeConductor(**foursphereParams)
phi_p = sphere.calc_potential(cell.current_dipole_moment, rz=dipole_position)

# import example_parallel_network_plotting as plotting
vlimround = draw_lineplot(
Exemple #4
0
    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    
    theta = np.linspace(0, np.pi, 31)
    
    # draw some circles:
    for i, r, label in zip(range(4), PSET.foursphereParams['radii'], ['brain', 'CSF', 'skull', 'scalp']):
        ax.plot(np.cos(theta)*r, np.sin(theta)*r, 'C{}'.format(i), label=label + r', $r_%i=%i$ mm' % (i+1, r / 1000), clip_on=False)
    
    # draw measurement points
    ax.plot(PSET.foursphereParams['r'][:, 0], PSET.foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites')
    
    for i, (x, y, z) in enumerate(PSET.foursphereParams['r']):
        ax.text(x, z+2500, r'{}'.format(i+1), ha='center')
        
    # dipole location
    ax.plot([0], [PSET.foursphereParams['radii'][0] + PSET.layer_data['center'][3]], 'k.', label='dipole site')
    
    ax.axis('equal')
    ax.set_ylim(top=max(PSET.foursphereParams['radii']) + 5000)

    ax.set_xticks(np.r_[-np.array(PSET.foursphereParams['radii']), 0, PSET.foursphereParams['radii']])
    ax.set_xticklabels([])                       
    
    ax.legend(loc=(0.25, 0.05), frameon=False)
    
    ax.text(-0.1, 1.05, alphabet[5],
        horizontalalignment='center',
        verticalalignment='center',
Exemple #5
0
fig.add_subplot(ax1)
#
for direction in ["xzero", "yzero"]:
    ax1.axis[direction].set_axisline_style("-|>")
    ax1.axis[direction].set_visible(True)
#
for direction in ["left", "right", "bottom", "top"]:
    ax1.axis[direction].set_visible(False)

ax1.set_aspect('equal')

ax1.set_xlim(-Sig_max, Sig_max)
ax1.set_ylim(-Sig_max, Sig_max)
ax1.text(0.,
         1.05,
         'y',
         size=20,
         transform=BlendedGenericTransform(ax1.transData, ax1.transAxes))
ax1.text(1.05,
         -0.15,
         'x',
         size=20,
         transform=BlendedGenericTransform(ax1.transAxes, ax1.transData))

vec_phi_xy = ax1.quiver(0,
                        0,
                        0,
                        0,
                        width=10,
                        scale=1,
                        units='x',
Exemple #6
0
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt
import numpy as np


if __name__ == '__main__':

    fig = plt.figure(1)
    ax = SubplotZero(fig, 1, 1, 1)
    # fig.autofmt_xdate(bottom=0.2, rotation=30, ha='right')

    fig.add_subplot(ax)



    ax.text(-1.15, 0.99, 'y', transform=BlendedGenericTransform(ax.transData, ax.transAxes), ha='center')
    ax.text(1., -0.25, 'x', transform=BlendedGenericTransform(ax.transAxes, ax.transData), va='center')
    #
    for direction in ["xzero", "left"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    x = np.linspace(-1., +1., 1000) # x < 0
    # print(x)
    ax.plot(x, 3**((2*x)/(3*x+1)))


    plt.show()
Exemple #7
0
from mpl_toolkits.axes_grid.axislines import SubplotZero

x = linspace(-5 * pi, 5 * pi, 500)
y = (sin(x) / x)**2
fig = plt.figure(figsize=(8, 4))
ax = SubplotZero(fig, 111)
fig.add_subplot(ax)
ax.grid(True)
ax.set_xticks([
    -5 * pi, -4 * pi, -3 * pi, -2 * pi, -pi, 0, pi, 2 * pi, 3 * pi, 4 * pi,
    5 * pi
])
ax.set_xticklabels([
    "$-5 \pi$", "$-4 \pi$", "$-3 \pi$", "$-2 \pi$", "$- \pi$", "0", "$\pi$",
    "$2 \pi$", "$3 \pi$", "$4 \pi$", "$5 \pi$"
])
ax.set_ylim((-.3, 1.2))
ax.set_yticklabels([])
for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_axisline_style("->")
    ax.axis[direction].set_visible(True)
for direction in ["left", "right", "bottom", "top"]:
    ax.axis[direction].set_visible(False)
ax.plot(x, y, label=r"$sinc^{2} \ x$", color="k", linewidth=3, alpha=0.8)
ax.text(5.5 * pi, 0., "x")
ax.text(0.1, 1, "1")
ax.legend()
plt.tight_layout()
plt.savefig("sinc.png")
plt.show()
Exemple #8
0
from matplotlib.transforms import BlendedGenericTransform
import matplotlib.pyplot as plt
import numpy

if 1:
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    ax.axhline(linewidth=1.7, color="black")
    ax.axvline(linewidth=1.7, color="black")

    plt.xticks(range(5))
    plt.yticks(range(1,5))

    ax.text(0, 1.05, '$x_{2}$', transform=BlendedGenericTransform(ax.transData, ax.transAxes), ha='center')
    ax.text(1.025, 0, '$x_{1}$', transform=BlendedGenericTransform(ax.transAxes, ax.transData), va='center')

    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    x = numpy.linspace(-1, 3.5, 1000)
    y = (4 - 2*x)
    ax.plot(x,y)

    plt.annotate('$y=1$',xy=(1.75,1.5))
    plt.annotate('$y=0$',xy=(0.5,1))
Exemple #9
0
if __name__ == '__main__':

    fig = plt.figure(1)
    ax = SubplotZero(fig, 1, 1, 1)

    fig.add_subplot(ax)

    labels = range(-4,5)
    plt.plot(labels, labels, color="w")


    ax.axhline(linewidth=.7, color="black")
    ax.axvline(linewidth=.7, color="black")

    ax.text(0, 1.05, 'y', transform=BlendedGenericTransform(ax.transData, ax.transAxes), ha='center')
    ax.text(1.05, 0, 'x', transform=BlendedGenericTransform(ax.transAxes, ax.transData), va='center')
    #
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    for label in ax.get_ymajorticklabels():
        label.set_rotation(123)

    x = np.linspace(-4, 0, 100) # x < 0
    f1, = ax.plot(x, -(x), label="-x")
Exemple #10
0
theta = np.linspace(0, np.pi, 31)

# draw some circles:
for i, r, label in zip(range(4), foursphereParams['radii'], ['brain', 'CSF', 'skull', 'scalp']):
    ax3.plot(np.cos(theta)*r, np.sin(theta)*r, 'C{}'.format(i), label=label + r', $r_%i=%i$ mm' % (i+1, r / 1000), clip_on=False)

# draw measurement points
ax3.plot(foursphereParams['r'][:, 0], foursphereParams['r'][:, 2], 'ko', label='EEG/MEG sites')
for i, (x, y, z) in enumerate(foursphereParams['r']):
    # theta = np.arcsin(x / foursphereParams['radii'][-1])
    # if x >= 0:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi))
    # else:
    #     ax3.text(x, z+5000, r'${}\pi$'.format(theta / np.pi), ha='right')
    ax3.text(x, z+2500, r'{}'.format(i + 1), ha='center')
    
# dipole location
ax3.plot([0], [dipole_position[-1]], 'k.', label='dipole site')
ax3.axis('equal')
ax3.set_xticks(np.r_[-np.array(foursphereParams['radii']), 0, foursphereParams['radii']])
ax3.set_xticklabels([])                       
ax3.legend(loc=(0.25, 0.15), frameon=False)



# four-sphere volume conductor
sphere = LFPy.FourSphereVolumeConductor(
    **foursphereParams
)
phi_p = sphere.calc_potential(cell.current_dipole_moment, rz=dipole_position)
Exemple #11
0
# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import SubplotZero
import numpy as np
import fractions
# 改変箇所をまとめておく
FIGNUM = 1 # 0 or 1
if FIGNUM == 0:
    t_max, step = 2, fractions.Fraction(1,3) # 傾きの最大、最小値の設定
    # 傾きをいくつ刻みで変化させるか。分数のまま計算させるためにFraction()を利用した
if FIGNUM == 1:
    t_max, step = 3, fractions.Fraction(1,2)
x_max = 7
y_max = 6
y_min = -5

def f(x, t):
	return t*x-t**2
# 以上が改変箇所

t_min = -t_max  # 対称性の利用
x_min = -x_max
if 1:
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)
    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)
    for direction in ["left", "right", "bottom", "top"]:
Exemple #12
0
    for i, r, label in zip(range(4), PSET.foursphereParams['radii'],
                           ['brain', 'CSF', 'skull', 'scalp']):
        ax.plot(np.cos(theta) * r,
                np.sin(theta) * r,
                'C{}'.format(i),
                label=label + r', $r_%i=%i$ mm' % (i + 1, r / 1000),
                clip_on=False)

    # draw measurement points
    ax.plot(PSET.foursphereParams['r'][:, 0],
            PSET.foursphereParams['r'][:, 2],
            'ko',
            label='EEG/MEG sites')

    for i, (x, y, z) in enumerate(PSET.foursphereParams['r']):
        ax.text(x, z + 2500, r'{}'.format(i + 1), ha='center')

    # dipole location
    ax.plot([0],
            [PSET.foursphereParams['radii'][0] + PSET.layer_data['center'][3]],
            'k.',
            label='dipole site')

    ax.axis('equal')
    ax.set_ylim(top=max(PSET.foursphereParams['radii']) + 5000)

    ax.set_xticks(np.r_[-np.array(PSET.foursphereParams['radii']), 0,
                        PSET.foursphereParams['radii']])
    ax.set_xticklabels([])

    ax.legend(loc=(0.25, 0.05), frameon=False)
Exemple #13
0
def f(x, t):
    return t * x - t**2  # 関数fの定義

if 1:
    fig = plt.figure(1)
    ax = SubplotZero(fig, 111)
    fig.add_subplot(ax)

    ax.axhline(linewidth=1.7, color="black")
    ax.axvline(linewidth=1.7, color="black")

    plt.xticks([])
    plt.yticks([])
    plt.ylim([-20,40])

    ax.text(0, 1.05, '$y$', transform=BlendedGenericTransform(ax.transData, ax.transAxes), ha='center')
    ax.text(1.05, 0, '$x$', transform=BlendedGenericTransform(ax.transAxes, ax.transData), va='center')
    # 軸の書式設定(謎)

    for direction in ["xzero", "yzero"]:
        ax.axis[direction].set_axisline_style("-|>")
        ax.axis[direction].set_visible(True)

    for direction in ["left", "right", "bottom", "top"]:
        ax.axis[direction].set_visible(False)

    x = np.linspace(-10, 10, 200)
    for i in range(-5,6):  # グラフを書く作業を繰り返す範囲
        y = f(x, t=i)
        ax.plot(x, y, 'black', linewidth=2)
    plt.show()
Exemple #14
0
def main():
	opts, args = getopt.getopt(sys.argv[1:], 'u:', ['URL='])
	print("Number of arguments: " + str(len(sys.argv)))

	if len(sys.argv) > 1:
		threadID = str(sys.argv[1])
	else:
		threadID = '3jms68'

	print("Using thread: " + threadID)

	r = praw.Reddit(user_agent='test script /u/Speff')
	#r.set_oauth_app_info(client_id='aDjUAlJ0Cb17pA',
	#						client_secret='AeJjd7CLEUt7wyMmTVhP6kidhLc',
	#						redirect_uri='http://127.0.0.1:65010/'
	#						'authorize_callback')
	#url = r.get_authorize_url('uniqueKey', 'identity', True)
	#print(url)
	#access_information = r.get_access_information('lfJfhgKEDDUzgwY9a2tcVtVYMnc')
	#r.set_access_credentials(**access_information)
	#authenticated_user = r.get_me()
	#print(authenticated_user.name, authenticated_user.link_karma)

	start = float(time.time())
	submission = r.get_submission(submission_id=threadID, comment_sort="confidence")
	submission.replace_more_comments(limit=None, threshold=1)
	print("Seconds to process thread: " + str(time.time()-start))
	flat_comments = praw.helpers.flatten_tree(submission.comments)

	submission_score = submission.score
	submission_time = submission.created_utc

	comment_score = []
	comment_time = []
	commentInfo = []
	#comment_body = []

	print("Number of comments: " + str(len(flat_comments)))

	for x in flat_comments:
	#	print(x.body + "\n")
		comment_score.append(abs(x.score-1)+1)
		comment_time.append((x.created_utc - submission_time)/(60))
	#	comment_body.append(x.body)


	data = np.column_stack((comment_time, comment_score))

	uniques, count = np.unique(data[:,1], return_counts=True)
	unvoted = 0.0
	for x in range(0, len(uniques)):
		if(uniques[x]) == 1:
			unvoted = count[x]

	unvoted = unvoted / len(comment_time)

	if 1:
		fig = plt.figure(1)
		ax = SubplotZero(fig, 111)
		fig.add_subplot(ax)

		ax.axis["left"].set_label('Points')
		ax.axis["bottom"].set_label('Time (minutes)')

		xRange = np.amax(data[:,0]) - np.amin(data[:,0])
		yRange = np.amax(data[:,1]) - np.amin(data[:,1])

		plt.axhline(1, color='gray', linestyle='--')
		plt.axhline(0, color='black')
		plt.axvline(0, color='black')

		xFit = np.linspace(np.amin(data[:,0]) - xRange*0.1, np.amax(data[:,0]) + xRange*0.1, 1000)

		A, K, C = fit_exp_nonlinear(data[:,0], data[:,1])
		fit_y = 2*model_func(xFit, A, K, C)


		print("Best-fit polynomial coefficient(s): " + str((A, K, C)))

		ax.axis([np.amin(data[:,0]) - xRange*0.1, np.amax(data[:,0]) + xRange*0.1, np.amin(data[:,1]) - yRange*0.1, np.amax(data[:,1]) + yRange*0.1])
		ax.plot(data[:,0], data[:,1], '.')
		ax.plot(xFit, fit_y, '-', color='darkred')

		ax.text(0.75*xRange + np.amin(data[:,0]), 0.9*yRange + np.amin(data[:,1]), str(round(unvoted,3)*100) + '% unvoted \n', fontsize=15)

		plt.show()
Exemple #15
0
fig.add_subplot(ax)
for direction in ["xzero", "yzero"]:
    ax.axis[direction].set_visible(True)
    ax.axis[direction].set_axisline_style("->")
for direction in ["top", "bottom", "left", "right"]:
    ax.axis[direction].set_visible(False)
ax.axis["yzero"].set_axis_direction("left")
ax.grid(True)
ax.minorticks_on()

ax.contour(x,
           y,
           x**2 + 2. * x * y + y**2 - 8. * x, [0],
           linewidths=1.5,
           colors='r')
ax.text(1.75, -4.5, r'$x^2+2xy+y^2-8x=0$', color='r')
ax.arrow(.5, -1, 0, 5, color='orange', head_width=.1, head_length=.2)
ax.text(.75, 4, r'$\bar{y}$', color='orange')
ax.arrow(-2.5, 1.5, 5.5, 0, color='orange', head_width=.1, head_length=.2)
ax.text(3, 1, r'$\bar{x}$', color='orange')
ax.plot(.5, 1.5, 'ko')
ax.text(.25, 1.75, r'V')

ax.arrow(-4.5, -4.5, 9, 9, color='m', ls='dashed', lw=.5), ax.text(-4,
                                                                   -4,
                                                                   r'$x=y$',
                                                                   color='m')
ax.arrow(-5.5, -4.5, 9, 9, color='grey', ls='dashed',
         lw=.5), ax.text(-6, -3, r'$x=y-1$', color='grey')
ax.arrow(-2, -1, 5, 5, color='g', head_width=.2,
         head_length=.2), ax.text(2.9, 4.2, r'$y$', color='g')