Jupyter Notebook使用小技巧

简介: 在 C:\Windows\Fonts目录下找到Mircosoft YaHei UI字体,然后复制到[你的Python安装路径]/Lib/site-packages/matplotlib/mpl-data/fonts/ttf目录下即可解决Matplotlib中文乱码的问题。
  1. C:\Windows\Fonts目录下找到Mircosoft YaHei UI字体,然后复制到[你的Python安装路径]/Lib/site-packages/matplotlib/mpl-data/fonts/ttf目录下即可解决Matplotlib中文乱码的问题。
  2. Jupyter Notebook的27个秘诀,技巧和快捷键
  3. jupyter notebook 嵌入到博客
    在博客(MarkDown模式)里嵌入如下代码:

    [code]
    <iframe src="https://nbviewer.jupyter.org/github/Papers-Collection/Xinet-Collection/blob/master/LaTeX%20从零开始快速入门.ipynb" width="850" height="500"></iframe>

src 里面写入自己想引用的源链接,但必须基于 nbviewer.jupyter.org;你可以打开http://nbviewer.jupyter.org 查看相关的使用方法;这里
[code]

1 字体、颜色、字号

MarkDown全篇是统一使用黑色微软雅黑字体,字号默认为3,而HTML却可以像Word那样灵活,引入大量字体包、颜色和字号,例如在MarkDown:

Hello world
- <font face="黑体"> 黑体: Hello world </font>
- <font face="STCAIYUN"> STCAIYUN: hello world </font>
- <font face="Terminal"> Terminal: Hello world </font>
- <font face="Consolas"> Consolas: Hello world </font>
- <font face="Consolas" size=3 color=#DC143C> Consolas,2,#DC143C: Hello world </font>
- <font face="Consolas" size=4 color=(220, 20, 60)> Consolas,2,(220, 20, 60): Hello world </font>
- <font face="Consolas" size=5 color=Crimson> Consolas,2,Crimson: Hello world </font>
- <font face="Consolas" size=7 color=#0099ff> Consolas,2,Crimson: Hello world </font>

展示如下:

Hello world

  • 黑体: Hello world
  • STCAIYUN: hello world
  • Terminal: Hello world
  • Consolas: Hello world
  • Consolas,2,#DC143C: Hello world
  • Consolas,2,(220, 20, 60): Hello world
  • Consolas,2,Crimson: Hello world
  • Consolas,2,Crimson: Hello world

font主要包含三个参数:字体(face),字号(size)和颜色(color),顺序可调,也可缺省。

  • size的可选范围为 1-7,小于 \(1\) 的数值等价于 \(1\),超过\(7\)的数值等价于\(7\));
  • color的赋值既可以使用颜色名,例如BlueBlackCrimson等,也可以使用十六进制的颜色值 #0000FF#000000#DC143C 等,如果想了解更多,可以阅读博客:CSDN-markdown编辑器语法——字体、字号与颜色

2 数学字符及公式

再来看数学字符及公式,MarkDown 中使用标识符 $$$$$$ 即可表示引入 LaTeX 语法,前者使用时不换行,即在所使用位置使用 LaTeX 的格式,后者会换行后居中,例如:

$$
f(x;\mu,\sigma^2) = \frac{1}{\sigma\sqrt{2\pi}} e^{ -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2 } \tag{1}
$$

where $\mu$ is the mean value, $\sigma^2$ is standard deviation.

展示如下:

\[ f(x;\mu,\sigma^2) = \frac{1}{\sigma\sqrt{2\pi}} e^{ -\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2 } \tag{1} \]

where \(\mu\) is the mean value, \(\sigma^2\) is standard deviation.

一些基本的LaTeX公式命令可参考:Markdown公式(二)

下面说下矩阵和表达式:

$$ 
\left[ \begin{matrix}
    b_{1}&c_{1}& & & &0 \\
    a_{2}&b_{2}&c_{2}& & & \\ 
     &a_{3}&b_{3}&\ddots& &  \\
     & &\ddots&\ddots&c_{n-1} & \\
    0& & & &a_{n}&b_{n}
\end{matrix}\right] 
\left[ \begin{matrix}
    x_{1} \\
    x_{2} \\ 
    x_{3} \\
    \vdots\\
    x_{n}
\end{matrix}\right]  = 
\left[ \begin{matrix}
    d_{1} \\
    d_{2} \\ 
    d_{3} \\
    \vdots\\
    d_{n}
\end{matrix}\right]
\tag{2}
$$

$$ c'_i =
\begin{cases} 
\begin{array}{lcl}
  \cfrac{c_i}{b_i}                   & & ; i = 1 \\
  \cfrac{c_i}{b_i - a_i c'_{i - 1}}  & & ; i = 2, 3, \dots, n-1 \\
\end{array}
\end{cases}
\tag{3}$$
$$

展示如下

\[ \left[ \begin{matrix} b_{1}&c_{1}& & & &0 \\ a_{2}&b_{2}&c_{2}& & & \\ &a_{3}&b_{3}&\ddots& & \\ & &\ddots&\ddots&c_{n-1} & \\ 0& & & &a_{n}&b_{n} \end{matrix}\right] \left[ \begin{matrix} x_{1} \\ x_{2} \\ x_{3} \\ \vdots\\ x_{n} \end{matrix}\right] = \left[ \begin{matrix} d_{1} \\ d_{2} \\ d_{3} \\ \vdots\\ d_{n} \end{matrix}\right] \tag{2} \]

\[ c'_i = \begin{cases} \begin{array}{lcl} \cfrac{c_i}{b_i} & & ; i = 1 \\ \cfrac{c_i}{b_i - a_i c'_{i - 1}} & & ; i = 2, 3, \dots, n-1 \\ \end{array} \end{cases} \tag{3} \]

3 图片排版

以网络上的一段图文为例:

<DIV ALIGN="CENTER">
<TABLE><CAPTION ALIGN="BOTTOM"><STRONG>Fig 1:</STRONG> Rigidly terminated string with the simplest frequency-dependent loss filter.  All loss factors (possibly including losses due to yielding terminations) have been consolidated at a single point and replaced by a one-zero filter approximation.</CAPTION>
![KarplusStrong](http://img.blog.csdn.net/20150925112421105)
</TABLE>
</DIV>

imshow:

![KarplusStrong](http://img.blog.csdn.net/20150925112421105) Fig 1: Rigidly terminated string with the simplest frequency-dependent loss filter. All loss factors (possibly including losses due to yielding terminations) have been consolidated at a single point and replaced by a one-zero filter approximation.

当然也可以简化只使用 <center>

<center>
![Panda](http://img.blog.csdn.net/20151109165400641)
Panda
</center>
![Panda](http://img.blog.csdn.net/20151109165400641)Panda

MarkDown 图片大小问题

引用自:文章链接: http://blog.csdn.net/yhl_leo/article/details/50099843

MarkDown里显示图片的方式可以引入 HTML 方法:

\(512 \times 512\) 的 lena 图像为例:

直接以MarkDown插入图片的方法,图片就会靠在左侧,大小也不由自己决定:

![lena](https://yqfile.alicdn.com/img_163cb7885672079cb727aad8617c4369.jpeg)

lena

固定图片显示大小:

<img src="https://yqfile.alicdn.com/img_163cb7885672079cb727aad8617c4369.jpeg" width=256 height=256 />

img_163cb7885672079cb727aad8617c4369.jpe

  • 其中 src 后面接的就是图像对象,widthheight 设置的是显示图像的尺寸。

根据一定比例显示:

<img src="https://yqfile.alicdn.com/img_163cb7885672079cb727aad8617c4369.jpeg" width="50%" height="50%" />

img_163cb7885672079cb727aad8617c4369.jpe

如果想给图像加个标注

可以这么做:

<center>
<img src="https://yqfile.alicdn.com/img_163cb7885672079cb727aad8617c4369.jpeg" width="25%" height="25%" />
Figure 1. Lena
</center>
img_163cb7885672079cb727aad8617c4369.jpeFigure 1. Lena

如果想让图和标注间距离增大,可以这么做:

注意<center>...</center> 表示居中

<center>
<img src="https://yqfile.alicdn.com/img_163cb7885672079cb727aad8617c4369.jpeg" width="25%" height="25%" />
$ $
Figure 1. Lena
</center>
img_163cb7885672079cb727aad8617c4369.jpe$ $$ $Figure 1. Lena

图片的对齐方式

使用 html 中的 div 标签,它有个对齐属性 align,可以指定为 leftcenterright 以实现左对齐居中对齐右对齐。不过经我实验,这种方式 div 标签之间不能放 Markdown 图片链接语法,而只能是 html 的语法格式,因此还要配合 <img> 标签使用。

<div align="center">
<img src="http://imgtech.gmw.cn/attachement/jpg/site2/20111223/f04da22d7ba7105e1d7507.jpg"  alt="CSDN图标" />
 </div>
Graph

更多参考Markdown 简明语法参考

至于更复杂的操作,可以查阅更多资料。对于使用一些网页上不错的用法时,建议可以通过查看网页源码,找到对应的HTML源码,稍作调整即可应用到文档写作中:

探寻有趣之事!
目录
相关文章
|
4月前
|
机器学习/深度学习 人工智能 数据挖掘
【Python数据挖掘】数据挖掘简介及Jupyter notebook操作介绍(图文解释 超详细)
【Python数据挖掘】数据挖掘简介及Jupyter notebook操作介绍(图文解释 超详细)
71 0
|
16天前
|
机器学习/深度学习 数据可视化 数据挖掘
Jupyter Notebook交互式开源笔记本工具
Jupyter Notebook交互式开源笔记本工具
|
4月前
|
机器学习/深度学习 安全 数据安全/隐私保护
Jupyter Notebook本地部署并实现公网远程访问内网Jupyter服务器【内网穿透】
Jupyter Notebook本地部署并实现公网远程访问内网Jupyter服务器【内网穿透】
|
1月前
|
IDE 数据可视化 数据挖掘
Jupyter Notebook使用教程——从Anaconda环境构建到Markdown、LaTex语法介绍
Jupyter Notebook使用教程——从Anaconda环境构建到Markdown、LaTex语法介绍
61 2
|
2月前
|
数据可视化 安全 数据挖掘
技术小白如何轻松安装Jupyter Notebook
技术小白如何轻松安装Jupyter Notebook
|
3月前
|
JSON 数据可视化 数据格式
Python小姿势 - Python使用Jupyter Notebook
Python小姿势 - Python使用Jupyter Notebook
|
3月前
|
数据可视化 Python
Python 的科学计算和数据分析: 解释什么是 Jupyter Notebook?
Python 的科学计算和数据分析: 解释什么是 Jupyter Notebook?
|
3月前
|
机器学习/深度学习 人工智能 数据可视化
Jupyter Notebook的10个常用扩展介绍
Jupyter Notebook(前身为IPython Notebook)是一种开源的交互式计算和数据可视化的工具,广泛用于数据科学、机器学习、科学研究和教育等领域。它提供了一个基于Web的界面,允许用户创建和共享文档,这些文档包含实时代码、方程、可视化和文本。
99 6
|
4月前
|
机器学习/深度学习 大数据 程序员
[机器学习]Jupyter Notebook 安装使用(二)
[机器学习]Jupyter Notebook 安装使用(二)
44 0
|
4月前
|
存储 数据可视化 Shell
18 个 Jupyter Notebook 小技巧,帮助你快速腾飞
18 个 Jupyter Notebook 小技巧,帮助你快速腾飞