我的 X 轴旋转有问题,我尝试旋转输出图而没有错误,但我没有结果。
# Import Data
#df = pd.read_csv("https://github.com/selva86/datasets/raw/master/economics.csv")
x = total_test["Dia"].values[:]; y1 = total_test["Confirmados"].values[:]; y2 = total_test["Fallecidos"].values[:]
# Plot Line1 (Left Y Axis)
fig, ax1 = plt.subplots(1,1,figsize=(10,8), dpi= 200)
ax1.plot(x, y1,'g^', color='tab:red')
# Plot Line2 (Right Y Axis)
ax2 = ax1.twinx() # instantiate a second axes that shares the same x-axis
ax2.plot(x, y2,'bs', color='tab:blue')
# Just Decorations!! -------------------
# ax1 (left y axis)
ax1.set_xlabel('Dias', fontsize=10)
ax1.set_ylabel('Personas Confirmadas', color='tab:red', fontsize=20)
ax1.tick_params(axis='y', rotation=0, labelcolor='tab:red' )
# ax2 (right Y axis)
ax2.set_ylabel("Personas …Run Code Online (Sandbox Code Playgroud) 我想用 SVR 绘制特征重要性,但我不知道是否可以使用支持向量回归这是我的代码。
from sklearn.svm import SVR
C=1e3
svr_lin = SVR(kernel="linear", C=C)
y_lin = svr_lin.fit(X,Y).predict(X)
scores = cross_val_score(svr_lin, X, Y, cv = 5)
print(scores)
print(scores.mean())
print(scores.std())
Run Code Online (Sandbox Code Playgroud) 我试图用 Matplotlib 绘制误差条,就像附加的图形一样,我做不到,有什么建议吗?
import numpy as np
import matplotlib.pyplot as plt
Media = data["Media"]
Periodo = data["Periodo"]
P10th = data["P10th"]
P90th = data["P90th"]
ind = np.arange(N) # the x locations for the groups
width = 0.35 # the width of the bars: can also be len(x) sequence
fig, ax = plt.subplots()
ax.errorbar(Media, P90th, P10th, color='red', ls='--', marker='o', capsize=5, capthick=1, ecolor='black')
plt.xticks(ind, ('1910-1940', '1950-1990', '1990-2000', '2001-2010') )
ax.set_ylim(ylims)
Run Code Online (Sandbox Code Playgroud)
这是我的输出