Skip to content

Instantly share code, notes, and snippets.

@satomacoto
satomacoto / circle.py
Created March 13, 2012 07:09
matplotlib - circle
import matplotlib.pyplot as plt
circle1=plt.Circle((0,0),.2,color='r')
circle2=plt.Circle((.5,.5),.2,color='b')
circle3=plt.Circle((1,1),.2,color='g',clip_on=False)
fig = plt.gcf()
fig.gca().add_artist(circle1)
fig.gca().add_artist(circle2)
fig.gca().add_artist(circle3)
plt.show()
@satomacoto
satomacoto / arrow.py
Created March 13, 2012 07:07
matplotlib - arrow
import matplotlib.pyplot as plt
from matplotlib.patches import Arrow
plt.figure(1, figsize=(3,3))
ax = plt.gca()
ax.annotate("",
xy=(0.2, 0.2), xycoords='data',
xytext=(0.8, 0.8), textcoords='data',
arrowprops=dict(arrowstyle="->",
@satomacoto
satomacoto / label_propagation.py
Created July 4, 2012 06:24
label propagation
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from scipy.sparse import dok_matrix, dia_matrix, identity
from scipy.sparse.linalg import spsolve
# ネットワークの構造
# ノードiとノードjの間にリンクがあるときW[i,j]=1
W = dok_matrix((10,10))
W[0,2] = W[2,0] = 1
@satomacoto
satomacoto / AttachLabelsToPoints.bas
Created July 20, 2012 08:20
Excelの散布図にラベルをつける AttachLabelsToPoints
Sub AttachLabelsToPoints()
'Dimension variables.
Dim RCounter As Integer, CCounter As Integer, xVals As String
'Disable screen updating while the subroutine is run.
Application.ScreenUpdating = False
'Store the formula for the first series in "xVals".
xVals = ActiveChart.SeriesCollection(1).Formula
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Hello world!</title>
</head>
<body>
<h1>Hello world!</h1>
<p>hogehoge</p>
</body>
@satomacoto
satomacoto / nx_karate.py
Created September 6, 2012 06:03
NetworkX
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
# Zachary's Karate Club graph
G = nx.karate_club_graph()
@satomacoto
satomacoto / gist_import.html
Last active October 10, 2015 08:28
BloggerでGistのファイルをAPIで取得して表示させる
<h1 id="gist_120907_description" style="font-weight:300;">Loading...</h1>
<iframe id="gist_120907_hello_html" marginwidth="0" marginheight="0" scrolling="no" style="border:solid 1px #ccc; display:inline; margin:0px; position:static; width:400px; height:300px;"></iframe>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
var id = '3347397';
var filename = 'hello.html';
$.ajax({
type: 'GET',
@satomacoto
satomacoto / app.yaml
Created October 24, 2012 09:48
aozoramakura
application: aozoramakura
version: 1
runtime: python
api_version: 1
handlers:
- url: /post_update
script: app.py
login: admin
@satomacoto
satomacoto / ekf.py
Created November 3, 2012 16:01
ekf
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
import scipy as sp
from scipy.optimize.slsqp import approx_jacobian
import matplotlib.pyplot as plt
def main():
# 初期化
@satomacoto
satomacoto / pf.py
Created November 15, 2012 14:37
pf
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Particle Filter
"""
import numpy
def f(x, u):
"""Transition model