已迁移至Github Pages,此处不再更新。
Mashiro
Last updated in 2017.6.3.
期末写货币银行学的论文,要研究利率对房价的影响,需要作一堆图来对比国内外情况,选择了用R绘图(Excel明明半分钟就可以了,我用R写了一个小时TAT)。效果如下:
代码如下:
FUN <- function(){
# 绘制房屋价格指数
plot(x = JP$Year, y = JP$Price,
xlim = c(1970, 2015), ylim = c(20, 120),
pch=16, axes=FALSE, xlab="", ylab="", col="blue", type="b",
main = "House Price Index & Interest Rate in Japan from 1970 to 2015")
# 左侧坐标轴
axis(2, ylim = c(20, 120), col="black", las=1)
# 图示标签
text(1975, 28, labels = "House Price Index", col = "blue")
# 左侧坐标轴标签,注意line参数调整位置
mtext("House Price Index (2010=100)", side=2, line=2.5)
# 允许在同一张图上画第二条折现
par(new=TRUE)
plot(x = JP$Year, y = JP$Interest,
xlim = c(1970, 2015), ylim = c(0, 10),
pch=16, axes=FALSE, xlab="", ylab="", col="red", type="b",
main = "House Price Index & Interest Rate in Japan from 1970 to 2015")
axis(4, at = c(0, 2, 4, 6, 8, 10), col="black", las=1)
mtext("Interest Rate %)", side=4, line=1.3)
text(1974, 7, labels = "Interest Rate", col = "red")
# x轴标签
axis(1, at = c(1970, 1975, 1980, 1985, 1990, 1995, 2000, 2005, 2010, 2015), col="black", las=2)
}
# 储存为svg(我这么认真画的图,导出为png品质那么低,强迫症不满意:P )
svg(filename="test.svg",
width=12,
height=8,
pointsize=12)
FUN()
dev.off()
哇塞,在markdown里面插入一段svg代码真是可怕。。🌸
#定义全局变量:global
x = 50
def func():
global x
print('x is', x)
x = 2
print('Changed global x to', x)
func()
print('Value of x is', x)
#可变参数 *不太明白,等后续填坑
def total(a=5, *numbers, **phonebook):
print('a', a)
#遍历元组中的所有项目
for single_item in numbers:
print('single_item', single_item)
#遍历字典中的所有项目
for first_part, second_part in phonebook.items():
print(first_part,second_part)
print(total(10,1,2,3,Jack=1123,John=2231,Inge=1560))
#return
def maximum(x, y):
if x > y:
return x
elif x == y:
return 'The numbers are equal'
else:
return y
print(maximum(2, 3))
#只消记住Python将所有东西都视为一个对象,这其中自然包括函数。
#对于如何解释函数如以上的maximum(2,3)以何种形式储存(如作为一个变量?)的问题,
#我想关键在于对上句话的“对象”的理解
#若未指定,则默认返回return None
#若不需要返回值则使用pass
def some_function():
pass
2017/5/10
#if函数的原理
if True:
print('Yes, it is true')
#for循环
for i in range(1, 5):
print(i)
else:
print('The for loop is over')
#疑问:如何直接打印出range?
#continue语句用以告诉Python跳过当前循环块中的剩余语句,并继续该循环的下一次迭代
while True:
s = input('Enter something : ')
if s == 'quit':
break
if len(s) < 3:
print('Too small')
#continue
print('Input is of sufficient length') #这是“剩余语句”
# 自此处起继续进行其它任何处理
2017/5/10
Github pages的静态网站一直没建好,所以临时记在这里,待以后搬运
print('this is the first line. this is the second line.', end=' ')
print("this is the third line.")
#只有三点中可以使用回车。
print('''this is a paragraph
of two lines.''')
#双引号
print("this first\
tis is second")
#单引号无法使用
#print(’this first\
#tis is second’)
#对于在format中定义变量的语句,{}中必须输入对应变量名
##print("{0} is {1} years old" .format(name="Mashiro", age=21)) 报错
##print("{} is {} years old" .format(name="Mashiro", age=21)) 报错
print("{name} is {age} years old" .format(name="Mashiro", age=21))
#一种与上一步等效的方法,不过不推荐
#在此,前一步中定义的变量无效
name='Mashiro'
age=21
print(name + ' is ' + str(age) +'years old')
# 对于浮点数 '0.333' 保留小数点(.)后三位
print('{0:.3f}'.format(1.0/3))
# 使用下划线填充文本,并保持文字处于中间位置
# 使用 (^) 定义 '___hello___'字符串长度为 11
# _可替换为任意单字符
print('{0:_^11}'.format('hello'))
# 基于关键词输出 'Swaroop wrote A Byte of Python'
print('{name} wrote {book}'.format(name='Swaroop', book='A Byte of Python'))
#print函数默认句尾有一个回车,想要避免得使用end函数
print('a', end=' ')
print('b', end=' ')
print('c')
#比较
print('a', end='')
print('b', end='')
print('c')
# 关于原始字符串
path = 'c:\noway'
print (path)
#比较,可以理解“原始”的意思
path = r'c:\noway'
print (path)
#其实所谓原始字符串,都是给人看的。对于计算机来说,没有什么原始字符串的概念。
#只是输出给人看的时候,会遇到一些\n、\t等的问题,让人看起来不好看而已。
2017/5/7

<
p style=”float:left;”>在根本处,也正是在那最深奥、最重要的问题上,我们是无名的孤单。
——里尔克
<
p style=”float:left;”>
我们读书而后知道自己并不孤单。我们读书,因为我们孤单;我们读书,然后就不孤单。
——《岛上书店》
回想起来,这些年,虽日读书,然多为教科书。也不是说不好吧,只是有时看着书架上一时兴起买的小说竟还未翻开,万分惭愧。
樱花,只为你。
那轻,那娉婷,你是,鲜妍
百花的冠冕你戴着,你是
天真,庄严,你是夜夜的月圆。
你是一树一树的花开,是燕
在梁间呢喃,——你是爱,是暖,
是希望,你是人间的四月天!
仍未说出那句话,
伴着樱花,希望
在这个四月,成为永远!
做了一点微小的研究…
最近学Corporate Finance,认识了一些财务指标,于是到SEC.gov找了几份上市公司报表研究。平时用的最多的是网易(NTES)和Google(Alphabet)的产品,所以找了这两家公司的报表。发现有趣的是,网易和Alphabet的报表类型有很大差别。
凝视天空,一瞬间无比开阔而畅快~