I have read posts with similar exception raised (ie:here, and there), but not particularly useful as the error was basically due to typos.
Below the very simple code that raises my error. Reading the seaborn doc and examples is not helping.
import pandas
import seaborn
df=pandas.DataFrame([[0,25.0,100],[0,24.0,95],[0,25.6,90],[0,20,120],[0,21,130],[0,22.5,115],[1,25.0,100],[1,26.0,150],[1,24.0,120],[1,20.0,200],[1,15.0,250]], columns=["meter","T°@T","meter-reading"])
df
output:
meter T°@T meter-reading
0 0 25.0 100
1 0 24.0 95
2 0 25.6 90
3 0 20.0 120
4 0 21.0 130
5 0 22.5 115
6 1 25.0 100
7 1 26.0 150
8 1 24.0 120
9 1 20.0 200
10 1 15.0 250
and then trying to plot FacetGrid:
g=seaborn.FacetGrid(data=df, col="meter").map(seaborn.relplot, x="T°@T",y="meter-reading")
Error: Could not interpret input 'T°@T'
the very odd thing is, .map encounters issues, but this other code works just fine:
seaborn.relplot(data=df,x="T°@T",y="meter-reading")
What am I doing wrong?
PS: the exception is raised in both Jupyter Notebook and Spyder
I'm guessing it's an error because relplot itself can expand multiple graphs. So you can draw the graph by specifying sns.scatterplot
. I don't think `meter' is color-coded because it's not a category variable.
import matplotlib.pyplot as plt
import seaborn as sns
g = sns.FacetGrid(data=df, col="meter")
g.map_dataframe(sns.scatterplot, x=df["T°@T"], y=df["meter-reading"], hue='meter')
g.set_axis_labels('T°@T','meter-reading')
g.add_legend()