天道酬勤,学无止境

geom-raster

在具有不同 xy 轴的小平面中绘制多个矩阵(Plot multiple matrices in facets with different x-y axis)

问题 我从一组在线论坛收集了数据,并想使用 ggplot 和 facets(每个论坛一个 facet)绘制表示用户 A 回复用户 B 的次数的矩阵。 这是加载玩具示例的代码: library(ggplot2) library(dplyr) df.edges <- data.frame(from = c('forum1_user1', 'forum1_user1', 'forum1_user2', 'forum1_user2', 'forum2_user1', 'forum2_user1', 'forum2_user2', 'forum2_user2', 'forum3_user1', 'forum3_user1', 'forum3_user2', 'forum3_user2'), to = c('forum1_user1', 'forum1_user2', 'forum1_user1', 'forum1_user2', 'forum2_user1', 'forum2_user2', 'forum2_user1', 'forum2_user2', 'forum3_user1', 'forum3_user2', 'forum3_user1', 'forum3_user2'), weight = 1:12, timestamp = 1:12, subforum = c('forum1'

2021-10-07 22:38:16    分类:技术分享    r   ggplot2   geom-raster

Plot multiple matrices in facets with different x-y axis

I collected the data from a set of online forums and wanted to plot, using ggplot and facets (one facet per forum), the matrix that represent how many times user A replied to user B. Here is the code to load a toy example: library(ggplot2) library(dplyr) df.edges <- data.frame(from = c('forum1_user1', 'forum1_user1', 'forum1_user2', 'forum1_user2', 'forum2_user1', 'forum2_user1', 'forum2_user2', 'forum2_user2', 'forum3_user1', 'forum3_user1', 'forum3_user2', 'forum3_user2'), to = c('forum1_user1', 'forum1_user2', 'forum1_user1', 'forum1_user2', 'forum2_user1', 'forum2_user2', 'forum2_user1',

2021-09-03 08:18:14    分类:问答    r   ggplot2   geom-raster

How can I remove space/gaps between continuous x-values in geom_raster

I am working with some time-frequency decomposed EEG data and want to produce a spectrogram-like figure using ggplot2. But, I end up with blank spaces between each of my time points. Data <- read.csv(url("https://www.dropbox.com/s/al3cygigm86mr3s/Test_Spec_Data.csv?dl=0")) If I create a vanilla geom_raster I get gaps in the x and y data: ggplot(Data,aes(Times,Frequency)) + geom_raster(aes(fill = ERSP)) If I make Frequency a factor, it fills in the y gap; but, the gaps along the x-axis remain: ggplot(Data,aes(Times,factor(round(Frequency,digits=1)))) + geom_raster(aes(fill = ERSP)) I can

2021-07-29 01:13:22    分类:问答    r   ggplot2   heatmap   geom-raster