English 中文(简体)
聚合物中的地球-化学物
原标题:Animation of geom_circle in ggplot2 displays unintentional interpolated circles

I created a GIF animation with gifski package in R. Here is the input and output data (sorry I do not know if it can be shared via online storage service). https://drive.google.com/drive/folders/1Zj2tXBKrfNfM3ezi4hKF8He4CVYImT4L?usp=sharing

这是用于估算的原始地图。

“enter像

在估算(测试)中,你可以看到一个圈子被定在底线上的固定红色点,在移动蓝点之间距离过远的地方,其面积(半径)。

这一圈子的信息在<代码>circle_df.rds上作了分类,其中仅包含13秒钟,而存储在<代码>gps.rds上的蓝点信息则包含大约700秒钟。 我所希望的结果是,在<代码>circle_df上的这些圈子,只有在时间框架涉及<代码>circle_df所储存的时间时,才能显示,不过,目前的估算从开始到数据框架结束时,圈子的大小就不断显现。 例如,在<代码>circle_df上的第一和第二圈,时间是11:41和11:31:14,因此,圈子不应在时间之间展示,而是在目前的估算中出现。

这里是一个可再生的例子:

## Google maps API
register_google(key="YOURKEY", write=TRUE)

## Extract satellite image from google maps
map <- ggmap(get_googlemap(center=cor, zoom=18, maptype="satellite"))

## Plot map
p <- map +
  geom_point(data=gps, aes(x=lon, y=lat),
             color="blue", size=2, shape=10) +
  geom_point(data=sensor, aes(x=lon, y=lat),
             color="red", fill="white", size=3.4, shape=21) +
  # Add labels at the center of each point
  geom_text(data=sensor, aes(x=lon, y=lat, label=ID),
            color="red", fontface="bold", size=2.4, vjust=0.24) +
  ## Circle from sensor
  geom_circle(data=circle_df, aes(x0=lon, y0=lat,
                                  color=signal, r=as.numeric(distance_deg)),
              fill=NA, alpha=0.6, linewidth=0.8) +
  scale_color_gradient(low="dodgerblue", high="red",
                       name=expression("Signal Intensity
(-100 to 0)"),
                       # breaks=seq(-100, 0, by=10), limits=c(-100,0),
                       guide = guide_colorbar(title.theme=element_text(color="white", size=10),
                                              label.theme = element_text(color = "white", size=10),
                                              barwidth=1, barheight = 5, nbin = 10)) +
  ## Theme
  theme(axis.title.x=element_blank(),
        axis.text.x = element_blank(),
        axis.title.y=element_blank(),
        axis.text.y = element_blank(),
        axis.ticks = element_blank(),
        rect = element_blank(),
        legend.position=c(0.9,0.14),
        plot.margin = unit(c(0, 0, 0, 0), "cm")) +
  ## Animation
  ## Variable to animate
  transition_time(time) +
  ## Title
  ggtitle( Time:, {frame_time} ,
          subtitle =  Frame {frame} of {nframes} ) # + 
## Add slider
# slider::slidify(gps$time, time_range=range(gps$time))

## Animate
## Number of frames
frame <- as.integer((max(gps$time) - min(gps$time)) * 60)
## Plot
anime <- animate(p, nframes=frame, fps=round(frame/20))
# Change x in frame/x based on duration of animation (x)

## Save
anim_save("test.gif", anime) ; anime
问题回答

实现这一目标的最容易的方法是加入你的圈子,即使用时间栏为ps子,形成一个my子,把圈子组起来。 这样,你们每二次获得国籍,即s not,以便二者在估算中变得空白,而分类变量则否定了默认的推断。 注:

Warning message: Removed 687 rows containing non-finite values (stat_circle()).

这只是 d倒了新来,可以安全地忽视。 在技术上,你可以同时使用红树和环流(df)块,但我刚刚使用df,用于<代码>geom_circle(),以尽量保持你原有的代码中的大部分不变。 我没有APIC钥匙,但其他一切都一样。

library(sf)
library(dplyr)
library(ggforce)
library(gganimate)

gps <- readRDS("C:/test/gps.rds")
circle_df <- readRDS("C:/test/circle_df.rds")
sensor<- readRDS("C:/test/sensor.rds")

# Join circle_df to gps, add variable to stop interpolation of circles
df <- gps %>%
  left_join(., circle_df, by = "time") %>%
  mutate(circletime = 1)

p <- ggplot() +
  geom_point(data=gps, aes(x=lon, y=lat),
             color="blue", size=2, shape=10) +
  geom_point(data=sensor, aes(x=lon, y=lat),
             color="red", fill="white", size=3.4, shape=21) +
  # Add labels at the center of each point
  geom_text(data=sensor, aes(x=lon, y=lat, label=ID),
            color="red", fontface="bold", size=2.4, vjust=0.24) +
  ## Circle from sensor
  geom_circle(data=df, aes(x0=lon.y, y0=lat.y,
                           color=signal, 
                           r=as.numeric(distance_deg),
                           group = interaction(circletime, time)), # Here is the  static  assignment
              fill=NA, alpha=0.6, linewidth=0.8) +
  scale_color_gradient(low="dodgerblue", high="red",
                       name=expression("Signal Intensity
(-100 to 0)"),
                       # breaks=seq(-100, 0, by=10), limits=c(-100,0),
                       guide = guide_colorbar(title.theme=element_text(color="white", size=10),
                                              label.theme = element_text(color = "white", size=10),
                                              barwidth=1, barheight = 5, nbin = 10)) +
  ## Theme
  theme(axis.title.x=element_blank(),
        axis.text.x = element_blank(),
        axis.title.y=element_blank(),
        axis.text.y = element_blank(),
        axis.ticks = element_blank(),
        rect = element_blank(),
        legend.position=c(0.9,0.14),
        plot.margin = unit(c(0, 0, 0, 0), "cm")) +
  ## Animation
  ## Variable to animate
  transition_time(time) +
  ## Title
  ggtitle( Time:, {frame_time} ,
          subtitle =  Frame {frame} of {nframes} ) # + 
## Add slider
# slider::slidify(gps$time, time_range=range(gps$time))

## Animate
## Number of frames
frame <- as.integer((max(gps$time) - min(gps$time)) * 60)
## Plot
anime <- animate(p, nframes=frame, fps=round(frame/20))
# Change x in frame/x based on duration of animation (x)

## Save
anim_save("c:/test/test.gif", anime) ; anime

“result”/





相关问题
images sliding continuously with <table> and jQuery

I m trying to write a little test page that circulates images through a window (see image). I have colored boxes inside a table (gray border), with each box being a element. <table id="boxes" ...

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

Disable Windows 7 touch animation in WPF

In Windows 7 when you touch the screen there is a short animation that occurs at the touch point. In my WPF app I want to display my own touch points, without showing the one supplied by Windows. ...

jQuery block moving

I wanna move a div block to the top, so I coded like this: CSS part: .movingPart{ margin-top:80px; } jQuery part: $(document).ready(function() { $( #btn ).click(function() { $( .movingPart )....

Direct 2D gnuplot PNG animation?

Can anyone please confirm that yes/no Gnuplot 4.5 (on CVS) can output 2D animated PNG files? I have numerous datasets but one line that I d like to show iteratively in 3 different places in my graph. ...

Visual State Manager VS Animations in WPF

There is a lot of talk about the simplicity of Visual States and the transitions between them in WPF/Silverlight. I have the need to generate animations dynamically at runtime, to animate the ...

Create a ImageIcon that is the mirror of another one

I ll like to know if there is a way to create a ImageIcon that is the mirror of another ImageIcon. Searching on Google, I found how to do it by using many AWT libraries. Is there a way to do it with ...

how to drag in the animation in iphone application?

Iphone application is using the static co-ordinates to reach at some points in the application,which is based on the button event. But what i want is when i drag the item than it should reach at some ...

热门标签