python - Plotnine:绘制图形时如何删除 ggplot:(xxx) 类型烦人的文本输出
问题描述
- 运行 jupyter 笔记本(python)
- 使用 Python Plotnine库绘图
- 我绘制并在输出图形下方是烦人的“ggplot2:(数字)”输出
- 通常你会
;
在你的笔记本单元格的末尾放一个,但是当我使用 Plotnine 时它似乎并没有抑制烦人的输出文本(但它显然适用于 matplotlib 等)
有任何想法吗 ?
解决方案
The point is in calling draw() method with semicolon at the end.
Fully working example:
import pandas
from plotnine import *
from random import randint
# 100 random numbers
random_numbers = [randint(1, 100) for p in range(0, 100)]
# Create DataFrame
df = pd.DataFrame({'number': random_numbers})
# Draw plot
(
ggplot(df, aes(x='number')) +
geom_histogram(bins=20, na_rm=True) +
ggtitle('Histogram of random numbers') +
theme_light()
).draw();
推荐阅读
- angular - 如何跨 Angular 组件保留 JWT 令牌
- r - 加速 R 中大型矩阵的一系列计算
- html - 设计边框底部
- python - 添加新功能在 pysandbox 中不起作用
- delphi - 如何返回记录中具有给定值的字段计数?
- symmetricds - Symmetricds - 配置数据模型架构
- distributed-computing - 在 PAXOS 或 RAFT 中重新上线的副本如何赶上?
- reactjs - 如何向 Material-UI TablePagination 添加元素?
- reactjs - 样式化组件 - 将对象作为来自抛光的颜色函数的第二个参数传递
- javascript - Primefaces 如何从 JQUERY 或 JS 或 PF 方法中设置 selectOneRadio