实用技巧——Python实现从Excel读取数据并绘制成图像

ImageDraw()绘图函数《python基础篇》 引言:最近看了关于源码,里面就有这个函数,开始不懂,然后拖到了现在,发现还是不懂,于是今天索性弄她个干净利索,安排的明明白白。 1.首先就是模块函数的引入。 from PIL import Image, ImageDraw, ImageFont 解释:其中image是用来读取图像、imagedraw用来绘图,也就是今天的主角,imagefont是用来调用字体。(首先对于我们之前没有见过的函数,通过这个函数的名称就能猜出个大概意思来!) 2.图像读取。 path=r'stt.jpg' im. 阅读详情

本文主要阐述如何使用python从excel读取数据,并用matplotlib绘制成二维图像。

主要知识点为:

  • 使用xlrd扩展包读取excel数据
  • 使用matplotlib绘制二维图像
  • 美化图像,添加标注,注释,显示Latex风格公式,坐标点处透明化处理等技巧

适合人群:适合具有Python基础的用户,对于需要书写实验报告,学位论文,发表文章,做PPT报告的学员具有较大价值。

实用技巧——Python实现从Excel读取数据并绘制成图像

 

开发准备

打开Xfce终端,下载并安装的相关依赖 。

$ sudo apt-get update
$ sudo apt-get install python-dev
$ sudo pip install numpy
$ sudo apt-get install python-matplotlib
$ sudo pip install xlrd
$ sudo apt-get install python-sip
$ sudo apt-get install libqt4-dev
$ sudo apt-get install python-qt4 python-qt4-dev pyqt4-dev-tools qt4-dev-tools

遇到是否安装的询问时,输入y,按回车键继续安装。

实验步骤

1.绘制一个简单图像,测试扩展包安装是否正常。

安装完成matplotlib后,运行一个小程序测试其是否正常。我们来绘制一个非常简单的正弦函数。

import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 500)
dashes = [10
Python实现从excel读取数据并绘制成精美图像 阅读详情

相关推荐

使用python读取excel中的数据,并绘制折线图

使用python读取excel中的数据,并绘制折线图 做实验的时候采集到一些数据,从文本拷贝到excel,然后从十六进制转换成十进制。图表时分析数据的有利工具,使用python绘制出的图标简明美观。所以我这次尝试一下。python新手,请多多指教。 我这次的数据比较简单,在excel中只有一个sheet,一列有效数据。所以这次的任务可以分为两部分:读取数据,绘图。 一, 读取数据 链接 这个写的很...

sherry_lvy的博客 5万+

Python实用技巧:从Excel读取数据并绘制成图像

本文主要阐述如何使用python从excel读取数据,并用matplotlib绘制成二维图像。 主要知识点为: 使用xlrd扩展包读取excel数据 使用matplotlib绘制二维图像 美化图像,添加标注,注释,显示Latex风格公式,坐标点处透明化处理等技巧 适合人群:适合具有Python基础的用户,对于需要书写实验报告,学位论文,发表文章,做PPT报告的学员具有较大价值。 开发准备 打...

web开发与Python 2561

Python从Excel读取数据并使用Matplotlib绘制成二维图像

本次实验使用 Python 的绘图包 Matplotlib 绘制了一副图像。图像的数据来源于 Excel 数据表。与使用数据表画图相比,通过程序控制绘图,得到了更加灵活和精细的控制,最终绘制除了一幅精美的图像。到此这篇关于Python从Excel读取数据并使用Matplotlib绘制成二维图像的文章就介绍到这了。点击拿去50G+学习视频教程100+Python初阶、中阶、高阶电子书籍​​​​​​​​​​​​​。

ai520wangzha的博客 4389

Python 实现将 Excel 数据绘制成精美图像

本课程实现使用 Python 从 Excel 读取数据,并使用 Matplotlib 绘制成二维图像。

python收藏家的博客 3608

Python读取excel数据且横轴是日期的图像绘制

Python的matplotlib包含很多图表函数,其中plot()函数是绘制坐标图的。 通常情况下,横轴和纵轴都是数值型数据很好画图,直接带入数据,坐标轴会自动调节大小和显示密度。但是当横轴是日期时,且从excel文件读取数据时,有一点麻烦。 遇到的问题: 1. 首先,excel里的日期显示不正常。 2. 横轴日期的显示不理想,或太密集或太松弛。 解决: 1. 方法一:修改excel...

u012494321的博客 7843

python获取excel数据制作有文字和图表的报告_Python实现从excel读取数据并绘制成精美图像...

Python实现从excel读取数据绘制成精美图像一、实验介绍1.1 实验内容这个世界从古至今一直是一个看颜值的世界。对于我们作报告,写文章时使用的图片,也是一样的。一图胜千言,一张制作精美的图片,不仅能展示大量的信息,更能体现绘图者的水平,审美,与态度。我的老板,国内外多家SCI,EI文章的审稿人,甚至跟我说,一篇文章拿到手里,一眼扫过去,看看数据和图片,就知道这篇文章值不值得发表,水平如何。由...

weixin_39953845的博客 585

Python实现将Excel转换成为image

我的主要思路是: Excel -> Html -> Image 代码如下: # -*- coding:utf-8 -*- __author__ = 'YangXin' import sys import pandas as pd import codecs import imgkit reload(sys) sys.setdefaultencoding('utf-8') #...

杨鑫newlife的专栏 9059

用Python处理Excel数据和绘制图表

我们将介绍如何使用Python处理Excel数据和绘制图表

weixin_44853840的博客 2271

HTTPS接口测试翻车实录:为什么浏览器能访问而curl报证书错误?

本文深入分析了HTTPS接口测试中浏览器访问正常而curl报证书错误的典型问题。通过对比浏览器、Postman和curl的工具行为差异,结合Nginx日志与Wireshark抓包,揭示了问题根源在于网络架构中HTTPS请求被意外“降级”为HTTP传输,导致SSL握手失败。文章重点探讨了curl工具严格验证机制暴露的`Peer's Certificate issuer is not recognized`错误,并提供了网络配置修正方案与标准化测试流程。

u9v0w的博客 285

路径搜索算法——RRT*算法

RRT算法是RRT算法的优化版本,通过引入路径优化机制实现渐进最优性。该算法在高维空间和复杂环境中表现优异,主要步骤包括随机采样、树扩展和邻近节点重新连接。相比RRT,RRT能够不断优化路径质量,但计算复杂度更高。Python实现展示了其核心逻辑:随机采样扩展树节点,检查碰撞,选择最优父节点,并通过重新连接优化路径。算法适用于机器人导航等场景,但需平衡计算效率与路径质量。

swaggytiger的博客 3066

ADS(Arm Developer Suite)安装的坑!

实验课老师让我们区安装ADS,作为嵌入式开发的工具,原本以为这只是一个简单的软件,但是当我安装的时候,我才发现这软件太难了!安装了我大半天,看了其他的博客之后,最终才安装成功???????? 安装过程的一个巨坑就是:安装路径!以及安装许可注册文件 如果没有注意路径,最后安装成功以后打开软件就是蜜汁报错???? 报错了怎么办?删掉已安装的东西,重新安装吧,而且要删干净 再次安装的时候,打开安装包是这个提示...

weixin_42795819的博客 8222

Buck电源设计常见的一些问题(四)MOS管振荡抑制方法(二)

另一方面,开关振铃为远超开关频率的高频振铃,并伴随很高的 dV/dt,会带来传导和辐射的 EMI 问题,可能会使得终端产品不能通过 EMI 标准测试,更严重时甚至会干扰开关电源自身的信号电路或临近的其他功能电路的正常工作。选用二极管反向特性好的器件;该电路可等效成图 3 中 LC 谐振电路,新的 LR和 CR为 Lp1、Lp5,Lp3, Lp4, CD等所有参与振铃的寄生感容的复合值。通常 Snubber 的 Csnub取值在数 nF 以上,在振铃频率 fR(加了 snubber 后)下的阻抗很小。

小幽余生不加糖 2900

构建AI Agent驱动的智能健康管理系统

数据碎片化:健康数据分散在不同的设备和平台中,难以统一管理和分析。个性化不足:健康管理方案通常是通用的,难以根据个人的健康状况实时调整。用户参与度低:用户难以获得及时、个性化的健康建议,导致健康管理效果不佳。AI Agent是一个能够感知环境、采取行动以实现目标的智能实体。根据智能体的智能水平,可以分为简单反应式智能体和复杂适应式智能体。实时监测健康数据。获取个性化的健康建议。收到健康风险预警。

AI天才研究院 753

基于模板匹配实现手写汉字识别matlab源码含GUI

主要包括三个按钮和三个图像显示框:第一个按钮用于选择待匹配的手写汉字图像,第二个按钮用于进行匹配,第三个按钮用于清除所有内容。当用户点击匹配按钮时,会自动调用模板匹配函数,并在图像显示框中显示匹配结果。上述代码首先将之前提取的Hu不变矩特征存储在T矩阵中,并将对应的类别信息存储在L向量中。然后读取待匹配汉字,提取其Hu不变矩特征,并使用pdist2函数计算待匹配汉字与所有汉字模板的距离。本文介绍了如何使用matlab实现手写汉字识别,包括汉字模板提取、模板匹配算法、GUI界面设计等方面。

pytorchCode的博客 268

【车载以太网】ATU(Address Translation Unit / Address Table Unit)

【车载以太网】ATU(Address Translation Unit / Address Table Unit)

天赐好车的博客 164

【AI·FDE】第9篇:FDE 的未来——从人 FDE 到 AI FDE 到自助化,价值迁向哪里

系列文章 | 2026年9月这是【AI·FDE】系列的终章。前面 8 篇把 FDE 的起源、能力、方法论、产品化、转型路径、工具化都讲透了。我们用一条"三段式演变弧线"来回答——从手工作坊,到平台化,再到自助化。

104

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

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

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

上一篇: 用Python帮你上马,哪里无码打哪里
下一篇: python里的真除法、Floor除法和小数位截断
lamehd
博客等级 码龄9年 119粉丝 208原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值