[英]Make bar chart's x-axis markers horizontal or 45 degree readable in Python Altair
I am trying to create a bar chart with year data on x-axis.我正在尝试在 x 轴上创建一个带有年份数据的条形图。 It works but the year marker on x-xais are all in vertical direction and I want to make them more readable - either horizontal or 45 degree.
它可以工作,但 x-xais 上的年份标记都是垂直方向的,我想让它们更具可读性 - 水平或 45 度。 I tried using the
year:T
in datatime format but it gave me the year and month markers (I just wanted to have the year markers on xais).我尝试以数据时间格式使用
year:T
,但它给了我年份和月份标记(我只是想在 xais 上有年份标记)。 How do I make the year markers on x-axis either horizontal or 45 degree?如何使 x 轴上的年份标记水平或 45 度?
import altair as alt
from vega_datasets import data
source = data.wheat()
source.info()
abars = alt.Chart(source).mark_bar().encode(
x='year:O',
y="wheat:Q"
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.