matplotlib legend()里字体修改

Python Matplotlib legend函数:为每条折线添加图例 还不会?还不会就来找我吧 阅读详情

背景:准备投论文,因为操蛋的模板要求,所以你得好好修改。

 

对legend()显示的内容的字体进行修改

 

labelss = plt.legend(loc='upper right').get_texts()
[label.set_fontname('Times New Roman') for label in labelss]
label = labelss[0]
label.set_fontproperties('SimSun')

如果你在一个plt显示多个线条,每个线条都设置label后,在最后通过plt.legend()方法显示,在这种情况下,要是中文设置宋体,英文设置Times New Roman,那你呵呵吧,通过set_fontname只会修改整体,而通过set_fontproperties才能对单个label进行修改。具体参考了matplotlib.Text的属性。

Python画图-中使用plt生成的图的legend,设置字体大小 pltpython的plt设置字体大小 阅读详情

相关推荐

R语言绘图进阶:五大工具高效组合多图(cowplot、patchwork、layout、par、gridExtra)

本文详细介绍了R语言中五大高效组合多图的工具:cowplot、patchwork、layout、par和gridExtra。针对不同场景提供了实用指南,帮助数据分析师解决图表排版难题,提升报告专业度。特别推荐cowplot用于ggplot2图形组合,patchwork提供最简洁语法,layout则支持完全自定义布局。

weixin_42544663的博客 288

如何在 Matplotlib 中更改图例字体大小

图例是一个 Matplotlib 函数,用于描述构成图形的元素。plt.show()带有图例的 matplotlib 图在上图中,我们使用legend. upper right“数据”的描述被分配给图例,并使用参数值放置在图表的右上角loc。使用该legend功能,您可以为图形的每一行分配不同的描述。plt.show()具有不同图例描述的两条折线图在上图中,我们使用函数legend来描述图中的每条线。这使得查看图表的任何人都更容易知道图中的蓝线表示age而橙色线表示。number。

分享身边生活经验blog 4613

IAR下载Linux环境适配:入门级安装指导

详细介绍如何在Linux系统中完成iar下载与环境配置,帮助开发者快速上手IAR集成开发环境,解决常见安装问题,提升开发效率。

weixin_35754676的博客 763

matplotlib fig.legend()常用参数 包括位置调整和字体设置等

matplotlib fig.legend()常用参数 包括位置调整和字体设置等

weixin_45913084的博客 6813

在 Coze 平台工作流开发中,使用图生视频大模型需要时间比较长比如5分钟,如何解决工作流运行超时的问题以及等在视频生成以后再向下走

在 Coze 平台工作流开发中,使用图生视频大模型需要时间比较长比如5分钟,如何解决工作流运行超时的问题以及等在视频生成以后再向下走 同步的比较简单,直接在coze 工作流里面就可以搞定了,也不用写代码之类的

AI懒虫 2358

五大经典遥感数据集对比:LoveDA、Potsdam、Toronto、Vaihingen、Massachusetts Roads选哪个?

本文深度对比了LoveDA、Potsdam、Vaihingen、Toronto和Massachusetts Roads五大经典遥感数据集。针对城市监测、道路提取、土地分类等不同任务,从分辨率、标注质量、数据规模及场景多样性等核心维度进行分析,为研究者根据项目目标、硬件条件与应用场景选择最合适的遥感数据集提供决策指南。

weixin_29057065的博客 237

Python matplotlib库绘图时设置标题 (label)、坐标轴 (axis) 和标注 (legend)的字体及大小

文章目录1 标题2 坐标轴3 标注4 示例5 展示6 说明 1 标题 plt.xlabel('False positive rate', fontdict={"family": "Times New Roman", "size": 25}) plt.ylabel('True positive rate', fontdict={"family": "Times New Roman", "size": 25}) 2 坐标轴 plt.xticks(fontname="Times New Roman", font

因吉的博客 3万+

RAG开源框架深度评测:从RAGFlow到Dify的实战选型指南

本文深度评测了主流RAG开源框架(RAGFlow、Dify、WeKnora)的核心能力与实战表现,提供企业级选型指南。重点对比了文档解析、检索性能和生产部署等关键指标,揭示RAGFlow在复杂文档处理、Dify在低代码开发、WeKnora在腾讯生态集成的差异化优势,并给出技术选型决策树与成本优化方案。

weixin_29294597的博客 828

matplotlib legend写tex公式且控制字体

matplotlib legend 写 tex 公式

iTom's blog 8578

数学建模常用模型10 :数据包络(DEA)分析法(投入产出法)

数据包络分析是评价多输入指标和多输出指标的较为有效的方法,将投入与产出进行比较。它的结果包含的意思有: ①θ=1,DEA有效,表示投入与产出比达到最优 ②θ<1,非DEA有效,表示投入与产出比没有达到最优,一般来说,θ越大说明效果越好。 数据包络分析是通过对投入的指标和产出的指标做了一个线性规划,并且进行变换后,然后根据其线性规划的对偶问题(线性规划对偶问题具有经济学意义),求解这个对...

HaLosec_Wei 9万+

【OS】AUTOSAR OS Alarm实现原理

AUTOSAR OS Alarm实现原理

qq_36056498的博客 1023

matplotlib.pyplot.legend()参数详解

matplotlib.pyplot.legend()参数 loc(默认best,自动选择):设置图例位置 upper left(2) upper center(9) upper right(1) center left(6) center(10) center right(7) lower left(3) lower center(8) lower right(4) bbox_to_anchor:设置图例位置 bbox.

Yangyuqing_的博客 1万+

IDEA的使用指南

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

matplotlib.legend函数的用法

plt.legend()函数的作用是给图像加图例。 图例是集中于地图一角或一侧的地图上各种符号和颜色所代表内容与指标的说明,有助于更好的认识地图。 官方手册对该函数的功能进行了详细的介绍 博主对matplotlib中其他函数也有介绍 下面对其中常用的一些功能做简单汇总: 1、设置图例位置:plt.legend(loc=‘xxx’) location string location cod...

humingzhu_97的博客 7万+

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

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

matplotlib的legend参数与设置

以下面代码为例 import matplotlib.pyplot as plt from pylab import mpl mpl.rcParams['font.sans-serif'] = ['SimHei'] # 用来显示中文,不然会乱码 x = range(4) y = [120, 200, 250, 600] plt.bar(x=x, height=y, color='r',...

Mr_blueD的博客 1万+

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

matplotlib之pyplot模块之图例(legend)基础(legend()的调用方式,图例外观设置)

matplotlib可以为可见对象(Artist,比如线条、形状)添加图例(legend)。官方建议使用pyplot模块的legend函数简便的创建图例,而不是使用底层的matplotlib.legend类构造图例。 函数签名为matplotlib.pyplot.legend(*args, **kwargs) legend()基本应用演示 使用图例的基础有两个: handles:可见对象(Artist,比如线条、形状)序列,与labels配合使用。 labels:类型为字符串列表,即图例中显示的文本集合。

mighty13的专栏 9万+

Python matplotlib修改默认字体

Python matplotlib修改默认字体 matplotlib库作为Python常用的数据可视化库,默认字体居然不支持中文字体,必须得吐槽一下~ 闲言少叙,开始正文 方法1:在plot中指定prop参数 使用matplotlib.font_manager下的FontProperties加载中文字体 调用函数时通过prop属性指定中文字体 import matplotlib.pyplot...

mp9105的博客 1万+

python - matplotlib.legend()函数用法解析

1.图例legend基础语法及用法 legend语法参数如下: matplotlib.pyplot.legend(*args,**kwargs) Keyword Description loc Location code string, or tuple (see below).图例所有figure位置 prop the font property字体参数 fontsize ...

云中寻雾的博客 1万+

【Matplotlib】plt.legend() 函数:添加图例(Legend)

matplotlib.pyplot.legend()用于为图表添加图例,适用于区分不同数据系列,提高可读性。-plt.legend()用于添加图例,支持位置、字体、标题等调整。-常见参数loc="upperright"调整位置,fontsize=12修改字体,frameon=False隐藏边框。

彬彬侠的博客 6105

Python:plt.legend或者ax.legend设置图例的参数详解

                plt.legend或者ax.legend设置图例的参数详解 #显示图例 # box = ax.get_position() # ax.set_position([box.x0, box.y0, box.wi...

缘来如此 11万+

matlab修改图片的坐标轴和legend以及title的字体样式

对于存好的matlab图片,在不跑代码的情况下,想要修改一下它的字体样式,汉字为宋体,英文或者数字为Times new roman。

m0_48167446的博客 3389

plt.legend()的几种用法

** plt.legend()的几种用法 ** (1)设置图列位置 ```python plt.legend(loc=' ') ![](https://img-blog.csdnimg.cn/20200830165252486.png#pic_center) **(2)设置图例字体大小** ```python fontsize : int or float or {‘xx-small’, ‘x-small’, ‘small’, ‘medium’, ‘large’, ‘x-large’, ‘xx-la

初学Python 10万+

Matplotlib:Legend 图例

添加图例 调整位置和名称 添加图例: x = np.linspace(-3, 3, 50) y1 = 2*x + 1 y2 = x**2 plt.figure() #set x limits plt.xlim((-1, 2)) plt.ylim((-2, 3)) # set new sticks new_sticks = np.linspace(-1, 2, 5) plt.xticks(n...

错位的梦寐的博客 4342

python中legend设置_如何使用python legend()函数?

当我们需要去设置一个图示,并且在细节掌控上需要我们对于背景的颜色,以及边框颜色等属性,需要去做处理的时候,一般大家想到的模块或者函数都只能解决部分。结合起来可以完成上述所说的要求,但是有一个函数是专门为制定个性化的图例而工作的,这就是本章要跟大家介绍的legend()函数。函数功能:设置图例的字体、大小、颜色等属性,制定个性化。函数语法:plt.legend()函数参数:Loc,指代地理位置实例代...

weixin_39906130的博客 1万+

python 之利用plt.legend()添加图例

python 之利用plt.legend()添加图例

牛牛博士博客 1万+
上一篇: 中文期刊matplotlib论文插图格式
下一篇: word去掉万恶的域代码
沉思的雅典娜
博客等级 码龄15年 16粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值