Skip to content

Latest commit

 

History

History
139 lines (115 loc) · 3.89 KB

File metadata and controls

139 lines (115 loc) · 3.89 KB

Interesting topic

插入 gnuplot 程序

  1. 配置好 gnuplot,可以正常使用 set terminal png 这条命令
  2. 需要加入下面的代码,使得可以运行 gnuplot
    ;; active Babel languages
    (org-babel-do-load-languages
    'org-babel-load-languages
    '((gnuplot . t)))
    ;; add additional languages with '((language . t)))
        
  3. 插入 gnuplot 函数代码
    reset
    set title "Putting it All Together"
    set xlabel "X"
    set xrange [-8:8]
    set xtics -8,2,8
    
    set ylabel "Y"
    set yrange [-20:70]
    set ytics -20,10,70
    
    f(x) = x**2
    g(x) = x**3
    h(x) = 10*sqrt(abs(x))
    
    plot f(x) w lp lw 1, g(x) w p lw 2, h(x) w l lw 3
        
  4. xy1y2
    0.10.4250.375
    0.20.31250.3375
    0.30.249999930.28333338
    0.40.2750.28125
    0.50.260.27
    0.60.258333380.24999993
    0.70.246428450.23928553
    0.80.231250.2375
    0.90.233333230.2333332
    10.22250.22
    set title "Putting it All Together"
    set xlabel "X"
    set xrange [0:1]
    set xtics 0,0.1,1
    
    set ylabel "Y"
    set yrange [0.2:0.5]
    set ytics 0.2,0.05,0.5
    
    
    plot data u 1:2 w p lw 2 title 'x vs. y1', \
    data u 1:3 w lp lw 1 title 'x vx. y2'
      

运行 python 程序

  1. :session [name] :default is no session
  2. :var data=data-table 可以从表中选择数据
  3. :exports {code,results,both,none} 选择以什么方式导出
  4. example
    a1
    b2
    c3
    # Return row specified by val.
    # In non-session mode, use return to return results.
    return(data[val])
        
    import matplotlib, numpy
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    fig=plt.figure(figsize=(4,2))
    x=numpy.linspace(-15,15)
    plt.plot(numpy.sin(x)/x)
    fig.tight_layout()
    plt.savefig('image/org/python-matplot-fig.png')
    return 'image/org/python-matplot-fig.png' # return filename to org-mode
        

easy templates

s	#+BEGIN_SRC ... #+END_SRC 
e	#+BEGIN_EXAMPLE ... #+END_EXAMPLE
q	#+BEGIN_QUOTE ... #+END_QUOTE 
v	#+BEGIN_VERSE ... #+END_VERSE 
c	#+BEGIN_CENTER ... #+END_CENTER 
l	#+BEGIN_LaTeX ... #+END_LaTeX 
L	#+LaTeX: 
h	#+BEGIN_HTML ... #+END_HTML 
H	#+HTML: 
a	#+BEGIN_ASCII ... #+END_ASCII 
A	#+ASCII: 
i	#+INDEX: line 
I	#+INCLUDE: line

setting picture size

  1. first need to disable below function # -*- org-image-actual-width: nil; -*-
  2. above the picture add below #+ATTR_foo: :width 500px

Keybindings

keydescription
C-c C-x C-vdisplay inline picture
C-c C-lInsert link
C-c C-x C-ldisplay Latex equation

Bugs

  1. 加入 org-babel-load-languages 依然出现错误,无法编译程序
    • 此时需要删除 org modeelc 文件
    • cd /Users/haomiao/.emacs.d/elpa/org-20170210
    • rm *.elc
    • C-u 0 M-x byte-recompile-directory