1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

マジックファンクション(ラインマジック)のドキュメントに当たる方法

Posted at

結論

  • 行頭 % はマジックファンクション(ipython の機能)
  • 調べ方は、ipython のインタラクティブモードで %magic
    • %matplotlib を調べるなら、%matplotlib?

だらだらと、流れを

ご多分に漏れず、jupyter で勉強してる訳だが、しょっぱなから

jupyter
In1: %matplotlib inline
In2: import matplotlib.pyplot as plt

行頭の % はなに?

意味わかんない。とりあえず、RYFM 実践。

$ pydoc matplotlib
(略)
    or using ipython::
    
        ipython
    
    at your terminal, followed by::
    
        In [1]: %matplotlib
        In [2]: import matplotlib.pyplot as plt
    
    at the ipython shell prompt.
  (略)

さらっと % を出されても、、、Python 本体の方の機能かと思っちゃったじゃんか。

ググった結果。

%quickref

コマンドラインで、ipython して、%quickref する。

$ ipython
In [1]: %quickref
(略)
%magic           : Information about IPython's 'magic' % functions.
(略)

そしたら magic の説明は、%magic だよと。

%magic

In [2]: %magic
IPython's 'magic' functions
===========================

The magic function system provides a series of functions which allow you to
control the behavior of IPython itself, plus a lot of system-type
features. There are two kinds of magics, line-oriented and cell-oriented.
(略)

で、matplotlib を検索すりゃ、説明がわらわらと出てくる。

それとは別に、

For a list of the available magic functions, use %lsmagic. For a description
of any of them, type %magic_name?, e.g. '%cd?'.

だそうだから、

%matplotlib?

$ ipython
In [1]: %matplotlib?

する。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?