首页 > 解决方案 > plotnine - jupyter lab - 在边距中添加 x 和 y 值

问题描述

我已导入 plotnine 并运行以下代码。

示例运行,但是当我运行如下图时,我会在边距中打印所有 x 和 y 值。其他人r

x       = np.arange(-5.,5.,0.25,dtype=float)
gamma   = 5.
y       = gamma * x / (x ** 2 + gamma)
gg      = pd.DataFrame()
gg['x'] = x
gg['y'] = y

p = ggplot(aes(x,y),gg) + geom_point() 
p.save(filename = 'test3.png', height=5, width=5, units = 'cm')
p

jupyter 实验室绘图输出

标签: jupyter-labplotnine

解决方案


用 Roseanne Rosannadanna 的话来说——“没关系”。

除非其他人从 R ggplot 包转换。

我可能已经在 R 中写过 1000 个 ggplots,上面的问题是 R ggplot 语句采用上面的 x 和 y 变量:

p = ggplot(aes(x,y),gg) + geom_point() 

显然 plotnine 需要分配 x 和 y ,所以这有效:

p = ggplot(aes(x='x',y='y'),gg) + geom_point().

推荐阅读