Matplotlib created a temporary config/cache directory at C:\Users\Elegent\AppData\Local\Temp\matplotlib-pyrb807h because the default path (C:\Users\Elegent\.matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing. Traceback (most recent call last): File "D:\pythonProject\AppleStock\ananly2.py", line 24, in <module> candlestick_ochl(ax, df[["Open", "Close", "Volume", "High", "Low"]].values, width=0.5, colorup="green", colordown="red") File "D:\pythonProject\venv\lib\site-packages\mplfinance\original_flavor.py", line 195, in candlestick_ochl return _candlestick(ax, quotes, width=width, colorup=colorup, File "D:\pythonProject\venv\lib\site-packages\mplfinance\original_flavor.py", line 286, in _candlestick if close >= open: TypeError: '>=' not supported between instances of 'int' and 'str'
时间: 2023-07-03 22:28:15 浏览: 618
CMOcean 颜色图:来自 https://matplotlib.org/cmocean/ 的颜色图集合-matlab开发
这个错误可能是由于您的数据类型不匹配所导致的。您可以尝试将 Close、Open、High 和 Low 这些列的数据类型转换为 float 或者 int 类型。您可以使用以下代码进行转换:
```python
df['Close'] = df['Close'].astype(float)
df['Open'] = df['Open'].astype(float)
df['High'] = df['High'].astype(float)
df['Low'] = df['Low'].astype(float)
```
如果您还遇到了 "MPLCONFIGDIR environment variable not set" 的错误,您可以在代码的开头添加以下代码来设置 MPLCONFIGDIR 环境变量:
```python
import os
os.environ['MPLCONFIGDIR'] = '/tmp/'
```
这样就可以避免上述警告,同时可以加速 Matplotlib 的导入并提高多进程支持。
阅读全文