Entering edit mode
18 months ago
ali.kian.saei
▴
10
i run these python codes in Rstudio but plots show in one plot like uploaded picture
first code
from sklearn import datasets
import pandas as pd
import matplotlib.pyplot as plt
iris = datasets.load_iris()
iris.data
iris.target
df = pd.DataFrame(iris.data, columns=iris.feature_names)
df.head()
df['class']= iris.target
x=iris.data[:,[2,3]]
y=iris.target
fig2 = plt.scatter(x[:,0],x[:,1],c=y, zorder=1)
plt.show(fig2)
second code
from sklearn.linear_model import Lasso
from sklearn.datasets import load_diabetes
import matplotlib.pyplot as plt
import pandas as pd
diabet = datasets.load_diabetes()
x = diabet.data
y = diabet.target
df = pd.DataFrame(x, columns=diabet.feature_names)
df ['Price'] = y
model =Lasso(alpha=0.1)
model.fit(x , y)
c= model.coef_
fig = plt.plot(range(10),c, zorder=0)
plt.xticks(range(10),diabet.feature_names)
plt.ylabel('coefficients')
plt.show(fig)
how can i draw each plot in separate plot?
output figs is attached