目前我可以用 matplotlib 绘制一个最小和最大间隔,但是我希望对 plotnine 库做同样的事情,这可能吗?我正在尝试但没有成功
Matplotlib 代码
plot_range = list(range(0,len(sorted_table)))
min_val = sorted_table[['min']]
max_val = sorted_table[['max']]
original = sorted_table[['true']]
fig = plt.figure(1, figsize = (18,10)) # Figure size in inches (size_x, size_y)
ax = plt.axes()
plt.plot(plot_range, min_val, label = "Min", color='blue')
plt.plot(plot_range, max_val, label = "Max", color='red')
plt.plot(plot_range,original, label = "y", color = "black")
#plt.plot(static_predicted, label = "y\u0302", marker='o', )
plt.title('Static Final Conformal Predictions', fontsize=20)
plt.xlim([-2, 100])
plt.ylim([-1, 1.5])
plt.legend()
plt.show()
尝试 Plotnine 代码
import plotnine as p9
p9.options.set_option("figure_size", (16, 8))
(p9.ggplot(sorted_table, p9.aes(x = "index")
+ p9.geom_line(p9.aes(y = "min"), color = "blue")
+ p9.geom_line(p9.aes(y = "max"), color = "red")
+ p9.geom_line(p9.aes(y = "true"), color = "black")
))
PlotnineError: "Cannot add layer to object of type <class 'plotnine.aes.aes'>"