echarts4r icon indicating copy to clipboard operation
echarts4r copied to clipboard

Visual Map range

Open MrMisc opened this issue 1 year ago • 2 comments

I have been tinkering with this for a while now. With scatterplots, I appear to be running into this strange thing where the minimum and maximum range of the visual map tool appears to be randomly selected (I can't seem to identify what feeds into it despite numerous trials and errors. Below is my example using the following dataset


library(ggplot2)
library(pandoc)
library(plotly)
library(echarts4r)
library(echarts4r.assets)
library("ggplot2")
library("plotly")
library("breakDown")
library(dplyr)
library(ggdark)
library(pracma)
library(comprehenr)
library(ggridges)
library(tidyverse)
library(ggplot2)
library(plotly)
library(thematic)
library(extrafont)
library(pandoc)
# Extract x, y coordinates

data<-read.csv("full.csv")

minimum<-min(data$time)
maximum<-max(data$time)
for (separate_zone in unique(data$zone)){

  data_<-subset(data, zone == separate_zone)

  f<-max(max(data$x),max(data$y),max(data$z))/200
  f_<-0.3*f
  
  df<-data_
  df$label<-df$interaction

  my_scale <- function(x) scales::rescale(x, to = c(minimum, maximum))
  print(paste("Minimum and maxima of data are as",min(df$time),"vs",max(df$time),"while for the entire dataset it is",min(data$time),"and",max(data$time)))
  fig<-df |> group_by(interaction) |> e_charts(x) |> 
    e_scatter_3d(y,z,time,label)|>
    e_tooltip() |>
    e_visual_map(time,type = "continuous",inRange = list(symbol = "diamond",symbolSize = c(45,8), colorLightness = c(0.6,0.35)),scale = my_scale,dimension = 3,height = 100) |>
    e_legend(show = TRUE) |>
    e_title(paste("Infection Plot | Zone",separate_zone,sep = " "), "CIC Model")|>
    e_theme_custom("MyEChartsTheme2.json")
  htmlwidgets::saveWidget(fig, paste("Eanimation",separate_zone,".html",sep = "_"), selfcontained = TRUE)
  
  
  
  

  rm(fig)
}

print("First section generation complete!")

Notice how the scatterplot clearly has points that where time>6? And yet the visual map feature appears to only go up till 6 in this example. I would really appreciate an explanation for this and how I can make it such that the range actually takes the entire range of the dataset for time to scrub through, and not a fraction of it.

After much trial and error, I thought for a while that it was determined by the scaling function, which is hopefully clear, has been defined to be defined by the range of the entire time column of the data.

MrMisc avatar Nov 26 '23 16:11 MrMisc

Without having tried your example: e_visual_map needs the same minimum and maximum value in each subgroup in order to let it work for every subgroup the same way. Usually I solve this issue by adding extra minimum and maximum data points to each subgroup (in your case "time") with giving this extra data points no values, just NA's.

rdatasculptor avatar Nov 28 '23 15:11 rdatasculptor

@MrMisc did @rdatasculptor helped you ?

munoztd0 avatar Dec 21 '23 14:12 munoztd0