Python可视化:python画图字体设置

Python可视化:图中字体设置

  • Python可视化:图中字体设置
    • 首先来简单的画一个散点图
    • 设置图中的字体的两种方法
      • 用`font`字典的形式来设置
      • 用`fontproperties`参数来设置
    • 可选字体名称集合
    • 可选字体格式集合
    • `legend()`函数详细参数
    • `scatter()`函数详细参数

Python可视化:图中字体设置

Python用于绘图还是非常方便的,利用matplotlib,可以实现很多的绘图需求,当然,如果想要一些自动设置的比较美观的图形默认设置,可以用sebornhttp://seaborn.pydata.org/,或者pyecharthttps://echarts.apache.org/examples/zh/index.html#chart-type-map

这里我们主要总结一下matplotlib中绘图时候的字体设置。

首先来简单的画一个散点图

import matplotlib.pyplot as plt 
import numpy as np
x = 10 * np.random.rand(10)
y = 10 * np.random.rand(10) 

'''
x = 
array([7.34208212, 6.14229141, 6.99898899, 5.10833595, 7.66301418,
       3.84463225, 2.97255304, 5.54680296, 2.07965563, 2.72611992])
'''

plt.scatter(x, y, marker='o', c='red', label='customer')
plt.legend() 
plt.show() 

结果如下:
Python可视化:python画图字体设置_第1张图片
这里我们并没有改变图例legend的字体,所以是默认字体。假如我们想要改成Arial字体,加粗,应该怎么做呢?首先来看一下scatter()函数的详细参数

plt.scatter(
    x,					# x 坐标
    y,					# y 坐标
    s=None,				# The marker size in points**2
    c=None,				# color of nodes 
    marker=None,		# The marker style
    cmap=None,			# Colormap
    norm=None,			# Normalize
    vmin=None,			# 
    vmax=None,			# 
    alpha=None,			# 
    linewidths=None,	# The linewidth of the marker edges
    verts=None,			# 
    edgecolors=None,	# The edge color of the marker
    *,
    plotnonfinite=False,
    data=None,
    **kwargs,
)

设置图中的字体的两种方法

font字典的形式来设置

我们再来看一下legend的参数,legend()函数有一个参数为prop,解释如下

prop : None or :class:matplotlib.font_manager.FontProperties or dict
The font properties of the legend. If None (default), the current
:data:matplotlib.rcParams will be used.

我们利用下面的代码,来设置图例legend的字体,代码如下

# 用这个来修改legend的字体,也可以用plt.rcParams['font.sans-serif']=['Arial']的方法,都可以
font = {'family':'Arial'  #'serif', 
#         ,'style':'italic'
        ,'weight':'bold'  # 'normal' 
#         ,'color':'red'
        ,'size':20
       }
# 注解边界的默认设置就是(x0,y0,width,height)=(0,0,1,1).
# 左边,右边,顶边,底边
# 对于四个元素的bbox_to_anchor(),也就是(x, y, width, height),情况就和上面两个元素的有所不同了。我们通过图来展示,会更清楚一点。
# https://blog.csdn.net/chichoxian/article/details/101058046
# https://blog.csdn.net/sinat_41299610/article/details/106494549?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param
plt.legend(loc = 'upper left'   # 就是指legend的box的左上角坐标是(0.1, 0.3) 
           , bbox_to_anchor=(0.05, 0.9)   # (x, y, width, height) (0, 0.5, 0.5, 0.5)
           , prop = font
           , markerscale = 2 # legend里面的符号的大小
          ) 

运行结果如下:
Python可视化:python画图字体设置_第2张图片

fontproperties参数来设置

设置横坐标和纵坐标坐标轴标题xlabelylabel的时候,可以用fontproperties这个参数来设置字体,如下面的代码

import numpy as np
x = 10 * np.random.rand(10)
y = 10 * np.random.rand(10) 

'''
x = 
array([7.34208212, 6.14229141, 6.99898899, 5.10833595, 7.66301418,
       3.84463225, 2.97255304, 5.54680296, 2.07965563, 2.72611992])
'''

plt.scatter(x, y, marker='o', c='red', label='customer')

plt.xlabel("$x$ coor",fontproperties="STLiti")
plt.ylabel("$y$ $m^2$",fontproperties="STXingkai")
plt.title("$y = x$",fontproperties="STXinwei")
 

# 用这个来修改legend的字体,也可以用plt.rcParams['font.sans-serif']=['Arial']的方法,都可以
font = {'family':'Arial'  #'serif', 
#         ,'style':'italic'
        ,'weight':'normal'
#         ,'color':'red'
        ,'size':20
       }

plt.legend(loc = 'upper left'   # 就是指legend的box的左上角坐标是(0.1, 0.3) 
           , bbox_to_anchor=(0.05, 0.9)   # (x, y, width, height) (0, 0.5, 0.5, 0.5)
           , prop = font
           , markerscale = 2 # legend里面的符号的大小
          ) 
# plt.legend(loc = 'upper left', fontsize = 20)  

plt.show() 

注意,坐标轴标题还支持LaTeX语法,比如在坐标轴上输入公式等的,都是可以的。

可选字体名称集合

我们可以通过输出matplotlib.font_manager.fontManager.ttflist中的字体来查看都可以设置哪些可选字体。

import matplotlib 
a = sorted([f.name for f in matplotlib.font_manager.fontManager.ttflist])
previous_font = '   '
count = 0 
for font_name in a:
    if(font_name != previous_font):
        count = count + 1  
#         print(font_name, '\t\t\t\t', end='')
        if(count > 2): 
            print('{:35}'.format(font_name), end='') 
        if(count % 4 == 0):
            print()
        previous_font = font_name

结果如下,也就是可以设置的字体可选集合

Adobe Devanagari                   Agency FB                          
Algerian                           Arial                              Arial Rounded MT Bold              Arial Unicode MS                   
Baskerville Old Face               Bauhaus 93                         Bell MT                            Berlin Sans FB                     
Berlin Sans FB Demi                Bernard MT Condensed               Blackadder ITC                     Bodoni MT                          
Book Antiqua                       Bookman Old Style                  Bookshelf Symbol 7                 Bradley Hand ITC                   
Britannic Bold                     Broadway                           Brush Script MT                    Calibri                            
Californian FB                     Calisto MT                         Cambria                            Candara                            
Castellar                          Centaur                            Century                            Century Gothic                     
Century Schoolbook                 Chiller                            Colonna MT                         Comic Sans MS                      
Consolas                           Constantia                         Cooper Black                       Copperplate Gothic Bold            
Copperplate Gothic Light           Corbel                             Courier New                        Curlz MT                           
DejaVu Sans                        DejaVu Sans Display                DejaVu Sans Mono                   DejaVu Serif                       
DejaVu Serif Display               DengXian                           ESRI AMFM Electric                 ESRI AMFM Gas                      
ESRI AMFM Sewer                    ESRI AMFM Water                    ESRI ArcPad                        ESRI Arrowhead                     
ESRI Business                      ESRI Cartography                   ESRI Caves 1                       ESRI Caves 2                       
ESRI Caves 3                       ESRI Climate & Precipitation       ESRI Commodities                   ESRI Conservation                  
ESRI Crime Analysis                ESRI Default Marker                ESRI Dimensioning                  ESRI ERS Infrastructures S1        
ESRI ERS Operations S1             ESRI Elements                      ESRI Enviro Hazard Analysis        ESRI Enviro Hazard Incident        
ESRI Enviro Hazard Sites           ESRI Environmental & Icons         ESRI Fire Incident NFPA            ESRI Geology                       
ESRI Geology AGSO 1                ESRI Geology USGS 95-525           ESRI Geometric Symbols             ESRI Hazardous Materials           
ESRI Hydrants                      ESRI IGL Font16                    ESRI IGL Font20                    ESRI IGL Font21                    
ESRI IGL Font22                    ESRI IGL Font23                    ESRI IGL Font24                    ESRI IGL Font25                    
ESRI Meteorological 01             ESRI Mil2525C Modifiers            ESRI MilMod 01                     ESRI MilMod 02                     
ESRI MilRed 01                     ESRI MilSym 01                     ESRI MilSym 02                     ESRI MilSym 03                     
ESRI MilSym 04                     ESRI MilSym 05                     ESRI NIMA City Graphic LN          ESRI NIMA City Graphic PT          
ESRI NIMA DNC LN                   ESRI NIMA DNC PT                   ESRI NIMA VMAP1&2 LN               ESRI NIMA VMAP1&2 PT               
ESRI North                         ESRI Oil, Gas, & Water             ESRI Ordnance Survey               ESRI Pipeline US 1                 
ESRI Public1                       ESRI SDS 1.95 1                    ESRI SDS 1.95 2                    ESRI SDS 2.00 1                    
ESRI SDS 2.00 2                    ESRI Shields                       ESRI Surveyor                      ESRI Telecom                       
ESRI Transportation & Civic        ESRI US Forestry 1                 ESRI US Forestry 2                 ESRI US MUTCD 1                    
ESRI US MUTCD 2                    ESRI US MUTCD 3                    ESRI Weather                       Ebrima                             
Edwardian Script ITC               Elephant                           Engravers MT                       Eras Bold ITC                      
Eras Demi ITC                      Eras Light ITC                     Eras Medium ITC                    Euclid                             
Euclid Extra                       Euclid Fraktur                     Euclid Math One                    Euclid Math Two                    
Euclid Symbol                      FZCuHeiSongS-B-GB                  FZLanTingHeiS-UL-GB                FZShuTi                            
FZYaoTi                            FangSong                           Felix Titling                      Fences                             
Footlight MT Light                 Forte                              Franklin Gothic Book               Franklin Gothic Demi               
Franklin Gothic Demi Cond          Franklin Gothic Heavy              Franklin Gothic Medium             Franklin Gothic Medium Cond        
Freestyle Script                   French Script MT                   Gabriola                           Gadugi                             
Garamond                           Georgia                            Gigi                               Gill Sans MT                       
Gill Sans MT Condensed             Gill Sans MT Ext Condensed Bold    Gill Sans Ultra Bold               Gill Sans Ultra Bold Condensed     
Gloucester MT Extra Condensed      Goudy Old Style                    Goudy Stout                        Haettenschweiler                   
Harlow Solid Italic                Harrington                         High Tower Text                    HoloLens MDL2 Assets               
Impact                             Imprint MT Shadow                  Informal Roman                     Javanese Text                      
Jokerman                           Juice ITC                          KaiTi                              Kristen ITC                        
Kunstler Script                    Leelawadee                         Leelawadee UI                      LiSu                               
Lucida Bright                      Lucida Calligraphy                 Lucida Console                     Lucida Fax                         
Lucida Handwriting                 Lucida Sans                        Lucida Sans Typewriter             Lucida Sans Unicode                
MS Gothic                          MS Outlook                         MS Reference Sans Serif            MS Reference Specialty             
MT Extra                           MT Extra Tiger                     MV Boli                            Magneto                            
Maiandra GD                        Malgun Gothic                      Marlett                            Matura MT Script Capitals          
Meiryo                             Microsoft Himalaya                 Microsoft JhengHei                 Microsoft MHei                     
Microsoft NeoGothic                Microsoft New Tai Lue              Microsoft PhagsPa                  Microsoft Sans Serif               
Microsoft Tai Le                   Microsoft Uighur                   Microsoft YaHei                    Microsoft Yi Baiti                 
MingLiU-ExtB                       Mistral                            Modern No. 20                      Mongolian Baiti                    
Monotype Corsiva                   Myanmar Text                       Niagara Engraved                   Niagara Solid                      
Nirmala UI                         NumberOnly                         OCR A Extended                     Old English Text MT                
Onyx                               OriginGISSymbols                   Palace Script MT                   Palatino Linotype                  
Papyrus                            Parchment                          Perpetua                           Perpetua Titling MT                
Playbill                           Poor Richard                       Pristina                           Rage Italic                        
Ravie                              Rockwell                           Rockwell Condensed                 Rockwell Extra Bold                
STCaiyun                           STFangsong                         STHupo                             STIXGeneral                        
STIXNonUnicode                     STIXSizeFiveSym                    STIXSizeFourSym                    STIXSizeOneSym                     
STIXSizeThreeSym                   STIXSizeTwoSym                     STKaiti                            STLiti                             
STSong                             STXihei                            STXingkai                          STXinwei                           
STZhongsong                        Script MT Bold                     Segoe MDL2 Assets                  Segoe Print                        
Segoe Script                       Segoe UI                           Segoe UI Emoji                     Segoe UI Historic                  
Segoe UI Symbol                    Segoe WP                           Showcard Gothic                    SimHei                             
SimSun                             SimSun-ExtB                        Sitka Small                        Snap ITC                           
Stencil                            Sylfaen                            Symbol                             Symbol Tiger                       
Symbol Tiger Expert                Tahoma                             Tempus Sans ITC                    Tiger                              
Tiger Expert                       Times New Roman                    Trebuchet MS                       Tw Cen MT                          
Tw Cen MT Condensed                Tw Cen MT Condensed Extra Bold     Verdana                            Viner Hand ITC                     
Vivaldi                            Vladimir Script                    Webdings                           Wide Latin                         
Wingdings                          Wingdings 2                        Wingdings 3                        YouYuan                            
Yu Gothic                          ZWAdobeF                           cmb10                              cmex10                             
cmmi10                             cmr10                              cmss10                             cmsy10                             
cmtt10                             hakuyoxingshu7000                  icomoon  

如果只需要中文字体,那么可以选择:
中文字体部分该部分转载自https://blog.csdn.net/qq_17753903/article/details/86260276?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param

字体 字体名
黑体 SimHei
楷体 KaiTi
隶书 LiSu
幼圆 YouYuan
华文细黑 STXihei
华文楷体 STKaiti
华文宋体 STSong
华文中宋 STZhongsong
华文仿宋 STFangsong
方正舒体 FZShuTi
方正姚体 FZYaoti
华文彩云 STCaiyun
华文琥珀 STHupo
华文隶书 STLiti
华文行楷 STXingkai
华文新魏 STXinwei

可选字体格式集合

字体的格式可以设置为

  1. normal
  2. bold
  3. italic
    等,根据自己的喜好进行设置即可。

legend()函数详细参数

Signature: plt.legend(*args, **kwargs)
Docstring:
Place a legend on the axes.

Call signatures::

    legend()
    legend(labels)
    legend(handles, labels)

The call signatures correspond to three different ways how to use
this method.

**1. Automatic detection of elements to be shown in the legend**

The elements to be added to the legend are automatically determined,
when you do not pass in any extra arguments.

In this case, the labels are taken from the artist. You can specify
them either at artist creation or by calling the
:meth:`~.Artist.set_label` method on the artist::

    line, = ax.plot([1, 2, 3], label='Inline label')
    ax.legend()

or::

    line, = ax.plot([1, 2, 3])
    line.set_label('Label via method')
    ax.legend()

Specific lines can be excluded from the automatic legend element
selection by defining a label starting with an underscore.
This is default for all artists, so calling `Axes.legend` without
any arguments and without setting the labels manually will result in
no legend being drawn.


**2. Labeling existing plot elements**

To make a legend for lines which already exist on the axes
(via plot for instance), simply call this function with an iterable
of strings, one for each legend item. For example::

    ax.plot([1, 2, 3])
    ax.legend(['A simple line'])

Note: This way of using is discouraged, because the relation between
plot elements and labels is only implicit by their order and can
easily be mixed up.


**3. Explicitly defining the elements in the legend**

For full control of which artists have a legend entry, it is possible
to pass an iterable of legend artists followed by an iterable of
legend labels respectively::

    legend((line1, line2, line3), ('label1', 'label2', 'label3'))

Parameters
----------

handles : sequence of `.Artist`, optional
    A list of Artists (lines, patches) to be added to the legend.
    Use this together with *labels*, if you need full control on what
    is shown in the legend and the automatic mechanism described above
    is not sufficient.

    The length of handles and labels should be the same in this
    case. If they are not, they are truncated to the smaller length.

labels : sequence of strings, optional
    A list of labels to show next to the artists.
    Use this together with *handles*, if you need full control on what
    is shown in the legend and the automatic mechanism described above
    is not sufficient.

Other Parameters
----------------


loc : str or pair of floats, default: :rc:`legend.loc` ('best' for axes, 'upper right' for figures)
    The location of the legend.

    The strings
    ``'upper left', 'upper right', 'lower left', 'lower right'``
    place the legend at the corresponding corner of the axes/figure.

    The strings
    ``'upper center', 'lower center', 'center left', 'center right'``
    place the legend at the center of the corresponding edge of the
    axes/figure.

    The string ``'center'`` places the legend at the center of the axes/figure.

    The string ``'best'`` places the legend at the location, among the nine
    locations defined so far, with the minimum overlap with other drawn
    artists.  This option can be quite slow for plots with large amounts of
    data; your plotting speed may benefit from providing a specific location.

    The location can also be a 2-tuple giving the coordinates of the lower-left
    corner of the legend in axes coordinates (in which case *bbox_to_anchor*
    will be ignored).

    For back-compatibility, ``'center right'`` (but no other location) can also
    be spelled ``'right'``, and each "string" locations can also be given as a
    numeric value:

        ===============   =============
        Location String   Location Code
        ===============   =============
        'best'            0
        'upper right'     1
        'upper left'      2
        'lower left'      3
        'lower right'     4
        'right'           5
        'center left'     6
        'center right'    7
        'lower center'    8
        'upper center'    9
        'center'          10
        ===============   =============

bbox_to_anchor : `.BboxBase`, 2-tuple, or 4-tuple of floats
    Box that is used to position the legend in conjunction with *loc*.
    Defaults to `axes.bbox` (if called as a method to `.Axes.legend`) or
    `figure.bbox` (if `.Figure.legend`).  This argument allows arbitrary
    placement of the legend.

    Bbox coordinates are interpreted in the coordinate system given by
    `bbox_transform`, with the default transform
    Axes or Figure coordinates, depending on which ``legend`` is called.

    If a 4-tuple or `.BboxBase` is given, then it specifies the bbox
    ``(x, y, width, height)`` that the legend is placed in.
    To put the legend in the best location in the bottom right
    quadrant of the axes (or figure)::

        loc='best', bbox_to_anchor=(0.5, 0., 0.5, 0.5)

    A 2-tuple ``(x, y)`` places the corner of the legend specified by *loc* at
    x, y.  For example, to put the legend's upper right-hand corner in the
    center of the axes (or figure) the following keywords can be used::

        loc='upper right', bbox_to_anchor=(0.5, 0.5)

ncol : integer
    The number of columns that the legend has. Default is 1.

prop : None or :class:`matplotlib.font_manager.FontProperties` or dict
    The font properties of the legend. If None (default), the current
    :data:`matplotlib.rcParams` will be used.

fontsize : int or float or {'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'}
    Controls the font size of the legend. If the value is numeric the
    size will be the absolute font size in points. String values are
    relative to the current default font size. This argument is only
    used if `prop` is not specified.

numpoints : None or int
    The number of marker points in the legend when creating a legend
    entry for a `.Line2D` (line).
    Default is ``None``, which will take the value from
    :rc:`legend.numpoints`.

scatterpoints : None or int
    The number of marker points in the legend when creating
    a legend entry for a `.PathCollection` (scatter plot).
    Default is ``None``, which will take the value from
    :rc:`legend.scatterpoints`.

scatteryoffsets : iterable of floats
    The vertical offset (relative to the font size) for the markers
    created for a scatter plot legend entry. 0.0 is at the base the
    legend text, and 1.0 is at the top. To draw all markers at the
    same height, set to ``[0.5]``. Default is ``[0.375, 0.5, 0.3125]``.

markerscale : None or int or float
    The relative size of legend markers compared with the originally
    drawn ones.
    Default is ``None``, which will take the value from
    :rc:`legend.markerscale`.

markerfirst : bool
    If *True*, legend marker is placed to the left of the legend label.
    If *False*, legend marker is placed to the right of the legend
    label.
    Default is *True*.

frameon : None or bool
    Control whether the legend should be drawn on a patch
    (frame).
    Default is ``None``, which will take the value from
    :rc:`legend.frameon`.

fancybox : None or bool
    Control whether round edges should be enabled around the
    :class:`~matplotlib.patches.FancyBboxPatch` which makes up the
    legend's background.
    Default is ``None``, which will take the value from
    :rc:`legend.fancybox`.

shadow : None or bool
    Control whether to draw a shadow behind the legend.
    Default is ``None``, which will take the value from
    :rc:`legend.shadow`.

framealpha : None or float
    Control the alpha transparency of the legend's background.
    Default is ``None``, which will take the value from
    :rc:`legend.framealpha`.  If shadow is activated and
    *framealpha* is ``None``, the default value is ignored.

facecolor : None or "inherit" or a color spec
    Control the legend's background color.
    Default is ``None``, which will take the value from
    :rc:`legend.facecolor`.  If ``"inherit"``, it will take
    :rc:`axes.facecolor`.

edgecolor : None or "inherit" or a color spec
    Control the legend's background patch edge color.
    Default is ``None``, which will take the value from
    :rc:`legend.edgecolor` If ``"inherit"``, it will take
    :rc:`axes.edgecolor`.

mode : {"expand", None}
    If `mode` is set to ``"expand"`` the legend will be horizontally
    expanded to fill the axes area (or `bbox_to_anchor` if defines
    the legend's size).

bbox_transform : None or :class:`matplotlib.transforms.Transform`
    The transform for the bounding box (`bbox_to_anchor`). For a value
    of ``None`` (default) the Axes'
    :data:`~matplotlib.axes.Axes.transAxes` transform will be used.

title : str or None
    The legend's title. Default is no title (``None``).

title_fontsize: str or None
    The fontsize of the legend's title.  Default is the default fontsize.

borderpad : float or None
    The fractional whitespace inside the legend border.
    Measured in font-size units.
    Default is ``None``, which will take the value from
    :rc:`legend.borderpad`.

labelspacing : float or None
    The vertical space between the legend entries.
    Measured in font-size units.
    Default is ``None``, which will take the value from
    :rc:`legend.labelspacing`.

handlelength : float or None
    The length of the legend handles.
    Measured in font-size units.
    Default is ``None``, which will take the value from
    :rc:`legend.handlelength`.

handletextpad : float or None
    The pad between the legend handle and text.
    Measured in font-size units.
    Default is ``None``, which will take the value from
    :rc:`legend.handletextpad`.

borderaxespad : float or None
    The pad between the axes and legend border.
    Measured in font-size units.
    Default is ``None``, which will take the value from
    :rc:`legend.borderaxespad`.

columnspacing : float or None
    The spacing between columns.
    Measured in font-size units.
    Default is ``None``, which will take the value from
    :rc:`legend.columnspacing`.

handler_map : dict or None
    The custom dictionary mapping instances or types to a legend
    handler. This `handler_map` updates the default handler map
    found at :func:`matplotlib.legend.Legend.get_legend_handler_map`.



Returns
-------

:class:`matplotlib.legend.Legend` instance

Notes
-----

Not all kinds of artist are supported by the legend command. See
:doc:`/tutorials/intermediate/legend_guide` for details.

Examples
--------

.. plot:: gallery/text_labels_and_annotations/legend.py
File:      c:\users\hsingluliu\anaconda3\lib\site-packages\matplotlib\pyplot.py
Type:      function

scatter()函数详细参数

Signature:
plt.scatter(
    x,
    y,
    s=None,
    c=None,
    marker=None,
    cmap=None,
    norm=None,
    vmin=None,
    vmax=None,
    alpha=None,
    linewidths=None,
    verts=None,
    edgecolors=None,
    *,
    plotnonfinite=False,
    data=None,
    **kwargs,
)
Docstring:
A scatter plot of *y* vs *x* with varying marker size and/or color.

Parameters
----------
x, y : array_like, shape (n, )
    The data positions.

s : scalar or array_like, shape (n, ), optional
    The marker size in points**2.
    Default is ``rcParams['lines.markersize'] ** 2``.

c : color, sequence, or sequence of color, optional
    The marker color. Possible values:

    - A single color format string.
    - A sequence of color specifications of length n.
    - A sequence of n numbers to be mapped to colors using *cmap* and
      *norm*.
    - A 2-D array in which the rows are RGB or RGBA.

    Note that *c* should not be a single numeric RGB or RGBA sequence
    because that is indistinguishable from an array of values to be
    colormapped. If you want to specify the same RGB or RGBA value for
    all points, use a 2-D array with a single row.  Otherwise, value-
    matching will have precedence in case of a size matching with *x*
    and *y*.

    Defaults to ``None``. In that case the marker color is determined
    by the value of ``color``, ``facecolor`` or ``facecolors``. In case
    those are not specified or ``None``, the marker color is determined
    by the next color of the ``Axes``' current "shape and fill" color
    cycle. This cycle defaults to :rc:`axes.prop_cycle`.

marker : `~matplotlib.markers.MarkerStyle`, optional
    The marker style. *marker* can be either an instance of the class
    or the text shorthand for a particular marker.
    Defaults to ``None``, in which case it takes the value of
    :rc:`scatter.marker` = 'o'.
    See `~matplotlib.markers` for more information about marker styles.

cmap : `~matplotlib.colors.Colormap`, optional, default: None
    A `.Colormap` instance or registered colormap name. *cmap* is only
    used if *c* is an array of floats. If ``None``, defaults to rc
    ``image.cmap``.

norm : `~matplotlib.colors.Normalize`, optional, default: None
    A `.Normalize` instance is used to scale luminance data to 0, 1.
    *norm* is only used if *c* is an array of floats. If *None*, use
    the default `.colors.Normalize`.

vmin, vmax : scalar, optional, default: None
    *vmin* and *vmax* are used in conjunction with *norm* to normalize
    luminance data. If None, the respective min and max of the color
    array is used. *vmin* and *vmax* are ignored if you pass a *norm*
    instance.

alpha : scalar, optional, default: None
    The alpha blending value, between 0 (transparent) and 1 (opaque).

linewidths : scalar or array_like, optional, default: None
    The linewidth of the marker edges. Note: The default *edgecolors*
    is 'face'. You may want to change this as well.
    If *None*, defaults to rcParams ``lines.linewidth``.

edgecolors : {'face', 'none', *None*} or color or sequence of color, optional.
    The edge color of the marker. Possible values:

    - 'face': The edge color will always be the same as the face color.
    - 'none': No patch boundary will be drawn.
    - A Matplotlib color or sequence of color.

    Defaults to ``None``, in which case it takes the value of
    :rc:`scatter.edgecolors` = 'face'.

    For non-filled markers, the *edgecolors* kwarg is ignored and
    forced to 'face' internally.

plotnonfinite : boolean, optional, default: False
    Set to plot points with nonfinite *c*, in conjunction with
    `~matplotlib.colors.Colormap.set_bad`.

Returns
-------
paths : `~matplotlib.collections.PathCollection`

Other Parameters
----------------
**kwargs : `~matplotlib.collections.Collection` properties

See Also
--------
plot : To plot scatter plots when markers are identical in size and
    color.

Notes
-----

* The `.plot` function will be faster for scatterplots where markers
  don't vary in size or color.

* Any or all of *x*, *y*, *s*, and *c* may be masked arrays, in which
  case all masks will be combined and only unmasked points will be
  plotted.

* Fundamentally, scatter works with 1-D arrays; *x*, *y*, *s*, and *c*
  may be input as 2-D arrays, but within scatter they will be
  flattened. The exception is *c*, which will be flattened only if its
  size matches the size of *x* and *y*.

.. note::
    In addition to the above described arguments, this function can take a
    **data** keyword argument. If such a **data** argument is given, the
    following arguments are replaced by **data[<arg>]**:

    * All arguments with the following names: 'c', 'color', 'edgecolors', 'facecolor', 'facecolors', 'linewidths', 's', 'x', 'y'.

    Objects passed as **data** must support item access (``data[<arg>]``) and
    membership test (``<arg> in data``).
File:      c:\users\hsingluliu\anaconda3\lib\site-packages\matplotlib\pyplot.py
Type:      function

你可能感兴趣的:(Python可视化,python,可视化)