matplotlib图表的样式
网格线
matplotlib.pyplot.grid(b=None, which='major', axis='both', )
- b:可选,默认为 None,可以设置布尔值,true 为显示网格线,false 为不显示,如果设置 **kwargs 参数,则值为 true。
- which:可选,可选值有 ‘major’、‘minor’ 和 ‘both’,默认为 ‘major’,表示应用更改的网格线。
- axis:可选,设置显示哪个方向的网格线,可以是取 ‘both’(默认),‘x’ 或 ‘y’,分别表示两个方向,x 轴方向或 y 轴方向。
- **kwargs:可选,设置网格样式,可以是 color=‘r’, linestyle=‘-’ 和 linewidth=2,分别表示网格线的颜色,样式和宽度。
设置字体及字体颜色
plt.rcParams['font.family'] = "SimSun" # 字体
plt.rcParams['font.size'] = 60 # 字体大小
plt.rcParams[‘font.sans-serif’]=[‘SimHei’]#显示中文标签
显示正负号
plt.rcParams[‘axes.unicode_minus’]=False
设置背景
非绘图区背景
fig.patch.set_facecolor('lightskyblue')
fig.patch.set_alpha(0.6) # set_alpha用于指定透明度
设置背景图片:
if __name__ == '__main__':fig = plt.figure(figsize=(16, 8))bgimg = img.imread('./world.png')fig.figimage(bgimg)pltfig(fig)plt.show()
绘图区背景
在ax中设定颜色
ax.patch.set_facecolor('greenyellow')
设置背景图片:
img = plt.imread("哆啦A梦.jpg")
fig,ax = plt.subplots()
ax.imshow(img)
ax.patch.set_alpha(0.0) 绘图本身的背景现在是透明的。
字体
黑体:SimHei
微软雅黑:Microsoft YaHei
微软正黑体:Microsoft JhengHei
新宋体:NSimSun
新细明体:PMingLiU
细明体:MingLiU
华文新魏:STXinwei
华文行楷:STXingkai
华文隶书:STLliti
花纹琥珀:STHupo
华文彩云:STCaiyun
方正姚体:FZYaoti
方正舒体:FZShuTi
标楷体:DFKai-SB
华文仿宋:STFangsong
华文中宋:STZhongsong
华文宋体:STSong
华文楷体:STKaiti
华文细黑:STXihei
幼圆:YouYuan
隶书:LiSu
楷体_GB 2313:Kaiti_GB2313
仿宋_GB2313:FangSong_GB2313
仿宋:FangSong
rcParams
pyplot使用rcParams来自定义图形的各种默认属性,称之为运行配置参数。通过更改参数可以修改默认的属性,包括窗体大小、每英寸的点数、线条宽度、颜色、样式、坐标轴、坐标和网络属性、文本、字体等。
- _internal.classic_mode
- agg.path.chunksize
- animation.bitrate
- animation.codec
- animation.convert_args
- animation.convert_path
- animation.embed_limit
- animation.ffmpeg_args
- animation.ffmpeg_path
- animation.frame_format
- animation.html
- animation.writer
- axes.autolimit_mode
- axes.axisbelow
- axes.edgecolor
- axes.facecolor
- axes.formatter.limits
- axes.formatter.min_exponent
- axes.formatter.offset_threshold
- axes.formatter.use_locale
- axes.formatter.use_mathtext
- axes.formatter.useoffset
- axes.grid
- axes.grid.axis
- axes.grid.which
- axes.labelcolor
- axes.labelpad
- axes.labelsize
- axes.labelweight
- axes.linewidth
- axes.prop_cycle
- axes.spines.bottom
- axes.spines.left
- axes.spines.right
- axes.spines.top
- axes.titlecolor
- axes.titlelocation
- axes.titlepad
- axes.titlesize
- axes.titleweight
- axes.titley
- axes.unicode_minus
- axes.xmargin
- axes.ymargin
- axes.zmargin
- axes3d.grid
- backend
- backend_fallback
- boxplot.bootstrap
- boxplot.boxprops.color
- boxplot.boxprops.linestyle
- boxplot.boxprops.linewidth
- boxplot.capprops.color
- boxplot.capprops.linestyle
- boxplot.capprops.linewidth
- boxplot.flierprops.color
- boxplot.flierprops.linestyle
- boxplot.flierprops.linewidth
- boxplot.flierprops.marker
- boxplot.flierprops.markeredgecolor
- boxplot.flierprops.markeredgewidth
- boxplot.flierprops.markerfacecolor
- boxplot.flierprops.markersize
- boxplot.meanline
- boxplot.meanprops.color
- boxplot.meanprops.linestyle
- boxplot.meanprops.linewidth
- boxplot.meanprops.marker
- boxplot.meanprops.markeredgecolor
- boxplot.meanprops.markerfacecolor
- boxplot.meanprops.markersize
- boxplot.medianprops.color
- boxplot.medianprops.linestyle
- boxplot.medianprops.linewidth
- boxplot.notch
- boxplot.patchartist
- boxplot.showbox
- boxplot.showcaps
- boxplot.showfliers
- boxplot.showmeans
- boxplot.vertical
- boxplot.whiskerprops.color
- boxplot.whiskerprops.linestyle
- boxplot.whiskerprops.linewidth
- boxplot.whiskers
- contour.corner_mask
- contour.linewidth
- contour.negative_linestyle
- date.autoformatter.day
- date.autoformatter.hour
- date.autoformatter.microsecond
- date.autoformatter.minute
- date.autoformatter.month
- date.autoformatter.second
- date.autoformatter.year
- date.converter
- date.epoch
- date.interval_multiples
- docstring.hardcopy
- errorbar.capsize
- figure.autolayout
- figure.constrained_layout.h_pad
- figure.constrained_layout.hspace
- figure.constrained_layout.use
- figure.constrained_layout.w_pad
- figure.constrained_layout.wspace
- figure.dpi
- figure.edgecolor
- figure.facecolor
- figure.figsize
- figure.frameon
- figure.max_open_warning
- figure.raise_window
- figure.subplot.bottom
- figure.subplot.hspace
- figure.subplot.left
- figure.subplot.right
- figure.subplot.top
- figure.subplot.wspace
- figure.titlesize
- figure.titleweight
- font.cursive
- font.family
- font.fantasy
- font.monospace
- font.sans-serif
- font.serif
- font.size
- font.stretch
- font.style
- font.variant
- font.weight
- grid.alpha
- grid.color
- grid.linestyle
- grid.linewidth
- hatch.color
- hatch.linewidth
- hist.bins
- image.aspect
- image.cmap
- image.composite_image
- image.interpolation
- image.lut
- image.origin
- image.resample
- interactive
- keymap.back
- keymap.copy
- keymap.forward
- keymap.fullscreen
- keymap.grid
- keymap.grid_minor
- keymap.help
- keymap.home
- keymap.pan
- keymap.quit
- keymap.quit_all
- keymap.save
- keymap.xscale
- keymap.yscale
- keymap.zoom
- legend.borderaxespad
- legend.borderpad
- legend.columnspacing
- legend.edgecolor
- legend.facecolor
- legend.fancybox
- legend.fontsize
- legend.framealpha
- legend.frameon
- legend.handleheight
- legend.handlelength
- legend.handletextpad
- legend.labelcolor
- legend.labelspacing
- legend.loc
- legend.markerscale
- legend.numpoints
- legend.scatterpoints
- legend.shadow
- legend.title_fontsize
- lines.antialiased
- lines.color
- lines.dash_capstyle
- lines.dash_joinstyle
- lines.dashdot_pattern
- lines.dashed_pattern
- lines.dotted_pattern
- lines.linestyle
- lines.linewidth
- lines.marker
- lines.markeredgecolor
- lines.markeredgewidth
- lines.markerfacecolor
- lines.markersize
- lines.scale_dashes
- lines.solid_capstyle
- lines.solid_joinstyle
- markers.fillstyle
- mathtext.bf
- mathtext.cal
- mathtext.default
- mathtext.fallback
- mathtext.fontset
- mathtext.it
- mathtext.rm
- mathtext.sf
- mathtext.tt
- patch.antialiased
- patch.edgecolor
- patch.facecolor
- patch.force_edgecolor
- patch.linewidth
- path.effects
- path.simplify
- path.simplify_threshold
- path.sketch
- path.snap
- pcolor.shading
- pcolormesh.snap
- pdf.compression
- pdf.fonttype
- pdf.inheritcolor
- pdf.use14corefonts
- pgf.preamble
- pgf.rcfonts
- pgf.texsystem
- polaraxes.grid
- ps.distiller.res
- ps.fonttype
- ps.papersize
- ps.useafm
- ps.usedistiller
- savefig.bbox
- savefig.directory
- savefig.dpi
- savefig.edgecolor
- savefig.facecolor
- savefig.format
- savefig.orientation
- savefig.pad_inches
- savefig.transparent
- scatter.edgecolors
- scatter.marker
- svg.fonttype
- svg.hashsalt
- svg.image_inline
- text.antialiased
- text.color
- text.hinting
- text.hinting_factor
- text.kerning_factor
- text.latex.preamble
- text.usetex
- timezone
- tk.window_focus
- toolbar
- webagg.address
- webagg.open_in_browser
- webagg.port
- webagg.port_retries
- xaxis.labellocation
- xtick.alignment
- xtick.bottom
- xtick.color
- xtick.direction
- xtick.labelbottom
- xtick.labelcolor
- xtick.labelsize
- xtick.labeltop
- xtick.major.bottom
- xtick.major.pad
- xtick.major.size
- xtick.major.top
- xtick.major.width
- xtick.minor.bottom
- xtick.minor.pad
- xtick.minor.size
- xtick.minor.top
- xtick.minor.visible
- xtick.minor.width
- xtick.top
- yaxis.labellocation
- ytick.alignment
- ytick.color
- ytick.direction
- ytick.labelcolor
- ytick.labelleft
- ytick.labelright
- ytick.labelsize
- ytick.left
- ytick.major.left
- ytick.major.pad
- ytick.major.right
- ytick.major.size
- ytick.major.width
- ytick.minor.left
- ytick.minor.pad
- ytick.minor.right
- ytick.minor.size
- ytick.minor.visible
- ytick.minor.width
- ytick.right
matplotlib图表的样式相关推荐
- 一行代码让matplotlib图表变高大上
1 简介 matplotlib作为Python生态中最流行的数据可视化框架,虽然功能非常强大,但默认样式比较简陋,想要制作具有简洁商务风格的图表往往需要编写众多的代码来调整各种参数. 而今天要为大家介 ...
- 【Python】科研论文绘图实操干货汇总,11类Matplotlib图表,含代码
作者丨数据派THU 来源丨DataScience 编辑丨极市平台 导读 Matplotlib 是一个 Python 的 2D绘图库,它以各种硬拷贝格式和跨平台的交互式环境生成出版质量级别的图形.通过 ...
- 超全万字汇总!科研论文绘图实操干货!11类Matplotlib图表,含代码
点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 导读 Matplotlib 是一个 Python 的 2D绘图库, ...
- 科研论文绘图实操干货汇总,11类Matplotlib图表,含代码
作者丨数据派THU 来源丨DataScience 编辑丨极市平台 导读 Matplotlib 是一个 Python 的 2D绘图库,它以各种硬拷贝格式和跨平台的交互式环境生成出版质量级别的图形.通过 ...
- python生成柱状图 不显示_python – Matplotlib图表不显示在PyCharm中
我在PyCharm 3.4.1中运行以下代码,并突出显示%matplotlib内联显示语法错误,我删除第一行,并运行,我希望它会提示我一些图表,但它运行正常与Process完成退出代码0,没有图表显示 ...
- 用 Python 将 matplotlib 图表集成到 PDF 中
介绍 PDF 格式是与平台无关,它独立于底层操作系统和渲染引擎.事实上,PDF 是基于一种脚本语言--PostScript,它是第一个独立于设备的页面描述语言. 在本指南中,我们将使用 borb -- ...
- python做动态折线图_python matplotlib折线图样式实现过程
python matplotlib 同时画箱线图和折线图的问题 python3 matplotlib画两个折线图,X轴相同,Y轴生...你的memo和cpui里面是字符串,不是数字 将memo.app ...
- matplotlib的绘图样式与色彩设置
绘图样式与色彩设置目录 一.matplotlib的绘图样式(style) 1.matplotlib预先定义样式 2.用户自定义stylesheet 3.设置rcparams 4.修改matplotli ...
- matplotlib图表介绍
Matplotlib 是一个python 的绘图库,主要用于生成2D图表. 常用到的是matplotlib中的pyplot,导入方式import matplotlib.pyplot as plt 一. ...
最新文章
- Linux内核系统时钟管理 感想总结 (未完待续)
- Metasploit save命令技巧
- java内部类文件,Java内部类学习
- 36套java精品高级课_Dubbo-ZooKeeper“走一波”
- 重构手法——提炼函数、搬移函数、以多态取代条件表达式
- 云图说|ROMA演进史:一个ROMA与应用之间不得不说的故事
- 内置函数dict()字典
- 全国一级计算机基础及ps题目,一级计算机基础及Photoshop应用模拟试题(14)
- for循环中的setTimeout()
- sql2000海量存储过程(1500w数据,分页只需1秒)
- android游戏手柄开发,android游戏手柄开发测试代码
- 0基础学RS(十三)思科交换机上的Access模式和trunk模式以及配置
- 一文搞定学术英语写作 (斯坦福SCI论文写作课程笔记)
- 贵州大数据声势已起 如何引进人才?
- 字长是指计算机什么之间,字长是指计算机()之间一次能够传递的数据位,位宽是CPU通过外据总线与()之 - 问答库...
- 古代情感诗词top100
- MIPS递归:斐波那契数列
- 转载:word2019写公式序号
- java 修饰符 详解,详解Java修饰符
- HMM-前向后向算法