JupyterLab 自分用メモ


Jupyter Notebookの先頭

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import japanize_matplotlib
import scipy.stats as st

def plt_legend_out(frameon=True):
    plt.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0, frameon=frameon)
plt.rcParams['font.size'] = 15
from IPython.display import HTML

HTML('''
<script>  
code_show=true; 
function code_toggle() {
  if (code_show){
    $(\'div.input\').hide();
  } else {
    $(\'div.input\').show();
  }
  code_show = !code_show
}  
$( document ).ready(code_toggle);
</script>
<form action="javascript:code_toggle()">
    <input type="submit" value="Toggle code">
</form>
''')

マル秘マーク

<font size="5"><div align="right"><span style="border: 1px solid red; color: red">秘</span></div></font>

LaTeX

$
f(x)=
\left(
\begin{array}{ccc}
  f_1(x) \\
  f_2(x)
\end{array}
\right)=
\left(
\begin{array}{ccc}
  x^3-2y \\
  x^2+y^2-1
\end{array}
\right)=
\left(
\begin{array}{ccc}
  0 \\
  0
\end{array}
\right)
$

Python 自作関数

有効桁数を3桁に

def sig_dig(x):
    return np.float('%s' % np.float('%.3g' % x))

ggplot

文字の大きさのデフォルト値

theme_set(theme_bw(base_size = 20))

グラフの大きさ

options(repr.plot.width=7, repr.plot.height=4)