下面的代码示例运行时没有错误,但屏幕上没有显示任何内容。
下面是我试图使用的代码示例..。
import SchemDraw
import SchemDraw.elements as elm
d = SchemDraw.Drawing()
R1 = d.add(elm.Resistor(label='1K$\Omega$'))
d.labelI(R1, '1 mA', top=False)
d.add(elm.Capacitor(d='down', botlabel='0.1$\mu$F'))
d.add(elm.Line( d='Left'))
d.add(elm.Ground)
d.add(elm.SourceV( d='up', label='10V') )
d.save('schematic.svg')
d.draw()我在Windows 7平台上,将Python3.7集成到我的命令提示符中。如果我导航到schematic.py文件所在的目录,并将其添加到控制台中:
Python schematic.py它运行良好,退出时有0错误,但是没有绘制到屏幕上,Matplotlib甚至没有被调用.
在搜索了一些文档、简要教程或非常有限的示例之后,我意识到上面的示例以及其他示例依赖于带有Matplotlib内联的木星笔记本.
我怎么能不直接使用朱庇特笔记本和内联材料库来画这个呢?
我想把它作为一个基本的Python脚本运行,我知道我可以像这样手动导入Matplotlib模块.
import Matplotlib.pyplot as plt
//... prev code
d.draw() // doesn't draw anything to the screen or to matplotlib's backend...
// plt.plot(...)? What goes here?
plt.show()但我不知道如何使用它来绘制SchemDraw的绘图方法的结果.
发布于 2020-06-27 21:00:37
丢失Matplotlib交互窗口是SchemDraw 0.7中引入的一个回归错误。它被修正在0.7.1,今天推到PyPi。在此版本中,如果以脚本的形式运行,d.draw()将打开Matplotlib窗口,如果以木星内联模式运行,则显示单元格中的输出。
https://stackoverflow.com/questions/62507312
复制相似问题