4
$\begingroup$

I am trying to output a complex facet grid plot in the format of the following image:

enter image description here

But the problem is that I don't want the edge color of the markers to be white, I want it to be the face color.

In matplotlib, I can change the color of marker edges by calling the following:

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

df = pd.DataFrame({"values_x": np.random.randn(100), "values_y": np.random.randn(100)})

plt.scatter(x=df["values_x"], y=df["values_y"], edgecolors="red")
plt.show()

This produces a plot that looks like:

enter image description here

Now, if I call the following:

sns.relplot(data=df, x="values_x", y="values_y", edgecolors="red")
plt.show()

I still get white marker edges like in the following:

enter image description here

So, how do I correctly change the color of the marker edges within a call to sns.relplot()?

*For reference, I create the top facet grid plot with the following:

sns.relplot(data=df,
            x="C",
            y=metric,
            row="penalty",
            col="solver",
            hue="fold")
$\endgroup$
3
  • $\begingroup$ Remove $edgecolors="red"$ and it will give you the desired plot. $\endgroup$ Aug 7, 2019 at 20:07
  • $\begingroup$ If I remove that I still get white edges around the markers. I want the edges to be whatever color I choose them to be. I actually figured out the problem and will update the question. $\endgroup$ Aug 7, 2019 at 20:20
  • $\begingroup$ That's weird. I didn't get that white marks. $\endgroup$ Aug 8, 2019 at 1:07

1 Answer 1

3
$\begingroup$

The issue was with the parameter I was using. The parameter "edgecolors" is incorrect. The correct parameter is the non-plural "edgecolor". So the correct call to relplot is:

sns.relplot(data=df, x="values_x", y="values_y", edgecolor=None)

This would remove the marker edges completely, which is what I was trying to do originally.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.