python-colab :: Error when using : palette='jet' . why?

85 views Asked by At

When I write the following code in Google colab, I get an error. what is the problem?

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
import pandas as pd
n=200
x=np.linspace(-1,1,n)
y1=x**2
y2=np.sin(3*x)
y3=np.exp(-10*x**22)
sns.scatterplot(x=y1,y=y2,hue=y3,legend=False,palette='jet')
plt.show()
1

There are 1 answers

0
Shishu Kumar Choudhary On

this piece of code cause problem

sns.scatterplot(x=y1,y=y2,hue=y3,legend=False,palette='jet')

use this in place of above, it will give you proper output

sns.scatterplot(x=y1,y=y2,hue=y3,legend=False)

or

sns.scatterplot(x=y1,y=y2,hue=y3,legend=False, palette=None)