使用backtrader时遇到的matplotlib版本过高的问题及解决办法

在使用backtrader进行金融数据分析和策略回测时,我们可能会遇到一个常见的问题,那就是matplotlib版本过高导致backtrader无法正常运行。本文将介绍如何解决这个问题,并提供相应的源代码和描述,帮助读者顺利使用backtrader进行数据分析和策略回测。

问题描述:
当我们在安装并使用backtrader时,可能会遇到以下错误提示之一:

ModuleNotFoundError: No module named 'matplotlib'

或者

AttributeError: ‘FigureCanvasGTK3Cairo’ object has no attribute ‘get_default_filename’

这些错误提示表明我们当前的matplotlib版本过高,不兼容backtrader的要求。

问题原因:
backtrader的早期版本与matplotlib存在一些兼容性问题,特别是在matplotlib 3.4及更高版本中。当我们安装了较新版本的matplotlib时,backtrader可能无法正常引用matplotlib的相关功能,导致出现上述错误。

解决办法:
为了解决这个问题,我们需要降低matplotlib的版本。请按照以下步骤操作:

步骤1:卸载当前版本的matplotlib
在命令行中执行以下命令,卸载当前版本的matplotlib:

pip uninstall matplotlib
Backtrader 文档学习- Plotting plot 绘图功能,绘图选项参数,控制对象的参数,plotscheme 对象。 阅读详情

相关推荐

Backtrader无法支持最新版本的Matplotlib,如何解决以及使用Backtrader进行画图的方案

Backtrader早期的版本是基于Matplotlib v1.x开发的,而随着时间的推移,Matplotlib已经迭代到了v3.x。在这个过程中,Matplotlib引入了一些不兼容的更改,导致了与Backtrader的兼容性问题。总结而言,当Backtrader无法支持最新版本的Matplotlib时,你可以选择降级安装兼容的Matplotlib版本,或者使用Backtrader自带的绘图功能。这样一来,你无需依赖于外部的Matplotlib库,就可以使用Backtrader自带的绘图功能进行画图。

NisyPhilosophy的博客 708

Backtrader无法支持最新版本的Matplotlib,解决方案及Backtrader绘图的方法

根据你的需求和偏好,选择适合的解决方案来解决Backtrader与Matplotlib版本不兼容的问题。Backtrader的早期版本使用的是Matplotlib的pyplot模块来绘制图形。然而,由于Matplotlib的更新,最新版本的Matplotlib中的pyplot模块与Backtrader不兼容。如果你无法解决Backtrader与Matplotlib版本不兼容的问题,你可以考虑使用其他绘图库来替代Matplotlib。一种解决方案是使用与Backtrader兼容的Matplotlib版本。

InUnix的博客 884

【答读者问27】backtrader不支持最新版本的matplotlib怎么办以及backtrader画图的解决方案

backtrader的版本由于相对比较完善了,所以最近更新的比较慢,这就导致了一个问题,如果依赖的模块进行更新了,就可能导致backtrader的某些功能不可用,即版本兼容问题。比如,当使用最新版本的matplotlib的时候,在backtrader中,使用cerebro.plot()进行画图会保持,出现兼容问题,如果把matplotlib的版本进行倒退到3.1.2,就可以使用了。 简单点的解决方式 直接尝试把matplotlib的版本倒退到3.1.2 这种向后兼容的方式是不合理的,但是可以作为权宜之计

云金杞 3708

matplotlib-2.1.0

本人在大家深度学习框架tensorflow过程中使用的软件,方便大家使用

Python3.x+matplotlib(matplotlib版本好像是2.2.1及以上版本;反正要求较高版本)库实现三维网格彩色显示源代码

Python3.x+matplotlib(matplotlib版本好像是2.2.1及以上版本;反正要求较高版本)库实现三维网格彩色显示源代码

2.ROS实用工具:坐标变换

本文围绕ROS坐标变换展开,介绍其在机器人系统中的关键作用,即统一不同传感器和执行器坐标系,服务数据融合等操作。基于ROS的tf库,从广播和监听TF变换两方面阐述实现过程,涵盖新建工作包、编写广播和监听代码、配置构建文件及编译等步骤。此外,介绍启动节点管理器后运行广播和监听节点的方法,并通过rqt_graph、rqt_tf_tree、tf_echo等工具可视化和获取坐标系变换信息。借助这些内容,读者不仅能掌握ROS坐标变换的实现,还能对机器人坐标变换系统的调试和理解有更深入认识 。

qq_74168740的博客 1178

ThinkPad X230魔改指南:从博通网卡驱动到1080P屏显全攻略(附Sonoma避坑清单)

本文详细介绍了ThinkPad X230的全面改造方案,包括博通网卡驱动(BCM94352HMB)的安装与调试、1080P屏幕改装技术以及macOS Sonoma系统的适配优化。通过硬件升级和软件调优,使这台经典商务本焕发新生,适合DIY爱好者和技术极客参考实践。

weixin_30379531的博客 601

决策树(分类树、回归树)

决策树 前言:第一篇博客,最近看完决策树,想着归纳一下,也方便自己以后回顾。写的会比较全面一些,可能会有很多不太正确的地方,欢迎大家交流指正 : ) 决策树模型: 决策树模型是运用于分类以及回归的一种树结构。决策树由节点和有向边组成,一般一棵决策树包含一个根节点、若干内部节点和若干叶节点。决策树的决策过程需要从决策树的根节点开始,待测数据与决策树中的特征节点进行比较,并按照比较结果选...

你午睡了吗 9万+

HPM6E00:PWM V2使用指南

HPM6E00:PWM V2使用指南

xikangsoon的博客 1741

如何理解反步法设计控制器?

假设以二阶系统为例,被控对象的系统状态方程为: 基于反步控制的具体方法如下: 1.1步骤一 定义期望状态为xd,状态误差e1,为: e1=x1-xd; 则e1的导数为: 1.2步骤二 定义虚拟控制量为: e2定义为: 1.3步骤三 定义Lyapunov能量函数为: 1.4步骤四 定义总Lyapunov能量函数为: 因此设计的控制律为: 设计c>0,则: 满足Lyapunov的稳定性判定条件...

weixin_42736130的博客 2万+

解决Docker拉取镜像报错:Get https://registry-1.docker.io/v2/: 报错

解决Docker拉取镜像报错: Get “https://registry-1.docker.io/v2/”: net/http: request canceled while waiting for connection问题描述Get "https://registry-1.docker.io/v2/"是docker官方的镜像源,下载很慢的,一般会自己指定国内映射的加速镜像源。

qq_33650333的博客 4180

基于语义分割的实时建图:HDMap动态更新

基于语义分割的实时建图:HDMap动态更新​ ,人工智能,计算机视觉,大模型,AI,本文围绕基于语义分割的实时建图技术在HDMap动态更新中的应用展开,介绍了语义分割基础、HDMap概述、相关实时建图技术、动态更新关键技术、系统性能评估指标、实际应用案例、面临的挑战与解决方案及未来发展趋势。阐述了该技术如何利用传感器数据和语义分割算法,解决传统HDMap构建与更新的弊端,分析了其在精度、实时性、鲁棒性等方面的表现,以及在自动驾驶和智能交通中的应用,还探讨了现存问题及未来优化方向。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 22万+

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

上一篇: 在肯特纳通道策略中应用到鸡蛋期货的文章
下一篇: Backtrader基础教程:使用Volume Filling Fillers
普通网友
博客等级 码龄3年 209粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值