develarist
develarist

Reputation: 1375

How to get markers with no fill, from matplotlib 3.3.1

matplotlib.pyplot.scatter has a facecolors=None argument that will give data point markers the appearance of being hollow on the inside. How can I get the same look for pandas.DataFrame.plot.scatter()?

Upvotes: 5

Views: 5832

Answers (2)

Trenton McKinney
Trenton McKinney

Reputation: 62513

  • It's difficult to find in the matplotlib documentation, but it seems fc and ec are aliases for facecolor and edgecolor, respectively.
  • The pandas plot engine is matplotlib.
  • The parameter is fc. To use fc, you should also use ec.
    • Specifying fc='none', without specifying ec, will result in blank markers.
  • 'None' and 'none' both work, but not None.
import seaborn as sns  # for data
import matplotlib.pyplot as plt

# load data
penguins = sns.load_dataset("penguins", cache=False)

# set x and y
x, y = penguins["bill_length_mm"], penguins["bill_depth_mm"]

# plot
plt.scatter(x, y, fc='none', ec='g')

enter image description here

# penguins is a pandas dataframe
penguins[['bill_length_mm', 'bill_depth_mm']].plot.scatter('bill_depth_mm', 'bill_length_mm', ec='g', fc='none')

enter image description here

Upvotes: 4

Quang Hoang
Quang Hoang

Reputation: 150785

It's option c (note that it's 'None' not None, even for facecolors in plt):

df.plot.scatter(x='x',y='y', c='None', edgecolors='C1')

Output:

enter image description here

Upvotes: 6

Related Questions