• 如何创建具有多种形状的ggplot气泡图?

    您好,谢谢! I would like to have four distinct shapes in my bubble plot to represent the different ponds on the x-axis (RHM1 and RHM2 are replicates of the same pond so they should be the same shape). I figured this should be straightforward, yet here I am, ho...
  • 如何更改ggplot中的点形状

    我正在尝试将ggplot中的点形状更改为不同的形状,而不是均匀的圆形,但保留不同的颜色,我认为它比仅圆形更好的视觉标识符,我尝试在geom_point中使用: aes(shape = c(0,1,2,8)) 我收到一个错误: Error: A continuous variable can not be mapped to shape 这是我的代码: library(repr, warn.conflicts = FALSE) options(repr.plot.width=3.5, repr.plot.h...
  • 基于因子列的阴影面

    这是我的数据的采样示例... SKOV<-as.data.frame(structure(list(sample_id = c(147, 167, 18, 131, 17, 222, 270, 19, 173, 56, 265, 151, 250, 273, 17, 61, 324, 279, 161, 144, 312, 97, 88, 167, 112, 146, 30, 17, 52, 99, 188, 135, 184, 277, 93, 305, 37, 264, 253, 74, 299,...
  • 使用gghighlight时为多个geom_hlines创建图例

    我想在geom_hline中为水平线创建图例。我使用的数据来自3个不同的数据框。我也在使用gghighlight,我相信它会掩盖任何传说。在这种情况下,我如何强制使用图例? 这三个数据帧是: 1)“数据集”,用于存储所有点的值 2)“限制”,其中包含某些参数的最大值,最小值和目标 3)“均值”,其中包含每个参数的均值。 以下是数据集的最小可重现示例: dataset <- data.frame( param = c('A','A','A','A','A', 'T','T','T','T','T', 'N...
  • 条宽度相等的facet_wrap

    我在创建带有两个组的多面条形图时遇到了麻烦,因为最终我得到了宽度不相等的条形图。 Most of the solutions involve the use of facet_grid. However, am comfortable with facet_wrapsince I need to separate my two groups and have group 1 plots ontop of group 2 and facet_wrap has an option of specifying n...
  • 在ggplotly图上添加文本标签

    I have compiled the following code in R using ggplot and plotly. Everything with my graph is fine, however I would like to add a text label in the top right corner which will display my R Squared for the model I've specified. When I try to use the stat_pol...
  • ggplot2软件包中的躲避点不起作用

    I am not able to get a position_dodge to work for ggplot2 (version 3.3.0) for my data set even though I am able to make it work for a toy dataset (based on the discussion in a very early version here). 首先,什么起作用: library(ggplot2) dat <- data.frame(x=1:2, y=...
  • 在ggplot中精细控制日期X轴标签

    我有一个R脚本,可以下载covid测试数据并进行一些处理以得出每周在选定州的总人口百分比和阳性测试率(按周汇总)的总计。下面的R脚本使用了一个大字样来代替可重复性下载和处理数据 stateWeekly <- structure(list(Date = structure(c(1586044800, 1586649600, 1587254400, 1587859200, 1588464000, 1589068800, 1589673600, 1586044800, 1586649600, 15872544...
  • ggplot刻面上的整数中断

    library(tidyverse) df <- tibble(col1 = rep(c("A", "B"), 2), col2 = c(0.4, 0.7, 3, 9), col3 = c("I", "I", "II", "II")) #> # A tibble: 4 x 3 #> col1 col2 col3 #> <chr> <dbl> <chr> #> 1 A 0.4 I #> 2 B 0.7 I ...
  • 相对频率条形图未加1 — geom_bar

    我正在尝试为种族和教育创建一个相对频率条形图。因此,例如,拥有学士学位的亚洲人的相对频率应为拥有学士学位的亚洲人的数量除以数据框中的亚洲人总数。 My code is below, inspired by this post. But I can't figure out why my relative frequencies aren't summing to 1. There aren't any NA's in the data, so I'm a little baffled. df %>% ...
  • 填充值未映射到正确的因子ggplot

    我正在尝试绘制由变量着色的散点图,其中x轴上的值使用geom_rect填充。但是我无法弄清楚如何使因子以正确的顺序映射。 这是我的数据样本: head(prod_cons_diff, n = 10) # A tibble: 10 x 10 country year cons.e iso3c terr.e diff.prod.cons.e prod.cons continent xstart xend <chr> ...
  • 在为geom_point添加色彩美学时遇到问题吗?

    I'm attempting to add a colour aesthetic to my geom_point, which depicts the year the datapoint was taken. I've attempted the colour = and fill = but have provided less than desirable results. I think this is primarily to do with calling for the column nam...
  • 调整和移动手动grob图例ggplot

    I have a ggplot2 object that I'm trying to add a legend for some vlines. I followed the following:(ggplot2: manually add a legend) but I was unable to get my desired output. Any suggestions are much appreciated. 我要去的地方: 我想要的输出是将手动图例直接放在“物种”图例的上方(或下方)。 lib...
  • 尝试在R中手动重新排列条形图

    我需要此图表以不同顺序显示条形图。 “ pretest”栏必须是第一个。除了更改标签外,什么都没有发生。非常感谢您的帮助! 我一直在使用此代码来更改因子水平。 plot_data2 <- main_data %>% dplyr::select(training_type, C1_reps, C2_reps, P1_reps, P2_reps, pretest_result) %>% drop_na(pretest_result) %>% gather(test, reps, C1_reps, C...
  • ggplot自定义图例代替默认

    I've searched and tried a bunch of suggestions to be able to display a custom legend instead of the default one in a grouped scatter ggplot. I've tried this and this and following this among others. For instance, let's say I have a df like this one: df = ...
  • gganimate无法使动画流畅

    我已经尝试了好几天了,但是我无法理解我所缺少的。 gganimate似乎没有在帧之间添加任何过渡。 I am using the Tour de France dataset from the tidytuesday. From this, I made a dataframe with the winner's country over the years. I have the cumulative number of victories for each year and added the rank...
公告

欢迎访问 goshare  点击这里设置您的邮箱  可以接收站内跟帖、回复邮件提醒,不错过任何一条消息。

关注公众号订阅更多技术干货! 码农俱乐部