Multiple plot are displayed on one plot by matplotlib
0
0
Entering edit mode
18 months ago

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 attachedenter image description here

Rstudio python r • 469 views
ADD COMMENT

Login before adding your answer.

Traffic: 2264 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6