Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #+BEGIN_SRC ipython :session :file plot2.png :exports both
- import matplotlib.pyplot as plt
- import numpy as np
- L = 6
- x = np.linspace(0, L)
- ncolors = len(plt.rcParams['axes.color_cycle'])
- shift = np.linspace(0, L, ncolors, endpoint=False)
- for s in shift:
- plt.plot(x, np.sin(x + s), 'o-')
- plt.xlabel('x-axis')
- plt.ylabel('y-axis')
- plt.title('title')
- plt.show()
- #+END_SRC
- #+RESULTS:
- [[file:plot2.png]]
- #+BEGIN_SRC ipython :session :file plot3.png :exports both
- from mpl_toolkits.mplot3d import axes3d
- import matplotlib.pyplot as plt
- from matplotlib import cm
- fig = plt.figure()
- ax = fig.gca(projection='3d')
- X, Y, Z = axes3d.get_test_data(0.05)
- ax.plot_surface(X, Y, Z, rstride=8, cstride=8, alpha=0.3)
- cset = ax.contourf(X, Y, Z, zdir='z', offset=-100, cmap=cm.coolwarm)
- cset = ax.contourf(X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm)
- cset = ax.contourf(X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm)
- ax.set_xlabel('X')
- ax.set_xlim(-40, 40)
- ax.set_ylabel('Y')
- ax.set_ylim(-40, 40)
- ax.set_zlabel('Z')
- ax.set_zlim(-100, 100)
- plt.show()
- #+END_SRC
- #+RESULTS:
- [[file:plot3.png]]
- #+TBLNAME: data_table
- |------------------+----+---+----|
- | date | x | y | z |
- |------------------+----+---+----|
- | <2016-06-15 Wed> | 1 | 1 | 1 |
- | <2016-06-16 Thu> | 2 | 2 | 2 |
- | <2016-06-17 Fri> | 4 | 3 | 3 |
- | <2016-06-18 Sat> | 8 | 4 | 4 |
- | <2016-06-19 Sun> | 16 | 5 | 30 |
- | <2016-06-20 Mon> | 32 | 6 | 40 |
- |------------------+----+---+----|
- #+BEGIN_SRC ipython :session :file plot.png :exports both :var table=data_table
- import matplotlib.pyplot as plt
- import numpy as np
- import pandas as pd
- %matplotlib inline
- df = pd.DataFrame(table[1:], columns=table[0])
- df.plot()
- #+END_SRC
- #+RESULTS:
- [[file:plot.png]]
- #+BEGIN_SRC ipython :session :exports both
- def foo(x):
- return x + 9
- [foo(x) + 7 for x in range(7)]
- #+END_SRC
- #+RESULTS:
- | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
- #+BEGIN_SRC python
- def foo(x):
- return x + 9
- [foo(x) + 7 for x in range(7)]
- #+END_SRC
- #+RESULTS:
- : None
- #+BEGIN_SRC latex
- \LaTeX
- #+END_SRC
- #+RESULTS:
- #+BEGIN_LaTeX
- \LaTeX
- #+END_LaTeX
- #+name: test_plot_png
- #+header: :exports results :file test.png
- #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 400
- #+header: :fit yes :noweb yes :headers '("\\usepackage{tikz}")
- #+begin_src latex :exports results :file test.png
- library("tikzDevice")
- tikz(console=TRUE, width=4, height=4)
- plot(rnorm(100), rnorm(100))
- dummy <- dev.off()
- #+end_src
- #+RESULTS: test_plot_png
- #+BEGIN_LaTeX
- [[file:test.png]]
- #+END_LaTeX
- #+begin_src latex
- \LaTeX
- #+end_src
- #+RESULTS:
- #+BEGIN_LaTeX
- \LaTeX
- #+END_LaTeX
- #+begin_src latex :file latex-logo.pdf :imagemagick :packages '(("" "tikz")) :border 1em
- % Define block styles
- \usetikzlibrary{shapes,arrows}
- \tikzstyle{astate} = [circle, draw, text centered, font=\footnotesize, fill=blue!25]
- \tikzstyle{rstate} = [circle, draw, text centered, font=\footnotesize, fill=red!25]
- \begin{tikzpicture}[->,>=stealth', shorten >=1pt, auto, node distance=2.8cm, semithick]
- \node [astate] (1) at (0,0) {1};
- \node [astate] (2) at (1,0) {2};
- \node [rstate] (3) at (2,0) {3};
- \path (1) edge [bend left] node {b} (2)
- (2) edge node {b} (3)
- (2) edge [bend left] node {a} (1)
- (3) edge [loop above] node {(a, b)} (3);
- \end{tikzpicture}
- #+end_src
- #+RESULTS:
- #+BEGIN_LaTeX
- [[file:latex-logo.pdf]]
- #+END_LaTeX
- #+name: test_plot_png
- #+header: :exports both :file test.png
- #+header: :imagemagick yes :iminoptions -density 600 :imoutoptions -geometry 400
- #+header: :fit yes :noweb yes :headers '("\\usepackage{tikz}")
- #+begin_src latex
- % Define block styles
- \usetikzlibrary{shapes,arrows}
- \tikzstyle{astate} = [circle, draw, text centered, font=\footnotesize, fill=blue!25]
- \tikzstyle{rstate} = [circle, draw, text centered, font=\footnotesize, fill=red!25]
- \begin{tikzpicture}[->,>=stealth', shorten >=1pt, auto, node distance=2.8cm, semithick]
- \node [astate] (1) at (0,0) {1};
- \node [astate] (2) at (1,0) {2};
- \node [rstate] (3) at (2,0) {3};
- \path (1) edge [bend left] node {b} (2)
- (2) edge node {b} (3)
- (2) edge [bend left] node {a} (1)
- (3) edge [loop above] node {(a, b)} (3);
- \end{tikzpicture}
- #+end_src
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement