ggplot2

Setting specific tile size for geom_tile between two graphs

孤者浪人 提交于 2021-02-18 18:10:54
问题 Might be missing something simple here, but my goal is to plot two heatmaps from two separate matrices. The matrices are of different dimensions, but I want each of the individual plotted tiles to be the same physical measurements between the two graphs. The graph size should then be dependent on the matrix dimensions, since the tile size will be constant between the graphs. Here is an example of two different size matrices and a stripped down version of the graphs I want to make. mat_lg <-

Setting specific tile size for geom_tile between two graphs

耗尽温柔 提交于 2021-02-18 18:10:09
问题 Might be missing something simple here, but my goal is to plot two heatmaps from two separate matrices. The matrices are of different dimensions, but I want each of the individual plotted tiles to be the same physical measurements between the two graphs. The graph size should then be dependent on the matrix dimensions, since the tile size will be constant between the graphs. Here is an example of two different size matrices and a stripped down version of the graphs I want to make. mat_lg <-

Setting specific tile size for geom_tile between two graphs

你离开我真会死。 提交于 2021-02-18 18:09:42
问题 Might be missing something simple here, but my goal is to plot two heatmaps from two separate matrices. The matrices are of different dimensions, but I want each of the individual plotted tiles to be the same physical measurements between the two graphs. The graph size should then be dependent on the matrix dimensions, since the tile size will be constant between the graphs. Here is an example of two different size matrices and a stripped down version of the graphs I want to make. mat_lg <-

Add average lines for categorical scatterplots with single group values

安稳与你 提交于 2021-02-18 17:47:06
问题 I have a categorical scatter plot like this: which I generated in R with the following code (using the ggplot2 library): data <- runif(50, 13, 17) factors <- as.factor(sample(1:3, 50, replace = TRUE)) groups <- as.factor(sample(1:3, 50, replace = TRUE)) data_table <- data.frame(data, factors) g <- ggplot(data_table, aes(y = data_table[, 1], x = data_table[, 2], colour = groups)) + geom_point(size = 1.5) I am trying to add an average line for each x-group, but I can't manage to find the right

Possible to animate polygon fill using gganimate in R?

不打扰是莪最后的温柔 提交于 2021-02-18 17:04:21
问题 I have county level data recording the year an invasive insect pest was first detected in that county between 2002 and 2018. I created a map using ggplot2 and the maps package that fills the county polygons with a color according to the year the pest was detected. **Is there a way to use the gganimate package to animate this map with the first frame filling in only polygons with a detection date of 2002, the second frame filling polygons with a detection date of 2003 or earlier (so 2002 and

How do I plot time (HH:MM:SS) in X axis in R

这一生的挚爱 提交于 2021-02-18 12:43:05
问题 I have tried to read through stackoverflow, blogs, books etc but have been unable to find the answer on plotting time in the x-axis in the following format(HH:MM:SS.000) in R and another quantity on the y-axis. I have the following dataset: Time EcNo 12:54:09.000 -14.47 12:54:10.000 -17.96 12:54:11.000 -15.97 12:54:12.000 -14.61 12:54:13.000 -12.68 12:54:14.000 -10.73 12:54:15.000 -10.54 12:54:16.000 -11.62 12:54:17.000 -12.49 12:54:18.000 -11.12 How would I plot EcNo on Yaxis vs Time(x axis)

Plot SpatialLinesDataFrame with ggplot2

北城以北 提交于 2021-02-18 12:10:30
问题 I would like to plot a SpatialLinesDataFrame calling ggplot with function fortify . The problem I have when using fortify is that I get undesirable lines between my points. I think it has something to do with the plot order Here is an example of my data : Coords <- matrix(c(4095215,2303286,4095275,2303226,4095275,2303196,4095395,2303076, 4095425,2303076,4095485,2303016,4095485,2302896,4095545,2302836,4095545,2302806, 4095575,2302776,4095575,2302746,4095635,2302686,4095635,2302656,4095665

Error using geom_density_2d() in R : Computation failed in `stat_density2d()`: bandwidths must be strictly positive

≯℡__Kan透↙ 提交于 2021-02-18 10:29:25
问题 In a attempt to make a test 2d density plot with ggplot2, I used the code snippet: ggplot(df, aes(x = S1.x, y = S1.y)) + geom_point() + geom_density_2d() and I got the error: "Computation failed in stat_density2d() : bandwidths must be strictly positive" My dataframe looks like this: > df transcriptID S1.x S1.y S2.x S2.y DQ459412 0.000000 0.000000 0.000000 0.000000 DQ459413 1.584963 2.358379 4.392317 3.085722 DQ459415 0.000000 0.000000 0.000000 0.000000 DQ459418 0.000000 0.000000 0.000000 0

Get ggplot2 legend to display percentage sign in r

孤者浪人 提交于 2021-02-18 09:10:28
问题 Below is a reproducible example of the issue I am trying to solve. I have created a heatmap of sorts in ggplot2 and things have been going well. Since I have put percentage signs on the data to use with geom_text I would like to make the legend of geom_tile also to display percent signs (I can only multiply the actual values by 100 right now). Ideally I would like the legend bar on the right to show 8%, 4%, 0%, -4%, -8%. #load in libraries require(plyr) require(dplyr) require(reshape2)

Get ggplot2 legend to display percentage sign in r

青春壹個敷衍的年華 提交于 2021-02-18 09:09:13
问题 Below is a reproducible example of the issue I am trying to solve. I have created a heatmap of sorts in ggplot2 and things have been going well. Since I have put percentage signs on the data to use with geom_text I would like to make the legend of geom_tile also to display percent signs (I can only multiply the actual values by 100 right now). Ideally I would like the legend bar on the right to show 8%, 4%, 0%, -4%, -8%. #load in libraries require(plyr) require(dplyr) require(reshape2)