kandi background
Explore Kits

markers | Sample app demonstrating use of Android touch APIs

 by   dsandler Java Version: Current License: Apache-2.0

 by   dsandler Java Version: Current License: Apache-2.0

Download this library from

kandi X-RAY | markers Summary

markers is a Java library. markers has no bugs, it has no vulnerabilities, it has a Permissive License and it has high support. However markers build file is not available. You can download it from GitHub.
Sample app demonstrating use of Android touch APIs for pressure-sensitive drawing.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • markers has a highly active ecosystem.
  • It has 218 star(s) with 68 fork(s). There are 26 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 6 open issues and 1 have been closed. On average issues are closed in 1061 days. There are 3 open pull requests and 0 closed requests.
  • It has a positive sentiment in the developer community.
  • The latest version of markers is current.
markers Support
Best in #Java
Average in #Java
markers Support
Best in #Java
Average in #Java

quality kandi Quality

  • markers has 0 bugs and 0 code smells.
markers Quality
Best in #Java
Average in #Java
markers Quality
Best in #Java
Average in #Java

securitySecurity

  • markers has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • markers code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
markers Security
Best in #Java
Average in #Java
markers Security
Best in #Java
Average in #Java

license License

  • markers is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
markers License
Best in #Java
Average in #Java
markers License
Best in #Java
Average in #Java

buildReuse

  • markers releases are not available. You will need to build from source code and install.
  • markers has no build file. You will be need to create the build yourself to build the component from source.
  • markers saves you 1990 person hours of effort in developing the same functionality from scratch.
  • It has 4376 lines of code, 267 functions and 45 files.
  • It has high code complexity. Code complexity directly impacts maintainability of the code.
markers Reuse
Best in #Java
Average in #Java
markers Reuse
Best in #Java
Average in #Java
Top functions reviewed by kandi - BETA

kandi has reviewed markers and discovered the below as its top functions. This is intended to give you an instant insight into markers implemented functionality, and help decide if they suit your requirements.

  • Initializes the icicle .
    • draw the stroke debug graph
      • Handle touch event .
        • Display info dialog .
          • Returns a new pressure based on the current pending pressure .
            • Filters the input and returns the results .
              • Draw the tile to the specified canvas .
                • Handle double click .
                  • Set insets .
                    • Updates the data .

                      Get all kandi verified functions for this library.

                      Get all kandi verified functions for this library.

                      markers Key Features

                      Sample app demonstrating use of Android touch APIs for pressure-sensitive drawing.

                      R plotly separate functional legends

                      copy iconCopydownload iconDownload
                      plot_ly(data = X, x = ~xcoord, y = ~ycoord, 
                              split = ~age,
                              legendgroup = 'age', # create first split and name it
                              legendgrouptitle = list(text = "Age"),
                              type = "scatter", mode = "markers",
                              color = ~score,
                              marker = list(colorbar = list(len = .5, y = .3))) %>% 
                        add_trace(split = ~gender,
                                  legendgroup = 'gender', # create second split and name it
                                  color = ~score,
                                  legendgrouptitle = list(text = "Gender")) %>% 
                          colorbar(title = 'Score')
                      
                      library(tidyverse)
                      library(plotly)
                      plot_ly() %>%
                        add_markers(data = X,
                                  x = ~xcoord, 
                                  y = ~ycoord, 
                                  type = "scatter", 
                                  mode = "markers",
                                  #name = "M",
                                  color = I("grey"),
                                  split = ~gender,
                                  legendgroup = 'gender', 
                                  legendgrouptitle = list(text = "Gender")) %>%
                        add_markers(data = X,
                                    x = ~xcoord, 
                                    y = ~ycoord, 
                                    type = "scatter", 
                                    mode = "markers",
                                    #name = "M",
                                    color = I("grey"),
                                    split = ~age,
                                    legendgroup = 'age', 
                                    legendgrouptitle = list(text = "Age")) %>%
                        add_trace(data = X,
                                  x = ~xcoord, 
                                  y = ~ycoord, 
                                  type = "scatter", 
                                  mode = "markers",
                                  name = "",
                                  marker = list(color = ~score,
                                                colorbar = list(len = .5, y = .3)))
                      
                      library(crosstalk)
                      
                      #SharedData object used for filters and plot
                      shared <- SharedData$new(X) 
                      
                      crosstalk::bscols(
                        widths = c(2, 10),
                         list(
                           crosstalk::filter_checkbox("Age", 
                                                      label = "Age",
                                                      sharedData = shared, 
                                                      group = ~age),
                           crosstalk::filter_checkbox("Gender", 
                                                      label = "Gender",
                                                      sharedData = shared, 
                                                      group = ~gender)
                         ),
                         plot_ly(data = shared, x = ~xcoord, y = ~ycoord,
                                 type = "scatter", mode = "markers",
                                 marker = list(color = ~score,
                                               colorbar = list(len = .5, y = .3),
                                               cmin = 0, cmax = 6)) %>%
                          layout(
                            xaxis = list(range=c(.5,6.5)),
                            yaxis = list(range=c(.5,6.5))
                          )
                         )
                      
                      out <- crosstalk::bscols(...) #previous output object
                      
                      library(htmltools)
                      out_tags <- htmltools::renderTags(out)
                      
                      #check all Age and Gender checkboxes
                      out_tags$html <- stringr::str_replace_all(
                        out_tags$html, 
                        '(<input type="checkbox" name="(Age|Gender)" value=".*")/>',
                        '\\1 checked="checked"/>'
                      )
                      out_tags$html <- HTML(out_tags$html)
                      # view in RStudio Viewer
                      browsable(as.tags(out_tags))
                      #or from Rmd chunk
                      as.tags(out_tags)
                      
                      library(crosstalk)
                      
                      #SharedData object used for filters and plot
                      shared <- SharedData$new(X) 
                      
                      crosstalk::bscols(
                        widths = c(2, 10),
                         list(
                           crosstalk::filter_checkbox("Age", 
                                                      label = "Age",
                                                      sharedData = shared, 
                                                      group = ~age),
                           crosstalk::filter_checkbox("Gender", 
                                                      label = "Gender",
                                                      sharedData = shared, 
                                                      group = ~gender)
                         ),
                         plot_ly(data = shared, x = ~xcoord, y = ~ycoord,
                                 type = "scatter", mode = "markers",
                                 marker = list(color = ~score,
                                               colorbar = list(len = .5, y = .3),
                                               cmin = 0, cmax = 6)) %>%
                          layout(
                            xaxis = list(range=c(.5,6.5)),
                            yaxis = list(range=c(.5,6.5))
                          )
                         )
                      
                      out <- crosstalk::bscols(...) #previous output object
                      
                      library(htmltools)
                      out_tags <- htmltools::renderTags(out)
                      
                      #check all Age and Gender checkboxes
                      out_tags$html <- stringr::str_replace_all(
                        out_tags$html, 
                        '(<input type="checkbox" name="(Age|Gender)" value=".*")/>',
                        '\\1 checked="checked"/>'
                      )
                      out_tags$html <- HTML(out_tags$html)
                      # view in RStudio Viewer
                      browsable(as.tags(out_tags))
                      #or from Rmd chunk
                      as.tags(out_tags)
                      

                      Laravel maps markers are not displaying?

                      copy iconCopydownload iconDownload
                      0 => {#1312
                        +"id": 2
                        +"name": "stanage"
                        +"location": "sheffield"
                        +"latitude": 53
                        +"longitude": 2
                        +"created_at": "2022-03-03 21:36:49"
                        +"updated_at": "2022-03-03 21:36:49"
                      }
                      
                      marker = new google.maps.Marker({
                          position: new google.maps.LatLng(places[i].latitude, places[i].longitude),
                          map: map
                      });
                      
                      0 => {#1312
                        +"id": 2
                        +"name": "stanage"
                        +"location": "sheffield"
                        +"latitude": 53
                        +"longitude": 2
                        +"created_at": "2022-03-03 21:36:49"
                        +"updated_at": "2022-03-03 21:36:49"
                      }
                      
                      marker = new google.maps.Marker({
                          position: new google.maps.LatLng(places[i].latitude, places[i].longitude),
                          map: map
                      });
                      

                      Animating child elements in ScrollTrigger GSAP horizontal scroll

                      copy iconCopydownload iconDownload
                      onUpdate: self => console.log("progress", self.progress)
                      
                      if ("scrollRestoration" in history) {
                        history.scrollRestoration = "manual";
                      }
                      $(function() {
                        let container = document.querySelector(".horizontalScroller__items");
                        let elements = gsap.utils.toArray(
                          document.querySelectorAll(".animate")
                        );
                        let intro = document.querySelector(".horizontalScroller__intro");
                        let svg = document.querySelector("svg");
                        let animDone = false;
                        window.scrollPercent = -1;
                      
                        var scrollTween = gsap.to(container, {
                          ease: "none",
                          scrollTrigger: {
                            trigger: ".horizontalScroller",
                            pin: ".horizontalScroller",
                            anticipatePin: 1,
                            scrub: true,
                            invalidateOnRefresh: true,
                            refreshPriority: 1,
                            end: "+=600%",
                            markers: true,
                            onEnter: (self) => {
                              moveAnimate();
                            },
                            onLeaveBack: (self) => {
                              resetAnimate();
                            },
                            onUpdate: (self) => {
                              let p = self.progress;
                              if (p <= 0.25) {
                                let op = 1 - p / 0.23;
                                intro.style.opacity = op;
                                animDone = false;
                              }
                      
                              if (p > 0.23) {
                                moveAnimate();
                                // we do not want to shift the svg by 100% to left
                                // want to shift it only by 100% - browser width
                                let scrollPercent =
                                  (1 - window.innerWidth / svg.scrollWidth) * 100;
                                let shift = ((p - 0.22) * scrollPercent) / 0.78;
                                gsap.to(svg, {
                                  xPercent: -shift
                                });
                              }
                            }
                          }
                        });
                      
                        function resetAnimate() {
                          gsap.set(".animate", {
                            y: 150,
                            opacity: 0
                          });
                        }
                        resetAnimate();
                      
                        function moveAnimate() {
                          for (let e of elements) {
                            if (ScrollTrigger.isInViewport(e, 0.4, true))
                              gsap.to(e, {
                                y: 0,
                                opacity: 1,
                                duration: 2
                              });
                          }
                        }
                      });
                      
                      onUpdate: self => console.log("progress", self.progress)
                      
                      if ("scrollRestoration" in history) {
                        history.scrollRestoration = "manual";
                      }
                      $(function() {
                        let container = document.querySelector(".horizontalScroller__items");
                        let elements = gsap.utils.toArray(
                          document.querySelectorAll(".animate")
                        );
                        let intro = document.querySelector(".horizontalScroller__intro");
                        let svg = document.querySelector("svg");
                        let animDone = false;
                        window.scrollPercent = -1;
                      
                        var scrollTween = gsap.to(container, {
                          ease: "none",
                          scrollTrigger: {
                            trigger: ".horizontalScroller",
                            pin: ".horizontalScroller",
                            anticipatePin: 1,
                            scrub: true,
                            invalidateOnRefresh: true,
                            refreshPriority: 1,
                            end: "+=600%",
                            markers: true,
                            onEnter: (self) => {
                              moveAnimate();
                            },
                            onLeaveBack: (self) => {
                              resetAnimate();
                            },
                            onUpdate: (self) => {
                              let p = self.progress;
                              if (p <= 0.25) {
                                let op = 1 - p / 0.23;
                                intro.style.opacity = op;
                                animDone = false;
                              }
                      
                              if (p > 0.23) {
                                moveAnimate();
                                // we do not want to shift the svg by 100% to left
                                // want to shift it only by 100% - browser width
                                let scrollPercent =
                                  (1 - window.innerWidth / svg.scrollWidth) * 100;
                                let shift = ((p - 0.22) * scrollPercent) / 0.78;
                                gsap.to(svg, {
                                  xPercent: -shift
                                });
                              }
                            }
                          }
                        });
                      
                        function resetAnimate() {
                          gsap.set(".animate", {
                            y: 150,
                            opacity: 0
                          });
                        }
                        resetAnimate();
                      
                        function moveAnimate() {
                          for (let e of elements) {
                            if (ScrollTrigger.isInViewport(e, 0.4, true))
                              gsap.to(e, {
                                y: 0,
                                opacity: 1,
                                duration: 2
                              });
                          }
                        }
                      });
                      

                      mapbox-gl marker issue not sticking

                      copy iconCopydownload iconDownload
                       <link href="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.css" rel="stylesheet">
                      <script src="https://api.mapbox.com/mapbox-gl-js/v2.6.1/mapbox-gl.js"></script>
                      

                      Scope composables to a parent composable

                      copy iconCopydownload iconDownload
                      interface PreferencesScreenScope {
                          @Composable
                          fun PreferencesCheckBox()
                      }
                      
                      private class PreferencesScreenScopeImpl: PreferencesScreenScope {
                          @Composable
                          override fun PreferencesCheckBox() {
                      
                          }
                      }
                      
                      @Composable
                      fun PreferencesScreen(content: @Composable PreferencesScreenScope.() -> Unit ) {
                          PreferencesScreenScopeImpl().content()
                      }
                      
                      PreferencesScreen {
                          PreferencesCheckBox()
                      }
                      
                      interface PreferencesScreenScope {
                          @Composable
                          fun PreferencesCheckBox()
                      }
                      
                      private class PreferencesScreenScopeImpl: PreferencesScreenScope {
                          @Composable
                          override fun PreferencesCheckBox() {
                      
                          }
                      }
                      
                      @Composable
                      fun PreferencesScreen(content: @Composable PreferencesScreenScope.() -> Unit ) {
                          PreferencesScreenScopeImpl().content()
                      }
                      
                      PreferencesScreen {
                          PreferencesCheckBox()
                      }
                      
                      interface PreferencesScreenScope {
                          @Composable
                          fun PreferencesCheckBox()
                      }
                      
                      private class PreferencesScreenScopeImpl: PreferencesScreenScope {
                          @Composable
                          override fun PreferencesCheckBox() {
                      
                          }
                      }
                      
                      @Composable
                      fun PreferencesScreen(content: @Composable PreferencesScreenScope.() -> Unit ) {
                          PreferencesScreenScopeImpl().content()
                      }
                      
                      PreferencesScreen {
                          PreferencesCheckBox()
                      }
                      

                      Installing SQLAlchemy with Poetry causes an AttributeErrorr

                      copy iconCopydownload iconDownload
                      curl https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py > get-poetry
                      
                      python get-poetry --uninstall
                      

                      React Native Maps - takeSnapshot not capturing markers

                      copy iconCopydownload iconDownload
                      const snapshot = this.viewRefTest.takeSnapshot({
                        width: 500,
                        height: 500,
                        format: 'png',
                        quality: 0.5,
                        result: 'file',
                      });
                      
                      snapshot.then((uri) => {
                        console.log(uri);
                      });
                      
                      import { StatusBar } from 'expo-status-bar';
                      import React, { useCallback, useEffect, useRef, useState } from 'react';
                      import { StyleSheet, Text, View, Image } from 'react-native';
                      import MapView, { Marker } from 'react-native-maps';
                      import { Ionicons } from '@expo/vector-icons';
                      
                      export default function App() {
                        const mapRef = useRef(null);
                        const [uri, setUri] = useState(null);
                      
                        const takeSnapshot = useCallback(() => {
                          if (!mapRef || !mapRef.current) {
                            return;
                          }
                          setTimeout(() => {
                            const snapshot = mapRef.current.takeSnapshot({
                              format: 'png', // image formats: 'png', 'jpg' (default: 'png')
                              quality: 0.5, // image quality: 0..1 (only relevant for jpg, default: 1)
                              result: 'file', // result types: 'file', 'base64' (default: 'file')
                            });
                            snapshot.then((uri) => {
                              setUri(uri);
                            });
                          }, 800); // I add some timeout delay because without delay snapnot won't have map or marker.
                        }, [mapRef]);
                      
                        return (
                          <View style={styles.container}>
                            {!uri && (
                              <MapView
                                ref={mapRef}
                                style={{
                                  width: '100%',
                                  height: '100%',
                                }}
                                initialRegion={{
                                  latitude: 37.78825,
                                  longitude: -122.4324,
                                  latitudeDelta: 0.0922,
                                  longitudeDelta: 0.0421,
                                }}
                                onMapReady={takeSnapshot} // I think need wait for map ready to take snapshot but seem still need wait by setTimeout to get fully snapshot
                              >
                                <Marker
                                  coordinate={{
                                    latitude: 37.78825,
                                    longitude: -122.4324,
                                  }}
                                  title={'Test'}
                                >
                                  <Ionicons name="trophy" size={32} color="red" />
                                  <Text>This is a marker</Text>
                                </Marker>
                              </MapView>
                            )}
                            {uri && (
                              <Image
                                style={{
                                  width: '100%',
                                  height: '100%',
                                  resizeMode: 'contain',
                                  borderColor: 'red',
                                  borderWidth: 10,
                                }}
                                source={{
                                  uri,
                                }}
                              />
                            )}
                            <StatusBar style="auto" />
                          </View>
                        );
                      }
                      
                      const styles = StyleSheet.create({
                        container: {
                          flex: 1,
                          backgroundColor: '#fff',
                          alignItems: 'center',
                          justifyContent: 'center',
                        },
                      });
                      
                      
                      const uri = await captureRef(this.viewRefTest, {
                                  format: "png",
                                  quality: 1
                              })
                      
                      <MapView
                        ref={(viewRefTest) => {
                          this.viewRefTest = viewRefTest;
                        }}
                        showsUserLocation={true}
                        followUserLocation={true}>
                        <MapView.Marker coordinate={item.location}>
                          <Image
                            style={{ width: 30, height: 30 }}
                            source={require('../../assets/images/trophy.png')}
                          />
                          <Callout style={{ width: 250, flexDirection: 'row', alignItems: 'center' }}>
                            <Text>$23</Text>
                            <View>
                              <Text style={{ fontSize: 12 }}>Custom Text!</Text>
                            </View>
                          </Callout>
                        </MapView.Marker>
                      </MapView>
                      

                      Automated legend creation for 3D plot

                      copy iconCopydownload iconDownload
                      from matplotlib import pyplot as plt
                      from mpl_toolkits.mplot3d.axes3d import Axes3D
                      import numpy as np
                      import pandas as pd
                      
                      color_names = ["red", "blue", "yellow", "black", "pink", "purple", "orange"]
                      
                      def plot_3d_transformed_data(df, title, colors="red"):
                       
                        ax = plt.figure(figsize=(12,10)).gca(projection='3d')
                        #fig = plt.figure(figsize=(8, 8))
                        #ax = fig.add_subplot(111, projection='3d')
                        
                      
                        if type(colors) is np.ndarray:
                          for cname, class_label in zip(color_names, np.unique(colors)):
                            X_color = df[colors == class_label]
                            ax.scatter(X_color[:, 0], X_color[:, 1], X_color[:, 2], marker="x", c=cname, label=f"Cluster {class_label}" if type(colors) is np.ndarray else None)
                        else:
                            ax.scatter(df.Type, df.Length, df.Freq, alpha=0.6, c=colors, marker="x", label=str(clusterSizes)  )
                      
                        ax.set_xlabel("PC1: Type")
                        ax.set_ylabel("PC2: Length")
                        ax.set_zlabel("PC3: Frequency")
                        ax.set_title(title)
                        
                        if type(colors) is np.ndarray:
                          #ax.legend()
                          plt.gca().legend()
                          
                        
                        ax.legend(bbox_to_anchor=(.9,1), loc="upper left")
                        plt.show()
                      
                      clusterSizes = 10
                      
                      test_df = pd.DataFrame({'Type':np.random.randint(0,5,10),
                                              'Length':np.random.randint(0,20,10),
                                              'Freq':np.random.randint(0,10,10),
                                              'Colors':np.random.choice(color_names,10)})
                      
                      plot_3d_transformed_data(test_df,
                                               'Clustering rare URL parameters for data of date:haha\nMethod: KMeans over PCA \nn_clusters={n_clusters} , Distance_Measure={DistanceMeasure}',
                                               colors=test_df.Colors)
                      
                      # Imports.
                      import matplotlib as mpl
                      import matplotlib.pyplot as plt
                      from mpl_toolkits.mplot3d import Axes3D
                      import pandas as pd
                      import numpy as np
                      
                      # Figure.
                      figure = plt.figure(figsize=(12, 10))
                      ax = figure.add_subplot(projection="3d")
                      ax.set_xlabel("PC1: Type")
                      ax.set_ylabel("PC2: Length")
                      ax.set_zlabel("PC3: Frequency")
                      ax.set_title("scatter 3D legend") 
                      
                      # Data and 3D scatter.
                      colors = ["red", "blue", "yellow", "black", "pink", "purple", "orange", "black", "red" ,"blue"]
                      
                      df = pd.DataFrame({"type": np.random.randint(0, 5, 10),
                                         "length": np.random.randint(0, 20, 10),
                                         "freq": np.random.randint(0, 10, 10),
                                         "size": np.random.randint(20, 200, 10),
                                         "colors": np.random.choice(colors, 10)})
                      
                      sc = ax.scatter(df.type, df.length, df.freq, alpha=0.6, c=colors, s=df["size"], marker="o")
                      
                      # Legend 1.
                      handles, labels = sc.legend_elements(prop="sizes", alpha=0.6)
                      legend1 = ax.legend(handles, labels, bbox_to_anchor=(1, 1), loc="upper right", title="Sizes")
                      ax.add_artist(legend1) # <- this is important.
                      
                      # Legend 2.
                      unique_colors = set(colors)
                      handles = []
                      labels = []
                      for n, color in enumerate(unique_colors, start=1):
                          artist = mpl.lines.Line2D([], [], color=color, lw=0, marker="o")
                          handles.append(artist)
                          labels.append(str(n))
                      legend2 = ax.legend(handles, labels, bbox_to_anchor=(0.05, 0.05), loc="lower left", title="Classes")
                      
                      figure.show()
                      

                      @react-google-maps/api &lt;GoogleMap&gt; onClick not working

                      copy iconCopydownload iconDownload
                      .gm-style-moc {
                          height: unset !important;
                      }
                      

                      How to create animation of vehicle moving form A to B along a route?

                      copy iconCopydownload iconDownload
                      library(tmap)
                      library(gifski)
                      
                      # sample osroute 50 times regularly, cast to POINT, return sf (not sfc) object
                      osroute_sampled <- st_sample(osroute, type = 'regular', size = 50) %>%
                        st_cast('POINT') %>%
                        st_as_sf() 
                      
                      
                      # use lapply to crate animation maps. taken from reference page:
                      #  https://mtennekes.github.io/tmap/reference/tmap_animation.html
                      
                      m0 <- lapply(seq_along(1:nrow(osroute_sampled)), function(point){
                        x <- osroute_sampled[point,]   ## bracketted subsetting to get only 1 point
                        tm_shape(osroute) +            ## full route
                          tm_sf() +
                          tm_shape(data) +             ## markers for start/end points
                          tm_markers() +
                          tm_shape(x) +                ## single point
                          tm_sf(col = 'red', size = 3)
                      })
                      
                      # Render the animation
                      tmap_animation(m0, width = 300, height = 600, delay = 10)
                      
                      library(sf)
                      library(dplyr)
                      library(tidygeocoder)
                      library(osrm)
                      
                      # 1. One World Trade Center, NYC
                      # 2. Madison Square Park, NYC
                      adresses <- c("285 Fulton St, New York, NY 10007", 
                                    "11 Madison Ave, New York, NY 10010")
                      
                      # geocode the two addresses & transform to {sf} data structure
                      data <- tidygeocoder::geo(adresses, method = "osm") %>% 
                        st_as_sf(coords = c("long", "lat"), crs = 4326)
                      
                      osroute <- osrm::osrmRoute(loc = data,
                                                 returnclass = "sf")
                      
                      # sample osroute 50 times regularly, cast to POINT, return sf (not sfc) object
                      osroute_sampled <- st_sample(osroute, type = 'regular', size = 50) %>%
                        st_cast('POINT') %>%
                        st_as_sf() 
                      
                      
                      library(ggplot2)
                      library(ggmap) # warning: has a naming conflict with tidygeocoder!
                      library(gganimate)
                      
                      # ggmap does not quite like geom_sf(), 
                      # the "old school" geom_point will be easier to work with
                      osroute_xy <- osroute_sampled %>% 
                        mutate(seq = 1:nrow(.),
                               x = st_coordinates(.)[,"X"],
                               y = st_coordinates(.)[,"Y"]) 
                      
                      # basemap / the bbox depends on yer area of interest
                      NYC <- get_stamenmap(bbox = c(-74.05, 40.68, -73.9, 40.8),
                                           zoom = 13,
                                           maptype = "toner-background")
                      
                      # draw a map 
                      animation <- ggmap(NYC) + 
                        geom_point(data = osroute_xy,
                                   aes(x = x, y = y),
                                   color = "red",
                                   size = 4) +
                        theme_void() +
                        transition_reveal(seq) +
                        shadow_wake(wake_length = 1/6)
                      
                      # create animation
                      gganimate::animate(animation, 
                                         nframes = 2*(nrow(osroute_xy)+1), 
                                         height = 800, 
                                         width = 760,
                                         fps = 10, 
                                         renderer = gifski_renderer(loop = T))
                      
                      # save animation  
                      gganimate::anim_save('animated_nyc.gif')
                      
                      library(mapdeck)
                      
                      set_token( secret::get_secret("MAPBOX") )
                      
                      mapdeck(
                        location = as.numeric( data[1, ]$geometry[[1]] ) ## for 'trips' you need to specify the location
                        , zoom = 12
                        , style = mapdeck_style("dark")
                      ) %>%
                        add_trips(
                          data = sf
                          , stroke_colour = "#FFFFFF" #white
                          , trail_length = 12
                          , animation_speed = 8
                          , stroke_width = 50
                        )
                      
                      
                      library(mpadeck)
                      library(sfheaders)
                      
                      
                      df_route <- sfheaders::sf_to_df(osroute, fill = TRUE)
                      
                      ## Assume 'duration' is constant
                      ## we want the cumulative time along the rute
                      df_route$cumtime <- cumsum(df_route$duration)
                      
                      
                      ## and we also need a Z component.
                      ## since we don't know the elevation, I'm setting it to '0'
                      df_route$elevation <- 0
                      
                      ## Build the 'sf' object wtih the Z and M dimensions
                      sf <- sfheaders::sf_linestring(
                        obj = df_route
                        , x = "x"
                        , y = "y"
                        , z = "elevation"
                        , m = "cumtime"
                      )
                      
                      
                      library(mapdeck)
                      
                      set_token( secret::get_secret("MAPBOX") )
                      
                      mapdeck(
                        location = as.numeric( data[1, ]$geometry[[1]] ) ## for 'trips' you need to specify the location
                        , zoom = 12
                        , style = mapdeck_style("dark")
                      ) %>%
                        add_trips(
                          data = sf
                          , stroke_colour = "#FFFFFF" #white
                          , trail_length = 12
                          , animation_speed = 8
                          , stroke_width = 50
                        )
                      
                      
                      library(mpadeck)
                      library(sfheaders)
                      
                      
                      df_route <- sfheaders::sf_to_df(osroute, fill = TRUE)
                      
                      ## Assume 'duration' is constant
                      ## we want the cumulative time along the rute
                      df_route$cumtime <- cumsum(df_route$duration)
                      
                      
                      ## and we also need a Z component.
                      ## since we don't know the elevation, I'm setting it to '0'
                      df_route$elevation <- 0
                      
                      ## Build the 'sf' object wtih the Z and M dimensions
                      sf <- sfheaders::sf_linestring(
                        obj = df_route
                        , x = "x"
                        , y = "y"
                        , z = "elevation"
                        , m = "cumtime"
                      )
                      
                      

                      Community Discussions

                      Trending Discussions on markers
                      • R plotly separate functional legends
                      • Laravel maps markers are not displaying?
                      • Animating child elements in ScrollTrigger GSAP horizontal scroll
                      • mapbox-gl marker issue not sticking
                      • Scope composables to a parent composable
                      • Installing SQLAlchemy with Poetry causes an AttributeErrorr
                      • React Native Maps - takeSnapshot not capturing markers
                      • What does 'Zero Cost Abstraction' mean?
                      • Automated legend creation for 3D plot
                      • @react-google-maps/api &lt;GoogleMap&gt; onClick not working
                      Trending Discussions on markers

                      QUESTION

                      R plotly separate functional legends

                      Asked 2022-Mar-29 at 09:55

                      I want to produce a plot via R plotly with independent legends while respecting the colorscale.

                      This is what I have:

                      library(plotly)
                      
                      X <- data.frame(xcoord = 1:6,
                                      ycoord = 1:6,
                                      score  = 1:6,
                                      gender = c("M", "M", "M", "F", "F", "F"),
                                      age = c("young", "old", "old", "old", "young", "young"))
                      
                      plot_ly(data = X, x = ~xcoord, y = ~ycoord, split = ~interaction(age, gender),
                              type = "scatter", mode = "markers",
                              marker = list(color = ~score,
                                            colorbar = list(len = .5, y = .3)))
                      

                      This is the outcome:
                      outcome

                      As you can see, the colorbar is messed up and the two categories are entangled.

                      I need to have separate legends for age (young vs old) and gender (M vs F), that can be clicked independently from one another. This would be the expected outcome:
                      expected outcome


                      Edit 1
                      This is the equivalent with ggplot2:

                      gg <- ggplot(X, aes(x = xcoord, y = ycoord)) +
                        geom_point(aes(color = score, shape = gender, alpha = age), size = 5) +
                        scale_shape_manual(values = c("M" = 19, "F" = 19)) +
                        scale_alpha_manual(values = c("young" = 1, "old" = 1))
                      
                      ggplotly(gg)
                      

                      It does display correctly in ggplot, but breaks when applying ggplotly().

                      Please note that I would favor a solution with the native plotly plot, rather than a post hoc ggplotly() fix as has been proposed in other posts.


                      Edit 2
                      Although the current answers do disentangle the two legends (age and gender), they are not functional. For instance, if you click on the young level, the whole age legend will be toggled on/off. The objective here is that each sub level of each legend can be toggled independently from the others, and that by clicking on the legend's levels, the dot will show/hide accordingly.

                      ANSWER

                      Answered 2022-Mar-19 at 15:21

                      This isn't exactly what you're looking for. I was able to create a meaningful color bar, though.

                      I removed the call for interaction between the groups and created a separate trace. Then I created legend groups and named them to create separate legends for gender and age. When I pull color = out of the call to create a colorbar, this synced the color scales.

                      However, it assigns colors to the labels for age and gender and that's not meaningful! There are a few things that don't line up with your request, but someone may be able to build on this information.

                      plot_ly(data = X, x = ~xcoord, y = ~ycoord, 
                              split = ~age,
                              legendgroup = 'age', # create first split and name it
                              legendgrouptitle = list(text = "Age"),
                              type = "scatter", mode = "markers",
                              color = ~score,
                              marker = list(colorbar = list(len = .5, y = .3))) %>% 
                        add_trace(split = ~gender,
                                  legendgroup = 'gender', # create second split and name it
                                  color = ~score,
                                  legendgrouptitle = list(text = "Gender")) %>% 
                          colorbar(title = 'Score')
                      

                      enter image description here

                      Source https://stackoverflow.com/questions/71494308

                      Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                      Vulnerabilities

                      No vulnerabilities reported

                      Install markers

                      You can download it from GitHub.
                      You can use markers like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the markers component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

                      Support

                      For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

                      DOWNLOAD this Library from

                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      Share this Page

                      share link
                      Consider Popular Java Libraries
                      Try Top Libraries by dsandler
                      Compare Java Libraries with Highest Support
                      Compare Java Libraries with Highest Quality
                      Compare Java Libraries with Highest Security
                      Compare Java Libraries with Permissive License
                      Compare Java Libraries with Highest Reuse
                      Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
                      over 430 million Knowledge Items
                      Find more libraries
                      Reuse Solution Kits and Libraries Curated by Popular Use Cases
                      Explore Kits

                      Save this library and start creating your kit

                      • © 2022 Open Weaver Inc.