0
1

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 3 years have passed since last update.

sympyでグラフを重ねる

Last updated at Posted at 2020-02-09

sympyでグラフを重ねる

sympyで数式をプロットするとき、重ねて表示する方法

import sympy as sym
sym.init_printing()

その1

sym.var("x")
expr = 1/(1+ sym.exp(-x))

ax1 = sym.plot(expr, line_color="blue", show=False)
ax2 = sym.plot(expr.diff(x), line_color="red", show=False)
ax1.extend(ax2)
ax1.show()

download.png

その2

sym.var("x")
expr = 1/(1+ sym.exp(-x))

ax1 = sym.plot(expr, expr.diff(x), legend=True, show=False)
ax1[1].line_color="red"
ax1.show()

legend=Trueで凡例が表示される。

download.png

0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?