column shows the 3 methanol-based pairs. Each plot will look like your plot for Exercise 1 above: it should includ ellipses for fermented and unfermented. Each subplot should have its own axis labels and title. In order to keep your code from exploding, you should create a function whose inputs are two columns of data, v two features. You will then call this function 6 times to produce the 6 subplots. import matplotlib.pyplot as plt xf= df_fer[['TPC-MECH']] |yf= df_fer[['TEAC-MEOH¹]] xnf = df_nf[['TPC-MEOH']] ynf = df_nf[['TEAC-MEOH']]

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

How do you fix this error. Or is there another way to plot six confidence ellipse in 3x2 grid of plots using subplot (IN PYTHON)

Create a 3 x 2 grid of plots (using the subplot command from matplotlib), where the first column of plots shows the 3 water-based pairs and the second
column shows the 3 methanol-based pairs. Each plot will look like your plot for Exercise 1 above: it should include the scattered points as well as confidence
ellipses for fermented and unfermented. Each subplot should have its own axis labels and title.
In order to keep your code from exploding, you should create a function whose inputs are two columns of data, which produces the plot corresponding to those
two features. You will then call this function 6 times to produce the 6 subplots.
import matplotlib.pyplot as plt
xf= df_fer [['TPC-MEOH']]
yf= df_fer[['TEAC-MEOH']]
xnf = df_nf[[ TPC-MEOH']]
ynf = df_nf[['TEAC-MEOH']]
#Answer to Exercise 4 here
import numpy as np # 'np' is the prefix that will identify nump packages
from source.ellipses import confidence_ellipse # for representing the correlation (for def draw_confidence_ellipse2(xf, yf,
xfa = np.array(xf).flatten()
yfa= np.array(yf).flatten()
xnfa = np.array(xnf).flatten()
ynfa = np.array(ynf).flatten()
ax = plt.subplots()
plt.scatter(xfa, yfa, s-6, color = 'blue')
confidence_ellipse (xfa, yfa, ax, n_std=1, label='FR', edgecolor='blue', linestyle='--')
plt.scatter (xnfa, ynfa, s-6, color = 'orange')
confidence_ellipse (xnfa, ynfa, ax, n_std=1, label='NF', edgecolor="orange', linestyle='--')
ax.set_title('title', fontsize =16, fontweight = "bold")
ax.set_xlabel('x1', fontweight ='bold', fontsize =16)
ax.set_ylabel('yl', fontweight ='bold', fontsize =16)
ax.legend (prop={"size":14})
f_tpc_m= df_fer [['TPC-MEOH']]
f_teac_m= df_fer [['TEAC-MEOH']]
f_frap_m= df_fer [['FRAP-MECH']]
Transcribed Image Text:Create a 3 x 2 grid of plots (using the subplot command from matplotlib), where the first column of plots shows the 3 water-based pairs and the second column shows the 3 methanol-based pairs. Each plot will look like your plot for Exercise 1 above: it should include the scattered points as well as confidence ellipses for fermented and unfermented. Each subplot should have its own axis labels and title. In order to keep your code from exploding, you should create a function whose inputs are two columns of data, which produces the plot corresponding to those two features. You will then call this function 6 times to produce the 6 subplots. import matplotlib.pyplot as plt xf= df_fer [['TPC-MEOH']] yf= df_fer[['TEAC-MEOH']] xnf = df_nf[[ TPC-MEOH']] ynf = df_nf[['TEAC-MEOH']] #Answer to Exercise 4 here import numpy as np # 'np' is the prefix that will identify nump packages from source.ellipses import confidence_ellipse # for representing the correlation (for def draw_confidence_ellipse2(xf, yf, xfa = np.array(xf).flatten() yfa= np.array(yf).flatten() xnfa = np.array(xnf).flatten() ynfa = np.array(ynf).flatten() ax = plt.subplots() plt.scatter(xfa, yfa, s-6, color = 'blue') confidence_ellipse (xfa, yfa, ax, n_std=1, label='FR', edgecolor='blue', linestyle='--') plt.scatter (xnfa, ynfa, s-6, color = 'orange') confidence_ellipse (xnfa, ynfa, ax, n_std=1, label='NF', edgecolor="orange', linestyle='--') ax.set_title('title', fontsize =16, fontweight = "bold") ax.set_xlabel('x1', fontweight ='bold', fontsize =16) ax.set_ylabel('yl', fontweight ='bold', fontsize =16) ax.legend (prop={"size":14}) f_tpc_m= df_fer [['TPC-MEOH']] f_teac_m= df_fer [['TEAC-MEOH']] f_frap_m= df_fer [['FRAP-MECH']]
f_tpc_n = df_fer[['TPC-MECH']]
f_teac_n = df_fer [['TEAC-MEOH"]]
f_frap_m= df_fer [['FRAP-MECH']]
f_tpc_h= df_fer[['TPC-H20']]
f_teac_h= df_fer[['TEAC-H20']]
f_frap_h= df_fer[['FRAP-H20']]
nf_tpc_n = df_nf[['TPC-MECH']]
nf_teac_n = df_nf[['TEAC-MECH']]
nf_frap_m= df_nf[['FRAP-MECH']]
nf_tpc_h= df_nf[['TPC-H20']]
nf_teac_h= df_nf[['TEAC-H20']]
nf_frap_h= df_nf[['FRAP-H20']]
fig, ax = plt.subplots(3, 2, figsize=(24, 24))
draw_confidence_ellipse2(f_tpc_h, f_teac_h, nf_tpc_h, nf_teac_h, 2, ax[0,0], "TPC", "TEAC", "TPC-H20 vs TEAC-H20")
draw_confidence_ellipse2(f_tpc_h, f_frap_h, nf_tpc_h, nf_frap_h, 2, ax[1,0], "TPC", "FRAP", "TPC-H20 vs FRAP-H20")
draw_confidence_ellipse2(f_frap_h, f_teac_h, nf_frap_h, nf_teac_h, 2, ax[2,0], "FRAP", "TEAC", "FRAP-H20 vs TEAC-H20")
draw_confidence_ellipse2(f_tpc_m,
draw_confidence_ellipse2(f_tpc_m,
draw_confidence_ellipse2(f_frap_n,
4
f_teac_m, nf_tpc_m, nf_teac_m, 2, ax[0,1], "TPC", "TEAC", "TPC-MEOH vs TEAC-MEOH")
f_frap_m, nf_tpc_m, nf_frap_m, 2, ax[1,1], "TPC", "FRAP", "TPC-MEOH vs FRAP-MEOH")
f_teac_m, nf_frap_n, nf_teac_m, 2, ax[2,1], "FRAP", "TEAC", "FRAP-MEOH vs TEAC-MEOH"
AttributeError
Input In [26], in <cell line: 13>()
plt.subplots()
Traceback (most recent call last)
10 ax
12 plt.scatter(xfa, yfa, s=6, color = 'blue')
---> 13 confidence_ellipse(xfa, yfa, ax, n_std=1, label='FR", edgecolor='blue', linestyle='--')
15 plt.scatter(xnfa, ynfa, s=6, color="orange")
16 confidence_ellipse(xnfa, ynfa, ax, n_std=1, label='NF", edgecolor='orange', linestyle='--')
File -\source\ellipses.py:58, in confidence_ellipse(x, y, ax, n_std, facecolor, **kwargs)
51 mean y = np.mean(y)
53 transf = transforms.Affine2D() \
54
.rotate_deg (45) \
55
.scale(scale_x, scale_y) \
.translate(mean_x, nean_y)
56
--> 58 ellipse.set_transform(transf + ax. transData)
59 return ax.add_patch(ellipse)
AttributeError: 'tuple' object has no attribute 'transData'
Transcribed Image Text:f_tpc_n = df_fer[['TPC-MECH']] f_teac_n = df_fer [['TEAC-MEOH"]] f_frap_m= df_fer [['FRAP-MECH']] f_tpc_h= df_fer[['TPC-H20']] f_teac_h= df_fer[['TEAC-H20']] f_frap_h= df_fer[['FRAP-H20']] nf_tpc_n = df_nf[['TPC-MECH']] nf_teac_n = df_nf[['TEAC-MECH']] nf_frap_m= df_nf[['FRAP-MECH']] nf_tpc_h= df_nf[['TPC-H20']] nf_teac_h= df_nf[['TEAC-H20']] nf_frap_h= df_nf[['FRAP-H20']] fig, ax = plt.subplots(3, 2, figsize=(24, 24)) draw_confidence_ellipse2(f_tpc_h, f_teac_h, nf_tpc_h, nf_teac_h, 2, ax[0,0], "TPC", "TEAC", "TPC-H20 vs TEAC-H20") draw_confidence_ellipse2(f_tpc_h, f_frap_h, nf_tpc_h, nf_frap_h, 2, ax[1,0], "TPC", "FRAP", "TPC-H20 vs FRAP-H20") draw_confidence_ellipse2(f_frap_h, f_teac_h, nf_frap_h, nf_teac_h, 2, ax[2,0], "FRAP", "TEAC", "FRAP-H20 vs TEAC-H20") draw_confidence_ellipse2(f_tpc_m, draw_confidence_ellipse2(f_tpc_m, draw_confidence_ellipse2(f_frap_n, 4 f_teac_m, nf_tpc_m, nf_teac_m, 2, ax[0,1], "TPC", "TEAC", "TPC-MEOH vs TEAC-MEOH") f_frap_m, nf_tpc_m, nf_frap_m, 2, ax[1,1], "TPC", "FRAP", "TPC-MEOH vs FRAP-MEOH") f_teac_m, nf_frap_n, nf_teac_m, 2, ax[2,1], "FRAP", "TEAC", "FRAP-MEOH vs TEAC-MEOH" AttributeError Input In [26], in <cell line: 13>() plt.subplots() Traceback (most recent call last) 10 ax 12 plt.scatter(xfa, yfa, s=6, color = 'blue') ---> 13 confidence_ellipse(xfa, yfa, ax, n_std=1, label='FR", edgecolor='blue', linestyle='--') 15 plt.scatter(xnfa, ynfa, s=6, color="orange") 16 confidence_ellipse(xnfa, ynfa, ax, n_std=1, label='NF", edgecolor='orange', linestyle='--') File -\source\ellipses.py:58, in confidence_ellipse(x, y, ax, n_std, facecolor, **kwargs) 51 mean y = np.mean(y) 53 transf = transforms.Affine2D() \ 54 .rotate_deg (45) \ 55 .scale(scale_x, scale_y) \ .translate(mean_x, nean_y) 56 --> 58 ellipse.set_transform(transf + ax. transData) 59 return ax.add_patch(ellipse) AttributeError: 'tuple' object has no attribute 'transData'
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY