You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I'm having difficulties with getting my heat map axes to order properly. I've tried arranging the data, and setting reorder = FALSE, but only one axis will be ordered properly: either the y-axis is in proper numeric order (1 - 24), or the x-axis is ordered properly (day of week, ordered factor), but never both.
Here is my code:
heatmap_df <- df %>% group_by(hour_of_day, day_of_week) %>%
summarise(jobs = n()) %>%
dplyr::ungroup() %>%
arrange(day_of_week)
#arrange by day_of_week provides the correct x-axis, arrange by hour_of_day provides the correct y-axis
heatmap_df |>
e_charts(day_of_week, reorder = FALSE) |>
e_heatmap(hour_of_day, jobs) |>
e_visual_map(jobs) |>
e_title(text = "Heatmap of Successful API Requests by Day and Hour",
subtext = "24 hour clock") %>%
e_tooltip(trigger = "item")
The text was updated successfully, but these errors were encountered:
Hi @avenn98, could you kindly share how you managed to reorder x axis based on factor levels?
I read in the manual one can reorder yaxis by echarts4r::e_y_axis(inverse = TRUE) but I am struggling to order x axis according to my factors levels.
[edit] I noticed it is not enough to set factor levels in the data. Data must be literally reordered to make it working:
data <- data.frame(
x = c("B", "A", "C", "D", "E"),
y = c("W", "X", "Y", "Z", "V"),
value = c(5, 7, 3, 9, 2))
desired_order <- c("A", "B", "C", "D", "E")
data <- data %>% dplyr::arrange(match(x, desired_order))
but as you pointed, if you reorder one axis then the other one is getting messy...Any help is welcome!
Hello! I'm having difficulties with getting my heat map axes to order properly. I've tried arranging the data, and setting reorder = FALSE, but only one axis will be ordered properly: either the y-axis is in proper numeric order (1 - 24), or the x-axis is ordered properly (day of week, ordered factor), but never both.
![image](https://user-images.githubusercontent.com/118836272/203360602-a13b8669-673d-4770-80c7-1d2625a18b20.png)
![image](https://user-images.githubusercontent.com/118836272/203360745-92c4feb8-85b3-4efe-9b40-0a1f55156129.png)
Here is my code:
The text was updated successfully, but these errors were encountered: