0

I am a beginner in python. I am trying to plot a CSV file in the form of a facet grid using the seaborne library.

import matplotlib.pyplot as plt
import seaborn as sns
g = sns.FacetGrid(df, col="Gamma1",col_wrap=6,sharex=False)
g = (g.map(plt.scatter, "ARMSE", "Frobenius_norm_correlation").add_legend())
plt.subplots_adjust(top=0.9)
g.fig.suptitle('Friedman_chain')

For each of the scatterplots in the facet grid, I want to state the co-ordinates of the data point with the minimum value of ARMSE and mark this point with a different color from the other data points in the given scatter plot.can you suggest to me how to do it?

The dataframe df contains the columns ARMSE,Gamma1,Frobenius_norm_correlation. I am attaching the image of the current plot below : The current plot i am getting

venkat
  • 13
  • 6
  • What is meant by ARMSE in your question? – Karthik Sep 03 '20 at 11:25
  • it's one of the columns in the data frame df – venkat Sep 03 '20 at 11:32
  • So you mean you want Gamma1 with different colors and ARMSE with different colors? – Karthik Sep 03 '20 at 11:33
  • I have updated the question. what I meant was for each of the scatter plots in the facet grid i want to mark the coordinates of the point with the minimum value of ARMSE and mark it with a different color compared to the other data points in the scatterplot . – venkat Sep 03 '20 at 11:39

1 Answers1

1

You can create a column identifying the minimum data point as part of pre-processing and pass this column's name to seaborn.

For example, taking a sample dataset:

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

df = pd.DataFrame(data={
    "group": list("ABCDEFGHIJ") * 10,
    "y": np.random.normal(loc=1, scale=1, size=100),
    "x": np.array([[x] * 10 for x in range(10)]).flatten()
})

# new column identifying the minimum value
df["min"] = df["y"] == df.groupby("group")["y"].transform(min)

g = sns.FacetGrid(df, col="group", hue="min", col_wrap=5, sharex=True)
g = (g.map(plt.scatter, "x", "y").add_legend())
plt.subplots_adjust(top=0.9)
g.fig.suptitle('Min value detection')

enter image description here

gherka
  • 1,416
  • 10
  • 17
  • Thanks that was helpful . is there a way i can annotate the co-ordinate of that point in the scatter plot ? – venkat Sep 03 '20 at 13:03
  • Judging by [this](https://stackoverflow.com/questions/45849028/seaborn-facetgrid-pointplot-label-data-points) post you might have to write a custom function to add annotations as each facet is drawn. – gherka Sep 03 '20 at 13:26