所以我一直试图得到它,所以每行末尾都有一个标签,给出国家的名称,然后我可以删除图例。试过玩,transform_filter但没有运气。
我使用了这里的数据https://ourworldindata.org/coronavirus-source-data我清理并重塑了数据,所以它看起来像这样:-
index days date country value
0 1219 0 2020-03-26 Australia 11.0
1 1220 1 2020-03-27 Australia 13.0
2 1221 2 2020-03-28 Australia 13.0
3 1222 3 2020-03-29 Australia 14.0
4 1223 4 2020-03-30 Australia 16.0
5 1224 5 2020-03-31 Australia 19.0
6 1225 6 2020-04-01 Australia 20.0
7 1226 7 2020-04-02 Australia 21.0
8 1227 8 2020-04-03 Australia 23.0
9 1228 9 2020-04-04 Australia 30.0
Run Code Online (Sandbox Code Playgroud)
import altair as alt
countries_list = ['Australia', 'China', 'France', …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 PyMUPDF 1.18.14 从 PDF 中提取粗体文本元素。我希望这能按照我从针对flags=4粗体字体的文档中了解到的那样起作用。
page = doc[1]\ntext = page.get_text(flags=4)\nprint(text)\nRun Code Online (Sandbox Code Playgroud)\n但它会打印页面上的所有文本,而不仅仅是粗体文本。
\nTextPage.extractDICT() (or Page.get_text(\xe2\x80\x9cdict\xe2\x80\x9d))当这样使用时:-
page.get_text("dict", flags=11)["blocks"]\nRun Code Online (Sandbox Code Playgroud)\n该标志有效,但我无法理解它在做什么。也许在图像和文本块之间切换。
\n跨度
\n所以看来你必须到达span才能访问标志。
<page>\n <text block>\n <line>\n <span>\n <char>\n <image block>\n <img>\nRun Code Online (Sandbox Code Playgroud)\n\n所以你可以做这样的事情,我flags=20在 span 标签上使用了粗体字体。
page = doc[1]\nblocks = page.get_text("dict", flags=11)["blocks"]\nfor b in blocks: # iterate through the text blocks\n for l in b["lines"]: # iterate through the text lines\n for s in l["spans"]: # …Run Code Online (Sandbox Code Playgroud) 所以我正在使用 Cars 数据集,并希望将 R 值添加到散点图。因此,我可以使用此代码生成散点图,transform_regression用于添加很棒的回归线。
from vega_datasets import data
import altair as alt
import pandas as pd
import numpy as np
cars = data.cars()
chart = alt.Chart(cars).mark_circle().encode(
alt.X('Miles_per_Gallon', scale=alt.Scale(domain=(5,50))),
y='Weight_in_lbs'
)
chart + chart.transform_regression('Miles_per_Gallon','Weight_in_lbs').mark_line()
Run Code Online (Sandbox Code Playgroud)
这是图表
然后我正在寻找 R 值。因此可以在此代码中使用熊猫,因为我不确定如何使用 Altair 获取 R 值。
corl = cars[['Miles_per_Gallon','Weight_in_lbs']].corr().iloc[0,1]
corl
Run Code Online (Sandbox Code Playgroud)
现在我想知道如何在图表上添加 R 值作为一种标签?
python ×3
altair ×2
pandas ×2
bold ×1
correlation ×1
label ×1
numpy ×1
pymupdf ×1
python-3.x ×1
search ×1