最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - Altair text on rule mark looks blurry - Stack Overflow

programmeradmin6浏览0评论

For this example on the documenation page:

import pandas as pd
import altair as alt

source = pd.DataFrame({
    "Day": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
    "Value": [55, 112, 65, 38, 80, 138, 120, 103, 395, 200, 72, 51, 112, 175, 131]
})
threshold = 300

bars = alt.Chart(source).mark_bar(color="steelblue").encode(
    x="Day:O",
    y="Value:Q",
)

highlight = bars.mark_bar(color="#e45755").encode(
    y2=alt.Y2(datum=threshold)
).transform_filter(
    alt.datum.Value > threshold
)

rule = alt.Chart().mark_rule().encode(
    y=alt.Y(datum=threshold)
)

label = rule.mark_text(
    x="width",
    dx=-2,
    align="right",
    baseline="bottom",
    text="hazardous"
)

(bars + highlight + rule + label)

The text "hazardous" on the plot looks blurry. How can I control the font properties for a chart specified in this way?

I have tried adding fontWeight="normal" to the mark_text call but the result was unchanged. I would like the text to appear in the same font/weight as the axis labels.

see simplifed vega spec

发布评论

评论列表(0)

  1. 暂无评论