【发布时间】:2023-03-08 15:42:01
【问题描述】:
我正在尝试创建一个条形图,显示在 R 的 Highcharter 包中索引到美国价值 (100) 的生活成本。所以我希望条形图从 100 开始,并且延伸到右侧或左侧100. 我有基本的条形图,但我不知道如何将图表的中心线移动到 100。我试图让它看起来像这样:http://drawingwithnumbers.artisart.org/moving-the-center-line-of-a-bar-chart-with-a-gantt-chart/
这是我正在处理的数据:
States <- c('Tennessee','Michigan','Indiana','Ohio','Kentucky','West Virginia','North Carolina','Virginia','Pennsylvania','Delaware','New Jersey','Maryland','New York')
Cost_of_Living <- c(88.7,88.9,90,90.8,90.9,91.1,94.9,100.7,101.7,108.1,125.1,129.7,139.1)
costliving <- data.frame(States, Cost_of_Living)
这是条形图的代码,只是基本条形图
costliving_graph <- highchart() %>%
hc_title(text = "Cost of Living by State (2020)") %>%
hc_add_series (costliving, "bar", hcaes(x = States, y = Cost_of_Living)) %>%
hc_xAxis(categories = costliving$States) %>%
hc_yAxis(title = list(text = "Indexed to the U.S. (U.S. Value = 100)"))%>%
hc_plotOptions (bar = list(colorByPoint = TRUE)) %>%
hc_legend (enabled = FALSE)%>%
hc_tooltip(pointFormat = "MSA Regional Price Parities: {point.y}", headerFormat ="")
costliving_graph
任何帮助都会很棒!提前致谢
【问题讨论】:
标签: r r-highcharter