Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Visual Map range #595

Open
MrMisc opened this issue Nov 26, 2023 · 2 comments
Open

Visual Map range #595

MrMisc opened this issue Nov 26, 2023 · 2 comments
Labels

Comments

@MrMisc
Copy link

MrMisc commented Nov 26, 2023

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.

@rdatasculptor
Copy link
Contributor

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.

@munoztd0
Copy link
Collaborator

@MrMisc did @rdatasculptor helped you ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants