ggplot2

Is it possible to draw diagrams in R?

冷暖自知 提交于 2021-02-05 20:27:37
问题 I was wondering if there is any package in R that could use x, y coordinates and shape sizes to draw something like this: I have the coordinates of vehicles' front centers and their sizes (length and width). Edit This is what the original data set looks like: > head(df) Vehicle.ID Frame.ID Global.X Global.Y Vehicle.Length Vehicle.width Lane Preceding.Vehicle.ID Following.Vehicle.ID Spacing Headway 1 2 43 6451214 1873261 14.5 4.9 2 0 13 0 0 2 2 44 6451217 1873258 14.5 4.9 2 0 13 0 0 3 2 45

Is it possible to draw diagrams in R?

﹥>﹥吖頭↗ 提交于 2021-02-05 20:24:19
问题 I was wondering if there is any package in R that could use x, y coordinates and shape sizes to draw something like this: I have the coordinates of vehicles' front centers and their sizes (length and width). Edit This is what the original data set looks like: > head(df) Vehicle.ID Frame.ID Global.X Global.Y Vehicle.Length Vehicle.width Lane Preceding.Vehicle.ID Following.Vehicle.ID Spacing Headway 1 2 43 6451214 1873261 14.5 4.9 2 0 13 0 0 2 2 44 6451217 1873258 14.5 4.9 2 0 13 0 0 3 2 45

Is it possible to draw diagrams in R?

元气小坏坏 提交于 2021-02-05 20:24:18
问题 I was wondering if there is any package in R that could use x, y coordinates and shape sizes to draw something like this: I have the coordinates of vehicles' front centers and their sizes (length and width). Edit This is what the original data set looks like: > head(df) Vehicle.ID Frame.ID Global.X Global.Y Vehicle.Length Vehicle.width Lane Preceding.Vehicle.ID Following.Vehicle.ID Spacing Headway 1 2 43 6451214 1873261 14.5 4.9 2 0 13 0 0 2 2 44 6451217 1873258 14.5 4.9 2 0 13 0 0 3 2 45

How can I colour variables in a ggplot without creating multiple regression lines?

北城以北 提交于 2021-02-05 12:13:37
问题 I'm creating a ggplot and I want to colour data points by the transect they came from. However when I do this using the colour=transect argument I end up with a regression line for each transect as well: Here is my code: ggplot(data=leaf.data, aes(x=distance.from.ecotone..m., y=mean.herbivory....,colour=transect)) + geom_point() + geom_smooth(method = "lm", na.rm = TRUE, fullrange= TRUE, aes=(group=1))+ labs(x="Distance from Ecotone (m)", y="Mean Herbivory per Tree (%)", title="Herbivory as a

Stick Plot for wind speed and direction data in ggplot

只谈情不闲聊 提交于 2021-02-05 11:30:58
问题 I'd like to plot a stick plot for wind speed/ direction data similar to this: https://www.researchgate.net/figure/Stick-plot-of-mean-daily-wind-speed-and-direction-measured-at-Valentia-Island-from_fig5_226577448 I've found a good plot in the excelent oce package, but I'd like to make this same kind of plot using ggplot (or plotley). WindSpeed<-c(1,2,3,5,7,2,3,4,5,6,7,8) WindDir<-c(180,90,320,200,350,10,270,50,9,100,110,129) TimeStamp<-c("2018-01-02 01:00","2018-01-02 02:00","2018-01-02 03:00"

Stick Plot for wind speed and direction data in ggplot

偶尔善良 提交于 2021-02-05 11:30:22
问题 I'd like to plot a stick plot for wind speed/ direction data similar to this: https://www.researchgate.net/figure/Stick-plot-of-mean-daily-wind-speed-and-direction-measured-at-Valentia-Island-from_fig5_226577448 I've found a good plot in the excelent oce package, but I'd like to make this same kind of plot using ggplot (or plotley). WindSpeed<-c(1,2,3,5,7,2,3,4,5,6,7,8) WindDir<-c(180,90,320,200,350,10,270,50,9,100,110,129) TimeStamp<-c("2018-01-02 01:00","2018-01-02 02:00","2018-01-02 03:00"

ggplot: boxplot sort

十年热恋 提交于 2021-02-05 09:36:22
问题 How do I sort a boxplot in ggplot? Here's what I'm trying to plot: qplot( row.names(pcaDF),pcaDF[,1],data=pcaDF,geom="boxplot") + coord_flip() and here's the structure of pcaDF > str(pcaDF) 'data.frame': 108 obs. of 1 variable: $ sort(plotdata[, 1], decreasing = F): num -5.89 -5.52 -4.66 -4.54 -3.92 ... 回答1: Sorting in ggplot is regulated by the levels in the factors. To control the sorting of factor: A in df: df$A = factor(df$A , level = sort(unique(df$A)) ) 回答2: This question is answered

How to insert a legend in a GGPLOT with multiple time series

巧了我就是萌 提交于 2021-02-05 09:31:03
问题 I'm trying to plot multiple times series on a single graph with GGPLOT . The data set is a Data Frame with the dates in date format on the first column, named Time , and the times series on the other columns, named V1, V2...etc.. I tried: gg1=ggplot() + geom_line(data=PCA2, aes(x=Time, y=V2, group=1), lwd=1.1, color="red") + geom_line(data=PCA2, aes(x=Time, y=V3, group=1), lwd=1.1, color="blue")+ scale_color_discrete(name = "PCA series", labels = c("V2", "V3")) print(gg1) but I just get this

Grouped bar chart using ggplot2

情到浓时终转凉″ 提交于 2021-02-05 09:30:30
问题 I have some data structured in the same way as the following: structure(list(respectfromsuperior = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, NA, 2L, 1L, 1L, 1L, 1L, 2L), .Label = c("agree", "disagree"), class = "factor"), respectideserve = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L), .Label = c("agree", "disagree"), class = "factor"), undesirablechange

How to insert a legend in a GGPLOT with multiple time series

和自甴很熟 提交于 2021-02-05 09:29:47
问题 I'm trying to plot multiple times series on a single graph with GGPLOT . The data set is a Data Frame with the dates in date format on the first column, named Time , and the times series on the other columns, named V1, V2...etc.. I tried: gg1=ggplot() + geom_line(data=PCA2, aes(x=Time, y=V2, group=1), lwd=1.1, color="red") + geom_line(data=PCA2, aes(x=Time, y=V3, group=1), lwd=1.1, color="blue")+ scale_color_discrete(name = "PCA series", labels = c("V2", "V3")) print(gg1) but I just get this