hrbrmstr / taucharts

:bar_chart: An R htmlwidget interface to the TauCharts javascript library
http://rpubs.com/hrbrmstr/taucharts
Other
65 stars 10 forks source link

Scatter w/ Color + Trendline #76

Open S-UP opened 6 years ago

S-UP commented 6 years ago

Hi,

Just discovered this package. Generally very nice!

Question: It seems not possible to show the trend line simultaneously with colored scatter points when each point is its own group.

What I would like to achieve is having a legend identifying every point (as they represent store fronts in our case). For this I (afaik) need to specify 'color'. Yet color seems to do some sort of grouping as well, thus preventing the trend line to show up (as there is only one data point per group).

Is it possible to add a legend, preferably w/ colored observations, and add a trend line treating all points the same?

Shows a legend + trend line (but grouped):

tauchart(cars_data) %>%
  tau_point("milespergallon", c("class", "price"), color="class") %>%
  tau_trendline() %>% 
  tau_legend()

Shows legend but (almost) no trend line (changed color to vehicle to make the point):

tauchart(cars_data) %>%
  tau_point("milespergallon", "price", color="vehicle") %>%
  tau_trendline() %>% 
  tau_legend()
S-UP commented 5 years ago

As an alternative, if one could calculate trend line values independently and then add them as an additional layer, this could be a work around. But it seems combining e.g. tau_point and tau_line is not currently supported.