python - 没有名为“matplotlib.finance”的模块,已弃用,且 mpl_finance 也未维护
问题描述
我需要在图表上绘制一些带有额外线条和各种图形的烛台图表,但我发现它matplotlib.finance
已被弃用。替换为mpl_finance
,但这也没有维护。
如今,一个诚实的新生 python 开发人员应该使用什么来绘制烛台?有任何想法吗?
我将用于此的代码将类似于:
将 matplotlib.pyplot 导入为 plt
from matplotlib.dates import DateFormatter, WeekdayLocator,\
DayLocator, MONDAY
from matplotlib.finance import candlestick_ohlc
mondays = WeekdayLocator(MONDAY)
alldays = DayLocator() # minor ticks on the days
weekFormatter = DateFormatter('%b %d') # e.g., Jan 12
dayFormatter = DateFormatter('%d') # e.g., 12
fig, ax = plt.subplots()
fig.subplots_adjust(bottom=0.2)
ax.xaxis.set_major_locator(mondays)
ax.xaxis.set_minor_locator(alldays)
ax.xaxis.set_major_formatter(weekFormatter)
# ax.xaxis.set_minor_formatter(dayFormatter)
#plot_day_summary(ax, quotes, ticksize=3)
candlestick_ohlc(ax, candles, width=0.6)
ax.xaxis_date()
ax.autoscale_view()
plt.setp(plt.gca().get_xticklabels(),
rotation=45, horizontalalignment='right')
解决方案
您可以mpl_finance
不受限制地使用。可在github.com/matplotlib/mpl_finance 获得。请参阅此处了解如何安装它。
“未维护”只是意味着如果您发现其中的错误,没有人会为您修复它。
推荐阅读
- lotus-notes - 在 LotusScript 中生成随机语言
- python - Flask-SQLAlchemy-SQLite:无法处理 GUID 对象服务器端 - ValueError:格式错误的十六进制 UUID 字符串
- flutter - 在调试模式下工作但不在发布模式下工作的包(Flutter 2.1)
- html - 更改按钮宽度
- symfony - Mailhog、Trapmailer 和 gmail 通过 symfony
- javascript - 如何使用 react-native-testing-library 模拟 useEffect 异步调用?
- node.js - nodejs API基本身份验证的证书链错误中的自签名证书
- javascript - 从字符串时区获取时间(javascript)
- r - Rstudio 发布文件到 rpubs 没有外部浏览器和登录页面弹出
- python-3.x - Django没有从静态目录加载样式文件