这段代码
from sympy import *
x=Symbol('x')
p1 = plot(x**2,(x,-2,2))
p2 = plot(x**3,(x,-2,2))
Run Code Online (Sandbox Code Playgroud)
得到两个单独的图.
我想用matplotlib作为子图显示它们,而不是两个单独的图:
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(121)
ax2 = fig.add_subplot(122)
plt.show()
Run Code Online (Sandbox Code Playgroud)
我如何添加p1和p2,以便它们在matplotlib图中显示为子图?
在 macOS Mojave 10.14.6 (18G7016) 上,gcc无法_ctermid.h再找到该文件
In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/wchar.h:90,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/cwchar:44,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/bits/postypes.h:40,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/bits/char_traits.h:40,
from /usr/local/Cellar/gcc/10.2.0_2/include/c++/10.2.0/string:40,
from /Users/Projects/test.h:10,
from /Users/Projects/test.cpp:1:
/usr/local/Cellar/gcc/10.2.0_2/lib/gcc/10/gcc/x86_64-apple-darwin18/10.2.0/include-fixed/stdio.h:219:10: fatal error: _ctermid.h: No such file or directory
219 | #include <_ctermid.h>
Run Code Online (Sandbox Code Playgroud)
这可能是由 macOS 软件更新或brew upgrade.
这可能与一个较旧的问题Can'tcompileCprogramonaMacafterupgradetoMojave相关。
我尝试了建议的解决方案:
CommandLineTools文件夹(sudo) rm -rf /Library/Developer/CommandLineTools并重新安装xcode-select --installmacOS_SDK_headers_for_macOS_10.14了open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkgbrew和gcc(也gcc@9和gcc@8)他们都没有工作。