python+matplotlib绘图线条类型、颜色、散点类型

Python-Matplotlib可视化(2)——自定义颜色绘制精美统计图 Matplotlib是Python的绘图库,它提供了一整套和 matlab 相似的命令 API,可以生成你所需的出版质量级别的图形。matplotlib提供的所有绘图都带有默认样式。虽然这可以进行快速绘图,但有时可能需要自定义绘图的颜色和样式,以对绘制更加精美、符合审美要求的图像。matplotlib的设计考虑到了此需求,很容易调整matplotlib图形的颜色和样式。 借助Matplotlib库,可以方便的对进行数据分析,快速完成数据可视化。 阅读详情

python+matplotlib画图选色选点


原文章链接:

http://www.cnblogs.com/darkknightzh/p/6117528.html

参考网址:

http://stackoverflow.com/questions/22408237/named-colors-in-matplotlib

http://stackoverflow.com/questions/8409095/matplotlib-set-markers-for-individual-points-on-a-line


第二个参考网址给出了linestyle可选参数:

[plain]  view plain  copy
  1. '-'       solid line style  
  2. '--'      dashed line style  
  3. '-.'      dash-dot line style  
  4. ':'       dotted line style  

第二个参考网址给出了marker可选参数:

[plain]  view plain  copy
  1. '.'       point marker  
  2. ','       pixel marker  
  3. 'o'       circle marker  
  4. 'v'       triangle_down marker  
  5. '^'       triangle_up marker  
  6. '<'       triangle_left marker  
  7. '>'       triangle_right marker  
  8. '1'       tri_down marker  
  9. '2'       tri_up marker  
  10. '3'       tri_left marker  
  11. '4'       tri_right marker  
  12. 's'       square marker  
  13. 'p'       pentagon marker  
  14. '*'       star marker  
  15. 'h'       hexagon1 marker  
  16. 'H'       hexagon2 marker  
  17. '+'       plus marker  
  18. 'x'       x marker  
  19. 'D'       diamond marker  
  20. 'd'       thin_diamond marker  
  21. '|'       vline marker  
  22. '_'       hline marker  


第一个参考网址给出了matplotlib中color可用的颜色:

[plain]  view plain  copy
  1. cnames = {  
  2. 'aliceblue':            '#F0F8FF',  
  3. 'antiquewhite':         '#FAEBD7',  
  4. 'aqua':                 '#00FFFF',  
  5. 'aquamarine':           '#7FFFD4',  
  6. 'azure':                '#F0FFFF',  
  7. 'beige':                '#F5F5DC',  
  8. 'bisque':               '#FFE4C4',  
  9. 'black':                '#000000',  
  10. 'blanchedalmond':       '#FFEBCD',  
  11. 'blue':                 '#0000FF',  
  12. 'blueviolet':           '#8A2BE2',  
  13. 'brown':                '#A52A2A',  
  14. 'burlywood':            '#DEB887',  
  15. 'cadetblue':            '#5F9EA0',  
  16. 'chartreuse':           '#7FFF00',  
  17. 'chocolate':            '#D2691E',  
  18. 'coral':                '#FF7F50',  
  19. 'cornflowerblue':       '#6495ED',  
  20. 'cornsilk':             '#FFF8DC',  
  21. 'crimson':              '#DC143C',  
  22. 'cyan':                 '#00FFFF',  
  23. 'darkblue':             '#00008B',  
  24. 'darkcyan':             '#008B8B',  
  25. 'darkgoldenrod':        '#B8860B',  
  26. 'darkgray':             '#A9A9A9',  
  27. 'darkgreen':            '#006400',  
  28. 'darkkhaki':            '#BDB76B',  
  29. 'darkmagenta':          '#8B008B',  
  30. 'darkolivegreen':       '#556B2F',  
  31. 'darkorange':           '#FF8C00',  
  32. 'darkorchid':           '#9932CC',  
  33. 'darkred':              '#8B0000',  
  34. 'darksalmon':           '#E9967A',  
  35. 'darkseagreen':         '#8FBC8F',  
  36. 'darkslateblue':        '#483D8B',  
  37. 'darkslategray':        '#2F4F4F',  
  38. 'darkturquoise':        '#00CED1',  
  39. 'darkviolet':           '#9400D3',  
  40. 'deeppink':             '#FF1493',  
  41. 'deepskyblue':          '#00BFFF',  
  42. 'dimgray':              '#696969',  
  43. 'dodgerblue':           '#1E90FF',  
  44. 'firebrick':            '#B22222',  
  45. 'floralwhite':          '#FFFAF0',  
  46. 'forestgreen':          '#228B22',  
  47. 'fuchsia':              '#FF00FF',  
  48. 'gainsboro':            '#DCDCDC',  
  49. 'ghostwhite':           '#F8F8FF',  
  50. 'gold':                 '#FFD700',  
  51. 'goldenrod':            '#DAA520',  
  52. 'gray':                 '#808080',  
  53. 'green':                '#008000',  
  54. 'greenyellow':          '#ADFF2F',  
  55. 'honeydew':             '#F0FFF0',  
  56. 'hotpink':              '#FF69B4',  
  57. 'indianred':            '#CD5C5C',  
  58. 'indigo':               '#4B0082',  
  59. 'ivory':                '#FFFFF0',  
  60. 'khaki':                '#F0E68C',  
  61. 'lavender':             '#E6E6FA',  
  62. 'lavenderblush':        '#FFF0F5',  
  63. 'lawngreen':            '#7CFC00',  
  64. 'lemonchiffon':         '#FFFACD',  
  65. 'lightblue':            '#ADD8E6',  
  66. 'lightcoral':           '#F08080',  
  67. 'lightcyan':            '#E0FFFF',  
  68. 'lightgoldenrodyellow': '#FAFAD2',  
  69. 'lightgreen':           '#90EE90',  
  70. 'lightgray':            '#D3D3D3',  
  71. 'lightpink':            '#FFB6C1',  
  72. 'lightsalmon':          '#FFA07A',  
  73. 'lightseagreen':        '#20B2AA',  
  74. 'lightskyblue':         '#87CEFA',  
  75. 'lightslategray':       '#778899',  
  76. 'lightsteelblue':       '#B0C4DE',  
  77. 'lightyellow':          '#FFFFE0',  
  78. 'lime':                 '#00FF00',  
  79. 'limegreen':            '#32CD32',  
  80. 'linen':                '#FAF0E6',  
  81. 'magenta':              '#FF00FF',  
  82. 'maroon':               '#800000',  
  83. 'mediumaquamarine':     '#66CDAA',  
  84. 'mediumblue':           '#0000CD',  
  85. 'mediumorchid':         '#BA55D3',  
  86. 'mediumpurple':         '#9370DB',  
  87. 'mediumseagreen':       '#3CB371',  
  88. 'mediumslateblue':      '#7B68EE',  
  89. 'mediumspringgreen':    '#00FA9A',  
  90. 'mediumturquoise':      '#48D1CC',  
  91. 'mediumvioletred':      '#C71585',  
  92. 'midnightblue':         '#191970',  
  93. 'mintcream':            '#F5FFFA',  
  94. 'mistyrose':            '#FFE4E1',  
  95. 'moccasin':             '#FFE4B5',  
  96. 'navajowhite':          '#FFDEAD',  
  97. 'navy':                 '#000080',  
  98. 'oldlace':              '#FDF5E6',  
  99. 'olive':                '#808000',  
  100. 'olivedrab':            '#6B8E23',  
  101. 'orange':               '#FFA500',  
  102. 'orangered':            '#FF4500',  
  103. 'orchid':               '#DA70D6',  
  104. 'palegoldenrod':        '#EEE8AA',  
  105. 'palegreen':            '#98FB98',  
  106. 'paleturquoise':        '#AFEEEE',  
  107. 'palevioletred':        '#DB7093',  
  108. 'papayawhip':           '#FFEFD5',  
  109. 'peachpuff':            '#FFDAB9',  
  110. 'peru':                 '#CD853F',  
  111. 'pink':                 '#FFC0CB',  
  112. 'plum':                 '#DDA0DD',  
  113. 'powderblue':           '#B0E0E6',  
  114. 'purple':               '#800080',  
  115. 'red':                  '#FF0000',  
  116. 'rosybrown':            '#BC8F8F',  
  117. 'royalblue':            '#4169E1',  
  118. 'saddlebrown':          '#8B4513',  
  119. 'salmon':               '#FA8072',  
  120. 'sandybrown':           '#FAA460',  
  121. 'seagreen':             '#2E8B57',  
  122. 'seashell':             '#FFF5EE',  
  123. 'sienna':               '#A0522D',  
  124. 'silver':               '#C0C0C0',  
  125. 'skyblue':              '#87CEEB',  
  126. 'slateblue':            '#6A5ACD',  
  127. 'slategray':            '#708090',  
  128. 'snow':                 '#FFFAFA',  
  129. 'springgreen':          '#00FF7F',  
  130. 'steelblue':            '#4682B4',  
  131. 'tan':                  '#D2B48C',  
  132. 'teal':                 '#008080',  
  133. 'thistle':              '#D8BFD8',  
  134. 'tomato':               '#FF6347',  
  135. 'turquoise':            '#40E0D0',  
  136. 'violet':               '#EE82EE',  
  137. 'wheat':                '#F5DEB3',  
  138. 'white':                '#FFFFFF',  
  139. 'whitesmoke':           '#F5F5F5',  
  140. 'yellow':               '#FFFF00',  
  141. 'yellowgreen':          '#9ACD32'}  

上面对应的颜色:


另外的显示方式:

装了seaborn扩展的话,在字典seaborn.xkcd_rgb中包含所有的xkcd crowdsourced color names。如下:

plt.plot([1,2], lw=4, c=seaborn.xkcd_rgb['baby poop green'])

所有颜色如下:


plt.plot(x,y,color,linestyle,marker)函数参数详解 需要注意的是,`plt.plot()`函数的参数比较多,不同的参数组合可以实现各种各样的效果。具体使用时需要根据需求进行选择和调整,以获得期望的绘图效果。`plt.plot()`函数是matplotlib库中用于绘制线条图的函数,它有多个参数可以控制绘图的各个方面。 阅读详情

相关推荐

详解matplotlib的color配置

详细了解matplotlib的颜色属性和配置

whitedrogen的博客 5914

plt的color,marker, legend的位置设置

blue’‘green’‘red’‘cyan’‘magenta’‘yellow’‘black’‘white’‘purple’‘orange’‘pink’ 等等。

weixin_43845922的博客 3487

python画图(线条颜色、大小、类型:点、虚线等)(图文详细入门教程四)

初衷 本人由于平常写论文需要输出一些结果图,但是苦于在网上搜python画图时,详细的教程非常多,但是就是找不到能马上解决自己问题那一行代码,所以打算写一些适合需求简单的朋友应急用的教程,应急就必须方便搜索,所以我把主要的内容写在了标题,方便大家到主页查找对应的功能,教程里有对应的效果图,方便查看,希望可以帮助到有需要的朋友。 说明 本教程的效果图是在jupyter notebook完成。教程是接...

weixin_45630708的博客 6261

【Python】plt绘图之颜色查询

绘制条形图时,柱子将会按照上述的顺序显示颜色,每种颜色对应的字符串可以在matplotlib的官方文档查询(https://matplotlib.org/stable/gallery/color/named_colors.html)

weixin_44708254的博客 2017

python matplotlib绘图过程中设置线条颜色

当使用matplotlib绘制图形时,我们通常需要自定义图形样式以使其更加美观和易于阅读。在本文中,我们将介绍如何自定义图形的颜色。文末有很多颜色,请大家自取🏇🏇🏇🏇最近一直在死磕数据可视化 💻,希望这些博文 📝 能够记录下我学习到的知识,同时也希望能够帮助到大家 🤗。数据可视化不仅仅是一种技能,更是一种表达想法的方式。希望大家能够通过我的分享,更好地理解和运用数据可视化,创造出更美、更有价值的可视化作品 💪。

alike_u的博客 1万+

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

今天是数据处理专题的第11篇文章,我们继续来介绍matplotlib这个包的使用方法。 在上一篇文章当中我们介绍了matplotlib当中subplot的概念以及用法,今天我们将会来介绍matplotlib绘图中的一些具体的设置,可以让我们画出来的图像更加丰富,表现力也更强。 颜色 我们之前绘制的图像都是蓝色的,这也是matplotlib的默认颜色。我们可以使用color这个参数来设置图像的颜色,比如我们想要画原谅色的图,我们就传入color=‘green’,这样我们得到的图像就是绿色了。 由于绿色是很常

TechFlow的博客 4688

matplotlib知识

后续用到的再更新; 首先matplotlib 是python的绘画库,pylot(plt)包含了很多绘画的函数; 1.plt.plot():绘制直线; plt.plot([1,3,6],'ro') # 一共有三个参数,第三个参数若省略则表示为蓝色实线; # 第一个参数若省略,则x值默认从0-n-1,长度与y的长度相同; # r:红色实线,ro红色点; plt.xlabel('x') # x轴坐标命名为x; plt.ylabel('y') # y轴坐标命名为y; plt.show() 运行结果: 如果mat

weixin_45544793的博客 337

不只是对齐:用 MFA 和 Praat 给你的语音数据集快速生成 TextGrid 标注文件

本文详细介绍了如何利用Montreal Forced Aligner(MFA)和Praat工具快速生成TextGrid标注文件,大幅提升语音数据标注效率。通过批量对齐、质量校验和跨语言处理等实战技巧,帮助研究者构建自动化标注流水线,适用于语音合成和语音识别等多种应用场景。

weixin_30675247的博客 380

python+matplotlib绘图线条类型和颜色选择

本文由以下链接转载: http://www.cnblogs.com/darkknightzh/p/6117528.html 参考网址: http://stackoverflow.com/questions/22408237/named-colors-in-matplotlib http://stackoverflow.com/questions/8409095/matplotlib-set-mar...

syyyy712的博客 10万+

具身智能的边缘计算核心构成方案

摘要: 具身智能(Embodied Intelligence)依赖物理实体与环境交互,而边缘计算(Edge Computing)通过本地化数据处理降低延迟、提升实时性。两者结合的核心方案包含五层架构:传感器层采集环境数据,边缘处理单元执行本地计算,通信模块实现低延迟传输,决策引擎运行轻量AI模型,执行器接口转化动作为物理操作。该方案以“边缘优先”为原则,满足毫秒级响应(如延迟<50ms),同时优化能效(功耗降低30%)和隐私保护。适用于机器人、自动驾驶等场景,通过分层闭环设计确保在资源受限环境中的可靠

老郑的博客 815

地图可视化类型大全

地图可视化类型大全: 散点地图 网格地图 聚合地图 气泡地图 热力图 Choropleth地图/分级设色地图/分级区域地图/着色地图/分级统计地图(百度百科这样翻译)/等值域地图/分段设色地图 Cartogram地图/变形地图/示意地图 规则形状地图 /RecMap/Demers Cartogram/瓷砖网格地图/DorlingMap 流型图(Flow Map)\流线图\流向图\轨迹地图 复合地图

codeuniverse的博客 3539

python中matplotlib的颜色及线条控制(linestyle、marker、color)

linestyle可选参数: '-' solid line style '--' dashed line style '-.' dash-dot line style ':' dotted line style marker可选参数: '.' point marker ',' pixel marker 'o' ...

jkx521的博客 2万+

彩票预测的可能性与算法分析

彩票作为一种以随机数为基础的赌博形式,吸引了大量希望一夜暴富的参与者。尽管许多人希望通过某种方式预测彩票结果,以增加中奖几率,但彩票预测的可能性依然是一个充满争议和误解的话题。本文将探讨彩票是否能够预测的理论依据,分析可能的预测算法,并解释这些算法为何在实际应用中难以奏效。

m0_38012434的博客 2万+

Python matplotlib 作图(一、线条颜色、类型设置)

目录 1、线条颜色、类型设置 matplotlib颜色表 ​线段类型大全 参考 1、线条颜色、类型设置 #颜色设置:color='g' #线的类型:linestyle='-' #线的粗细:linewidth=5 plt.scatter(df_2012[vnlCol], df_2012[srNLCol], color='g') plt.plot(xlst, xlst, color='r', linestyle=':') matplotlib颜色表 线段类型大全 ...

qq_17576739的博客 1万+

OpenMVS :用 colmap制作自己的数据集 重建(用colmap计算位姿,将位姿转为MVS需要的格式)

数据集制作主要是在windows进行,比较方便。

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 3329

QT如何使用CTK插件搭建应用程序框架?

CTK框架,QT框架,插件系统

cs821984831的博客 739

python画图(线条颜色、大小、类型:点、虚线等)

本人由于平常写论文需要输出一些结果图,但是苦于在网上搜python画图时,详细的教程非常多,但是就是找不到能马上解决自己问题那一行代码,所以打算写一些适合需求简单的朋友应急用的教程,应急就必须方便搜索,所以我把主要的内容写在了标题,方便大家到主页查找对应的功能,教程里有对应的效果图,方便查看,希望可以帮助到有需要的朋友。

m0_59485658的博客 9915

LSTM 双向 Bi-LSTM

LSTM 双向 Bi-LSTM

jacke121的专栏 1524

matplotlib绘图线条样式和线条颜色

常用的线条类型: 字符 类型 ‘ - ’ 实线 ’ -. ’ 虚点线 ’ . ’ 点 ’ o ’ 圆点 ’ ^ ’ 上三角形 ’ > ’ 右三角形 ’ 2 ’ 上三叉点 ’ 4 ’ 右三叉点 ’ p ’ 五角点 ‘h’ 六边形点 ’ + ’ 加号点 ’ D ’ 实习菱形点 ’ _ ’ 横线点 ’ __ ’ 虚线 ’ : ’ 点线 ’ , ’ 像素点 ’ v ’ 下三角形 ’ < ’ 左三角形 ’ 1 ’ 下三

Benjamin 1万+

手把手教你学SOME/IP「3.2.1.发布/订阅行为」

本文详细介绍了SOME/IP协议中的服务发现机制,重点解析了发布/订阅行为的流程。主要内容包括:1)服务发布与Method通信流程,涵盖find/offer报文交互、TTL保活机制及异常处理;2)服务订阅与Event通信流程,包括subscribe/ack报文交互和组播延迟机制;3)特殊场景如快速发送、半周期回复、重置订阅等机制。通过邮局订阅报纸的类比,帮助理解服务发现的核心原理,并强调流程图对于问题定位的重要性。文章为SOME/IP协议的工程实现提供了实用指导。

nihaoljq2010的博客 1231

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

【Python】Python画图(线条颜色、大小、线形)【转载】

本文转载自:https://www.cnblogs.com/qccc/p/12795541.html 初衷 本人由于平常写论文需要输出一些结果图,但是苦于在网上搜python画图时,详细的教程非常多,但是就是找不到能马上解决自己问题那一行代码,所以打算写一些适合需求简单的朋友应急用的教程,应急就必须方便搜索,所以我把主要的内容写在了标题,方便大家到主页查找对应的功能,教程里有对应的效果图,方便查看,希望可以帮助到有需要的朋友。 说明 本教程的效果图是在jupyter notebook完成。教程是接着之前.

weixin_43868754的博客 3995

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

python中matplotlib画图时颜色及线条控制

(原)python中matplotlib的颜色及线条控制 http://www.cnblogs.com/darkknightzh/p/6117528.html 参考网址: http://stackoverflow.com/questions/22408237/named-colors-in-matplotlib http://stackoverflow.com/...

Turbo_Come的博客 2261

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

(原)python中matplotlib的颜色及线条控制

转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6117528.html 参考网址: http://stackoverflow.com/questions/22408237/named-colors-in-matplotlib http://stackoverflow.com/questions/8409095/matplotlib-set-m...

weixin_34160277的博客 1万+

02 Python Matplotlib 库的样式设置(颜色、线条、标记样式)

02 设置图表样式 #linewidth 绘制线条宽度 plt.plot(a,s, linewidth = 6) #添加x,y轴名称 plt.xlabel('x') plt.ylabel('y = x^2') #给图标添加图名 plt.rcParams['font.sans-serif'] = ['SimHei'] # 中文下的字体格式进行修改对 plt.title('多点绘制') plt.s...

Corollary的博客 6657
上一篇: Python利用Matplotlib画曲线和柱状图
下一篇: ubuntu系统重新分区、根目录扩容
Publish or Perish
博客等级 码龄12年 93粉丝 49原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址