按组的gganimate树图在R中存在渲染问题

如何解决按组的gganimate树图在R中存在渲染问题

我想创建一个gif,在geom_treemap上显示推文文本,我正通过gganimate对这些树形图的过渡进行计时。数据是根据日期进行分组的,但是转换似乎错过了这个分组因素,并且它会在每个转换中继续添加文本,而不是为每个日期提供刷新的树形图。数据,代码和gif如下提供。

A)数据

    structure(list(date = structure(c(18552,18552,18553,18554,18555,18556,18557,18557),class = "Date"),user = c("bc670ht","DelVeneto","JMLudes","fmch6444","_ReaalAmerican_","andrenaleen","VintageloverH","semperdiced","fouririshlads","hahnalytics","mackinnom_kari","BasilNSybil","Neffinger","SGFilmComposer","o2bnobx","courageousgirl2","BlueGirlsRule","john_sipher","tariqpanja","ted_rood","InTheNoosphere","MarchForTruth17","AngelaZiegenfe1","jean_mumford","azlibertad","JJohnsonLaw","IAmJoeTrudeau","biannagolodryga","JamesFourM","Politics_PR","Sundae_Gurl","Not_PaulRevere","RWTrollPatrol","ProfessorCrunk","jilevin","harveyjkaye","drewmckevitt","ranger2911","gerardobarrios","CharlesLEllis4","votevets"
),text = c("RT @bc670ht: No,There Isn’t Evidence That Trump Owes Money to Russia t.co/hzSHqHJDH0","RT @DelVeneto: t.co/entXcVtqKM","RT @JMLudes: @atrupar Literally from the Russian playbook. t.co/KHyR9lG9bV","RT @fmch6444: @EvanMcMullin @AshaRangappa_ This is how they do it t.co/iKLbt3vFUZ","RT @_ReaalAmerican_: @MariaBartiromo @SenRonJohnson @FoxNews @SundayFutures t.co/KxhpQCAUMa","RT @andrenaleen: @daveweigel @HeerJeet Gee,I wonder where they get this idea.\n\nt.co/Jrev6FO8Zu","RT @VintageloverH: @AngrierWHStaff As discussed here: t.co/URrZwfcEY9","RT @semperdiced: t.co/t6fquynxSO","RT @fouririshlads: @JoyceWhiteVance t.co/fZ1CB07OOS","RT @fmch6444: @clearing_fog Ah ha! I knew I read it somewhere!\nt.co/6nZgV5ja6M","RT @hahnalytics: @OreoBuffy5 @katie_robertson @brianstelter yup. putin playbook.\n\nt.co/eExN4w5oVG","RT @mackinnom_kari: @atrupar Of course he does. It’s right on schedule. \n\nt.co/UmbuvPe8WZ","RT @BasilNSybil: @waltshaub @SenRonJohnson StandArd Putin play\nt.co/zDCIJAMLhu","RT @Neffinger: @BrookeSingman @DNI_Ratcliffe @AdamSchiff t.co/dOe0VDPgWf","RT @SGFilmComposer: @TheRickyDavila Foes of Russia Say Child Pornography Is Planted to Ruin Them t.co/eTkY0xD2iP","RT @o2bnobx: @RVAwonk @goldengateblond Weird how there’s a pattern... t.co/ExrW1VDAge","RT @courageousgirl2: Trump and Miss Moscow: Report Examines Possible Compromises in Russia Trips t.co/HrCTRppm4P","RT @BlueGirlsRule: 2/2020 \n\nLawmakers are warned Russia is interfering in US elections\nt.co/0Dbdy6VLtp\n\n3/2020","RT @john_sipher: They just can’t help themselves.  t.co/9qwHrteO3U","RT @tariqpanja: Russia Got Caught Doping at the Olympics,Now They've Got Caught Hacking Them\n\nt.co/BxYT7AlNRC","RT @ted_rood: Is the Trump Campaign Colluding With Russia Again? t.co/T9v1IU8am7","RT @InTheNoosphere: Is the Trump Campaign Colluding With Russia Again? t.co/0X4B6CvNaE","RT @MarchForTruth17: Is the Trump Campaign Colluding With Russia Again? -@michelleinbklyn t.co/9HsAFkD3D5","RT @AngelaZiegenfe1: Spoiler Alert: YES\n\nIs the Trump Campaign Colluding With Russia Again? t.co/U9aFaimKFP","RT @jean_mumford: @meiselasb NYTimes ?\n\nNow do ....\nRussia \n&\nSaudi Arabia","RT @azlibertad: Opinion | Is the Trump Campaign Colluding With Russia Again? - The New York Times t.co/OPqU4nDAKt","RT @JJohnsonLaw: After Doping Scandal,Russia Hacked the Olympics,U.S. and Britain Say t.co/ULFS2SofLF","RT @IAmJoeTrudeau: Is the Trump Campaign Colluding With Russia Again? t.co/ioc2XjbUSM","RT @john_sipher: Russia is at war with us and our President is good with it.  t.co/QaqwUWFtYD","RT @biannagolodryga: “Trump has been a godsend to Russia,”\n\nThis pretty much sums it up. \nt.co/O8CSql1hUa","RT @john_sipher: Funny. Russia again.  t.co/9qwHrteO3U","RT @JamesFourM: A reminder:\n\nFoes of Russia Say Child Pornography Is Planted to Ruin Them t.co/TWZtQmsC4M","RT @Politics_PR: U.S. Government and Tech Firms Push Back on Russia (and Trump) t.co/qhfUmSXPzC t.co/tpyYcw0me3","RT @Sundae_Gurl: @nytimes Sounds like Russia.","RT @Not_PaulRevere: @robertjdenault Much better reporting than when they front paged this: t.co/G2IxiJwCQv","RT @RWTrollPatrol: @DonaldJTrumpJr Is the Trump administration colluding with Russia again? \nt.co/6ZEQ4v1KsU","RT @ProfessorCrunk: Latino gender gap. Latino dudes support Trump at 47%. That shit cray. t.co/14mnoG6Cjk","RT @jilevin: Iran and Russia Seek to Influence Election in Final Days,U.S. Officials Warn t.co/EajRkWWUbf","RT @jilevin: U.S. Still Unsure of Havana Syndrome's Cause Years Later t.co/ydfo9j818u","RT @harveyjkaye: via @NYTimes t.co/WquA0H9Ajf","RT @drewmckevitt: Weird how this is also Republican election strategy t.co/LaqB0kOISb t.co/r87LoIuOfu","RT @ranger2911: @DonaldJTrumpJr t.co/1rqRxvKFQo","RT @gerardobarrios: @meiselasb Where was the press conference for Russian interference to help Trump? t.co/ozBliweUbJ","RT @CharlesLEllis4: @Yamiche Iran and Russia obtained voter registration data?!?! You don't say!\nt.co/fD4Cy6Bo8l","RT @votevets: Were these Marines victims of Russian bounties??! ?\n\nt.co/COLVTaeQpR"
),V1 = c(1L,1L,155L,70L,29L,17L,13L,8L,7L,6L,5L,9L,4L,3L,34L,18L,15L,14L,10L,109L,52L,40L,37L,30L,2L,2L)),row.names = c(NA,-52L),groups = structure(list(date = structure(c(18552,.rows = structure(list(
    1:2,3:12,13:22,23:32,33:42,43:52),ptype = integer(0),class = c("vctrs_list_of","vctrs_vctr","list"))),6L),class = c("tbl_df","tbl","data.frame"),.drop = TRUE),class = c("grouped_df","tbl_df","data.frame"))

请注意上述数据,因为我在发布此问题时不接受数据,所以我已从文本中删除了https://

B)代码

t <- ggplot(t7b4,aes(area = V1,fill = user,label = user)) + 
  geom_treemap() + 
  geom_treemap_text(place = "centre",grow = T,reflow = T,colour = "dark blue",min.size = 0) +
  transition_reveal(date) +
  ease_aes('linear') +
  theme(legend.position = 'none') +
  labs(title = "Tweets: {frame_along}")

animate(t,length(unique(t7b4$date)),.4,width = 1000,height = 600)

C)Gif图片

See Animation

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res