matplotlib设置颜色、标记、线条,让你的图像更加丰富

Python--matplotlib绘图 绘制一个最简单的折线图 现在绘制一个简单的二维折线图,按如下代码画出折线图: # -*- coding: utf-8 -*- #matplotlib小测试 ''' import matplotlib.pyplot as plt #导入库 plt.plot([2,4,6,8,10],[3,1,4,5,2]) #给图形x,y轴拐点赋值,并生成2D图形 plt.xlabel('Course') #生成x轴标签 plt.ylabel 阅读详情

今天是数据处理专题的第11篇文章,我们继续来介绍matplotlib这个包的使用方法。

在上一篇文章当中我们介绍了matplotlib当中subplot的概念以及用法,今天我们将会来介绍matplotlib绘图中的一些具体的设置,可以让我们画出来的图像更加丰富,表现力也更强。

颜色

我们之前绘制的图像都是蓝色的,这也是matplotlib的默认颜色。我们可以使用color这个参数来设置图像的颜色,比如我们想要画原谅色的图,我们就传入color=‘green’,这样我们得到的图像就是绿色了。

由于绿色是很常见的颜色(大雾),所以我们没必要输入完整的green单词,使用g作为缩写就可以了。除了绿色之外,其他常用的颜色也一样,比如红色可以就写成r,蓝色写成b,黄色写成y等等。

相对来说这些常用颜色还是比较好记的,如果记不住也没有关系,我们可以在jupyter当中通过plt.plot?这个命令来查阅相关的文档。把文档拉到最后,我们可以看到关于颜色设置的定义:

这里有两个颜色看起来不太常用,一个是cyan是青色,另外一个是magenta是品红。说明老外对颜色的喜好和审美和我们国人还是有些差距的。

除了使用单词之外,我们还可以使用16进制来表示颜色。比如#CECECE,表示一种淡淡的灰色。到底有多灰呢?我们画出来就知道了。

16进制表示颜

1篇1章3节:R 语言的产生与发展轨迹(更新2024/08/14) 药物的研究阶段包括靶标确定、生物学模型建立、新化学实体的发现和优化新化学实体四个关键环节。每个环节都在药物研发过程中发挥着至关重要的作用。通过科学严谨的方法和技术手段,研究人员能够在药物研发过程中不断探索和优化,从而发现和开发出具有高效、安全性的候选药物,为疾病治疗提供更多的选择和希望。 阅读详情

相关推荐

东方财富API隐藏技巧:这样获取分时均价线数据更稳定(避坑指南)

本文深入解析东方财富API获取股票分时数据,特别是分时均价线的实战技巧与避坑指南。针对高频调用中常见的请求失败、数据错位及IP限制等问题,提供了从接口参数深层解析、稳健请求与错误处理机制,到系统优化与数据校验的全流程解决方案,帮助开发者构建稳定可靠的数据采集系统。

rice5的博客 2547

使用FloodRisk2插件进行洪水风险评估

入汛以来,长江流域持续的强降雨使得沿岸多地成为洪水风险极高地区,抗洪、抢险、救灾继新冠病毒之后成为又一个攻坚阵地。如何科学地评估洪水风险,是快速决策的关键。 实际生活中,根据风险是否可控,一般将洪水风险大致分为两类:一类是通过数据分析可以得出其发生的可能性和后果,如强降雨引发的区域性洪水、水库/大坝溃决洪水等。这类洪水可以通过有关资料分析和设定一定条件计算得到可能的损失后果,也就是说,风险可以预判。另一类洪水风险基本是未知的,如滑坡堵塞河道形成堰塞湖引发的洪水,无法预知事件发生的地点和规模,具体的洪水风险无

QGISClass的博客 2883

CESM笔记——CESM1.0-CESM1.2.2-CESM2.1.3三个版本模式工作流对比

最近测试了CESM1.0,CESM1.2.2和CESM2.1.3三个版本,不同版本在workflow上有一些区别,来做点笔记。 CESM1.0 测试compset:B_2000,F_2000 workflow: 1. create_newcase -case ~/CESM/cesm1_0/script/B_2000 -compset B_2000 -res f19_g16 -mach tianhe 2. cd B_2000 (optional) env_mach_pes.xml ##修改核数,

砍柴姑娘Jourosy的博客 4949

python 爬虫 xpath 存储到数据库

参考

我是张先生 1295

Onnxruntime之YOLOP部署过程记录

魔改YoloP部署过程记录

如果想成为中心,那么就到中心去吧。 1934

嵌入式Modbus协议面试题及参考答案

Modbus 协议采用主从模式进行通信,这种模式定义明确,便于在工业环境中实现设备之间的有序数据交互。在主从模式中,存在一个主站(Master)和多个从站(Slave)。主站通常是工业控制系统中的上位机,如 PLC、工控机等,它负责发起通信请求,控制整个通信过程。从站则是各种现场设备,如传感器、执行器等,它们接收主站的请求,并根据请求进行相应的操作,然后将结果返回给主站。主站的主要功能包括:发起数据读取或写入请求、控制通信的时序和流程、处理从站返回的数据。

大模型大数据攻城狮的专栏 2051

【RAG文档解析优化】复杂Excel表格处理

—从识别表格边界,到恢复内部结构,再到生成RAG友好的表示——我们可以系统性地将这些“带刺的玫瑰”驯服。虽然代码实现可能充满细节和挑战,但其带来的回报是巨大的:一个更干净、更可靠的知识库,以及一个能真正理解和利用表格数据、从而提供精准答案的RAG系统。为了人类阅读的便利性,制作者常常会使用合并单元格来创建标题、使用多层表头来组织复杂的列、在同一个Sheet页中放置多个相关的表格,并添加大量的注释说明。它们就像一朵朵“带刺的玫瑰”,虽然蕴含着宝贵的数据,但如果直接用传统的方法(如。

kakaZhui的博客 860

SAP Build Work Zone standard edition 订阅报错 OIDC trust missing 的成因与完整解决路径

摘要:用户订阅SAP Build Work Zone时遇到422错误,提示未配置OpenID Connect信任。该错误表明业务用户需通过SAP Cloud Identity Services的OIDC协议认证,而当前子账户仅配置了SAML信任或未配置信任。解决方法是进入子账户的Trust Configuration页面,使用Establish Trust功能建立与SAP Cloud Identity Services的OIDC信任关系。这是SAP新版服务的强制要求,SAML协议已不被支持。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 200

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

深度学习工具包 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")

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

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

上一篇: 20行代码实现,使用Tarjan算法求解强连通分量
下一篇: 设计模式第二篇,链式方法模式
TechFlow
博客等级 码龄7年 347粉丝 276原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址