【Python】matplotlib绘图教程

1 自定义绘图风格文件

1.1 编写格式参考

  1. matplotlib自带配置文件,其路径为:~\Anaconda3\envs\Python37\Lib\site-packages\matplotlib\mpl-data\matplotlibrc
  2. matplotlib自带风格文件(如:ggplot, seaborn-colorblind, seaborn-poster等),其路径为:~\Anaconda3\envs\Python37\Lib\site-packages\matplotlib\mpl-data\stylelib

1.2 绘图风格文件

1.2.1 Robert-paper.mplstyle

文件名称:Robert-paper.mplstyle
风格名称:Robert-paper
文件内容:

## Color format
# scalar grayscale intensity: range is 0 to 1, 0 is black
# matplotlib color string, such as r, k, or b
# rgb tuple, such as (1.0, 0.5, 0.0)
# hex string, such as ff00ff (Fuchsia/Magenta). Each two characters represent the values of R, G and B.
# legal html color name, e.g., red, blue, darkslategray

## Fontsize
# Special text sizes can be defined relative to font.size, using the following values: xx-small, x-small, small, medium, large, x-large, xx-large, larger, or smaller

# Lines properties
lines.linewidth: 1.5
lines.markersize: 7
lines.markeredgewidth: 0
lines.solid_capstyle: round  # butt|round|projecting

# Text properties
font.family: sans-serif
font.sans-serif: SimHei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, sans-serif
font.size: 10.0
text.color: 0

# Axes properties
axes.unicode_minus: False  # If True, use unicode for the minus symbol rather than hyphen. Setting it as False can solve the problem that minus can't display in figure.
axes.facecolor: white
axes.edgecolor: black
axes.linewidth: 1
axes.titlesize: x-large
axes.labelsize: large
axes.labelcolor: 0
axes.axisbelow: True  # grid/ticks are below elements (e.g., lines, text)

axes.prop_cycle: cycler('color', ['D62728', '1F77B4', 'FF7F0E', '2CA02C', 'BCBD22', '9467BD', '8C564B', '777777', '000000', 'E24A33', '348ABD', '8EBA42', 'FBC15E', 'FFB5B8', '988ED5', '17BECF'])
                   # D62728 : red
                   # 1F77B4 : marine blue
                   # FF7F0E : light orange
                   # 2CA02C : forestgreen
                   # BCBD22 : green yellow
                   # 9467BD : medium purple
                   # 8C564B : sienna
                   # 777777 : gray
                   # 000000 : black
                   # E24A33 : orangered
                   # 348ABD : blue
                   # 8EBA42 : green
                   # FBC15E : earthy yellow
                   # FFB5B8 : pink
                   # 988ED5 : lilac
                   # 17BECF : cyan

xtick.color: 0
xtick.direction: in
xtick.labelsize: 10  # fontsize of the tick labels
xtick.major.pad: 3.5  # distance to major tick label in points
xtick.minor.pad: 3.5  # distance to the minor tick label in points
xtick.major.size: 3.5  # major tick size in points
xtick.minor.size: 2  # minor tick size in points
xtick.major.width: 0.8  # major tick width in points
xtick.minor.width: 0.6  # minor tick width in points


ytick.color: 0
ytick.direction: in
ytick.labelsize: 10  # fontsize of the tick labels
ytick.major.pad:
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值