简体   繁体   English

将边缘添加到 matplotlib plot 并给出边缘颜色(无散点图)

[英]Add edge to matplotlib plot and give a edgecolor (no scatter)

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(np.random.randint(0,100,size=(5, 2)), columns=list('AB'))


plt.plot(df.A,df.B,color='black',marker='o',linestyle='', markersize=5)

Insted of putting black dots, I want to put white dots with black circle/edge and adjust edge size放置black点,我想用black圆圈/边缘放置white点并调整边缘大小

Just add markerfacecolor='white' to your keyword arguments:只需将markerfacecolor='white'添加到您的关键字 arguments 中:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame(np.random.randint(0,100,size=(5, 2)), columns=list('AB'))


plt.plot(df.A,df.B,color='black',marker='o',markerfacecolor='white',linestyle='',markersize=5)
# or use mfc='white' instead

From the documentation:文档中:

kwargsLine2D properties, optional kwargs are used to specify properties like a line label (for auto legends), linewidth, antialiasing, marker face color . kwargsLine2D 属性,可选的 kwargs 用于指定属性,如线 label(用于自动图例)、线宽、抗锯齿、标记面颜色

markerfacecolor or mfc color markerfacecolor 或 mfc颜色

where color is one of these colors .其中颜色是这些 colors 之一

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM