python
利用matplotlib绘制一幅具有两个子图的图片# 第一个子图为半径为5的圆形,第2个子图为一个边长为10的等边3角形怎么用matplotlib绘制图形啊刚学老师让我们自己研究怎么做都做不出来,呜呜, 本帖最后由 suchocolate 于 2021-11-1 21:07 编辑
#import numpy as np# 这行删除吧,没有用上。
import matplotlib.pyplot as plt
import matplotlib.patches as pat
fig, axs = plt.subplots(1, 2, sharex=False, sharey=False)
cic = pat.Circle((0, 0), 5, fill=False, color='b')# 圆心坐标0,0,半径5
axs.add_patch(cic)
axs.set_xlim(-5.5, 5.5)
axs.set_ylim(-5.5, 5.5)
xy = [, , [-5, - pow(75, 0.5)]]# 三角形的三个顶点的坐标
tra = pat.Polygon(xy, True, fill=False, color='g')
axs.add_patch(tra)
axs.set_xlim(-5.5, 5.5)
axs.set_ylim(-10, 5.5)
plt.show()
suchocolate 发表于 2021-11-1 19:35
我用pycham运行不了 你库装好了吗,如果import部分报错就是没装库,还有楼上的答主第一行代码可以删了,没用 金倩倩的美梦 发表于 2021-11-1 20:01
我用pycham运行不了
报的错贴出来。 抱错信息
C:\ProgramData\Anaconda3\python.exe C:/新建文件夹/Lib/site-packages/pip/_vendor/webencodings/20陆美萍.py
C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py:138: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 22, in <module>
from . import multiarray
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\multiarray.py", line 12, in <module>
from . import overrides
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
ImportError: DLL load failed while importing _multiarray_umath: 找不到指定的模块。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/新建文件夹/Lib/site-packages/pip/_vendor/webencodings/20陆美萍.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py", line 107, in <module>
from . import cbook, rcsetup
File "C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\cbook\__init__.py", line 28, in <module>
import numpy as np
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import core
File "C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\__init__.py", line 48, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://n $a2@y2@2416id@ssbya@@ndmeomeceritos@lpb2@ya@@4262d1si8@79612027t7$ 金倩倩的美梦 发表于 2021-11-2 07:57
$a2@y2@2416id@ssbya@@ndmeomeceritos@lpb2@ya@@4262d1si8@79612027t7$
这是啥 别急,很ez Python初学者8号 发表于 2021-11-2 09:13
别急,很ez
还有别的方法吗{:10_266:} suchocolate 发表于 2021-11-2 08:42
这是啥
复制错了 我运行不了
页:
[1]