- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 echarts4r 生成条形图,但我无法指定轴中值的顺序。
我想根据数值变量“Casos”(按降序排列)对名称(“Estado”变量)进行排序。我试过有序因素但没有成功。
我能够使用 ggplot
+ plotly
以及 highcharter
生成正确的输出。
有什么帮助吗?
TIA
下面是我的 MRE。
library(echarts4r)
library(magrittr)
my.df3 <- structure(list(Estado = c("São Paulo", "Rio de Janeiro", "Ceará", "Pernambuco", "Amazonas", "Maranhão", "Pará", "Bahia", "Espírito Santo", "Santa Catarina", "Minas Gerais", "Distrito Federal", "Rio Grande do Sul", "Amapá", "Paraíba", "Alagoas", "Sergipe", "Rio Grande do Norte", "Paraná", "Acre", "Piauí", "Rondônia", "Roraima", "Goiás", "Tocantins", "Mato Grosso", "Mato Grosso do Sul"), Casos = c(51097, 18486, 18412, 14309, 14168, 9112, 9059, 6204, 5087, 3733, 3435, 2979, 2917, 2910, 2777, 2580, 2032, 1989, 1930, 1694, 1612, 1460, 1295, 1225, 828, 604, 405), Mortes = c(4118, 1928, 1280, 1157, 1098, 444, 914, 225, 212, 73, 127, 46, 111, 86, 154, 150, 37, 92, 116, 52, 57, 50, 24, 61, 14, 20, 12)), row.names = c(NA, -27L), class = c("tbl_df", "tbl", "data.frame"))
my.df3 %>%
e_charts(x = Estado, elementId = "casos") %>%
e_bar(Casos, legend = FALSE, name = "Casos") %>%
e_labels(position = "right") %>%
e_tooltip(
trigger = "item",
axisPointer = list(
type = "line"
)
) %>%
e_title("Casos Confirmados") %>%
e_flip_coords() %>%
e_y_axis(splitLine = list(show = FALSE), axisLabel = list(
interval = 0L
)) %>%
e_x_axis(show = FALSE) %>%
e_toolbox_feature(
feature = "saveAsImage",
title = "Save as image"
) -> echrtCasos
my.df3 %>%
e_charts(x = Estado) %>%
e_bar(Mortes, legend = FALSE, name = "Mortes") %>%
e_labels(position = "right") %>%
e_tooltip(
trigger = "item",
axisPointer = list(
type = "line"
)
) %>%
e_title("Mortes") %>%
e_flip_coords() %>%
e_y_axis(splitLine = list(show = FALSE), axisLabel = list(
interval = 0L
)) %>%
e_x_axis(show = FALSE) %>%
e_connect("casos") %>%
e_toolbox_feature(
feature = "saveAsImage",
title = "Save as image"
) -> echrtMortes
e_arrange(echrtCasos, echrtMortes, rows = 1, cols = 2)
sessionInfo() 的输出是:
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/libopenblasp-r0.2.20.so
locale:
[1] LC_CTYPE=pt_BR.UTF-8 LC_NUMERIC=C LC_TIME=pt_BR.UTF-8 LC_COLLATE=pt_BR.UTF-8
[5] LC_MONETARY=pt_BR.UTF-8 LC_MESSAGES=pt_BR.UTF-8 LC_PAPER=pt_BR.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=pt_BR.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] echarts4r_0.2.3 magrittr_1.5
loaded via a namespace (and not attached):
[1] Rcpp_1.0.4.6 rstudioapi_0.11 tidyselect_1.0.0 xtable_1.8-4 R6_2.4.1
[6] rlang_0.4.6 fastmap_1.0.1 dplyr_0.8.5 tools_3.6.3 clipr_0.7.0
[11] htmltools_0.4.0.9000 ellipsis_0.3.0 yaml_2.2.1 assertthat_0.2.1 digest_0.6.25
[16] tibble_3.0.1 lifecycle_0.2.0 crayon_1.3.4 shiny_1.4.0.2 purrr_0.3.4
[21] later_1.0.0 htmlwidgets_1.5.1 vctrs_0.2.4 promises_1.1.0 glue_1.4.0
[26] mime_0.9 compiler_3.6.3 pillar_1.4.4 jsonlite_1.6.1 httpuv_1.5.2
[31] pkgconfig_2.0.3
最佳答案
已经有一段时间了,但我正在回答这个问题。您可以使用重新排序参数(例如 e_chart(x,reorder=FALSE)
)。
在 OP 的辩护中,John Coene(echarts4r 包的所有者)在被问到这个问题后添加了这个功能:)
来源:https://github.com/JohnCoene/echarts4r/issues/126#issuecomment-585207460
关于r - echarts4r中如何指定坐标轴值的顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61801355/
Matplotlib 的 坐标轴 是用于在绘图中表示数据的位置的工具。 坐标轴是图像中的水平和垂直线,它们通常表示为 x 轴和 y 轴。 坐标轴的作用是帮助观察者了解图像中数据的位置
我在 Objective-C 应用程序中成功使用了 Core Plot。我正在用 Swift 编写一个新应用程序,但遇到了一些麻烦。在我为图表设置 dataSource 之前,坐标轴显示正确且符合预期
Dlib C++ 可以很好地检测地标和估计面部姿势。但是,如何获得头部姿势的 3D 坐标轴方向 (x,y,z)? 最佳答案 我也遇到了同样的问题,前一段时间,搜索并找到了 1-2 篇有用的博客文章,这
我是一名优秀的程序员,十分优秀!