【发布时间】:2023-04-05 21:11:04
【问题描述】:
到目前为止,我已经花了几个小时来完成 plotnine 中的轴缩放。 到目前为止我发现的所有东西都不起作用。
是数据,是定义图形的代码吗,希望大家能看出什么问题。
数据如下:
数据类型有:
concat object
direction object
date_trunc timedelta64[ns]
comment object
timestamp datetime64[ns]
dtype: object
以下代码按预期创建图表:
ch_time_plot = (p9.ggplot(data= ch_time,
mapping= p9.aes(x= 'timestamp',
y= 'date_trunc',
color= 'direction'))
+ p9.geom_line()
+ p9.theme(axis_text_x= p9.element_text(rotation=90))
)
# ch_time_plot += p9.ylim(0,5)
# => TypeError: Discrete value supplied to continuous scale
# ch_time_plot += p9.expand_limits(y=0)
# => AttributeError: 'int' object has no attribute 'value'
# ch_time_plot += p9.scale_y_continuous(limits = (1, 10))
# => TypeError: Discrete value supplied to continuous scale
ch_time_plot
我想要实现的是始终显示 y 轴 (0) 的原点。一旦我注释掉代码中显示的一行(应该这样做),我就会收到一条错误消息并且没有更多图表。
我的代码有什么问题?
【问题讨论】:
标签: r python-3.x ggplot2 plotnine