一个简单的pycharm使用问题 大家帮帮忙呀

img

img

img


报错如图,我想复现这段代码,需要用到plotting
但我下载好plotting以后,仍有报错,提示plotting里面没有'newfig'等
然后 这段代码的作者是单独建立了一个,plotting.py在里面定义了newfig
所以我现在应该怎样才能运行代码呢 希望大家指教

参考如下实例:

# 需要导入模块: from matplotlib import pyplot [as 别名]
# 或者: from matplotlib.pyplot import setp [as 别名]
def plotTimeShareChart(self, code, date, n):
        date = self._daysEngine.codeTDayOffset(code, date, n)
        if date is None: return
        DyMatplotlib.newFig()
        # plot stock time share chart
        self._plotTimeShareChart(code, date, left=0.05, right=0.95, top=0.95, bottom=0.05)
        # plot index time share chart
        #self._plotTimeShareChart(self._daysEngine.getIndex(code), date, left=0.05, right=0.95, top=0.45, bottom=0.05)
        # layout
        f = plt.gcf()
        plt.setp([a.get_xticklabels() for a in f.axes[::2]], visible=False)
        f.show() 

修改你这个.py文件名重新运行一下!

img


改一下这个路径就可以了,应该是你的目录和他的一样。

文件名不要取plotting

1、你的文件名和库函数名重复了,建议改文件名
2、路径你可以用绝对路径(针对本机)
3、逻辑运算符比较建议用crop is True (==运行不会报错,但pycharm会提示错误)

你的py文件名称和你要导入的模块名称产生重复了,
引入时导致pycharm 读取错误,你可以先将你的py文件改个名字,重新运行哈

img

修改文件名,不要与plotting库重名

你自己的文件不要起名叫plotting.py,换一个自己的名字,比如myplot之类的,和库文件区分开