Most voted "ggplot2" questions
ggplot2 is a graphic design package for R based on the principles of "Graph Grammar". It partially replaces the basic Plot of R and the Lattice package, offering a clean and powerful API. It is written and actively maintained by Hadley Wickham.
Learn more…279 questions
Sort by count of
-
3
votes1
answer107
viewsWhat is the difference between facet_wrap() and facet_grid() in ggplot?
The options facet_wrap() and facet_grid() in the ggplot have similar purposes, produce graphs with results stratified by a categorical variable. However, sometimes these options produce…
-
3
votes1
answer29
viewsHow to remove duplicate figures generated by the geom_errorbar function?
How do I remove the other tags generated by the function geom_errorbar()? I only need the marking that is circled in the image. Database dataset = structure(list(structure(c(1L, 1L, 1L, 1L, 1L, 1L,…
-
3
votes1
answer60
viewsGeom_rect does not recognize alpha
I have a chart made with geom_rect, the problem is I’m using the argument alpha and he’s not applying the transparency on the chart. My code: dados %>% mutate(median_x = inicio + floor((fim -…
-
3
votes1
answer30
viewsGraph error with package ggplot2 and function sumarySE
I seek your assistance in solving some problems in constructing a graph with average and standard error in R with the ggplot2 package and summarySE function. In my work I evaluate the effect of…
-
3
votes1
answer85
viewsColoring a map with differing color intensity in ggplot2
I’m trying to create the Plot of a color map of Brazil with a specific color, the "#2D3E50". However, using this color on the map to color from the smallest area (light shade) to the largest area…
-
3
votes1
answer73
viewsggplot2: get color palette used in scale_color
Do you know if it is possible to get the color palette used in scale_color_*? I would like to get the specific colors (Hex color codes) used with the package paletteer in each case to then use it in…
-
3
votes1
answer47
viewsggplot: geom_area - error with aes(Fill)
I have the following data and would like to create a chart with the ggplot2::geom_area() with different colors for the positive and negative values. However, I am getting an error and I am not being…
-
3
votes1
answer55
viewsHow to change values on the y-axis
How do I change the values of the y-axis to 0,5,10,15,20? # Dados da produção da aquicultura 2013-2019 producao_aquicultura = structure(list(Valor = c(19350491, 22082777, 21063695, 20828670,…
-
2
votes2
answers2571
viewsBar graph - ggplot2
I have a data-frame with the structure below. I want to make a simple bar graph that relates the "CID" by type (A, B, C, etc...) with the days of departure and the other with the Calls. df <-…
-
2
votes1
answer252
viewsmultiple columns using geom_lines ggplot
I have this data frame: structure(list(`Exchange Rate` = c(-0.145442175, 0.291096141, 0.489923112, -2.038363166, 1.180430664, 0.188114666, 0.850922634, 1.172142766, -3.980837975, 0.285762444,…
-
2
votes1
answer580
viewsGraph ggplot axis x
This is my date.: datamatrix=structure(list(month = c(1980, 1980.08333333333, 1980.16666666667, 1980.25, 1980.33333333333, 1980.41666666667, 1980.5, 1980.58333333333, 1980.66666666667, 1980.75,…
-
2
votes2
answers1628
viewsI want to generate an R table for Latex
I want to generate a table with the R Summary data with the results I got, I know there’s a library called Stargazer that does, but I couldn’t find the documentation.
-
2
votes1
answer609
viewsHow to insert caption into ggplot maps?
How do I insert the legend and scale the map to degrees? library("rgeos") library("maptools") library("ggplot2") library("mapproj") cores1 = c('brown2', 'aquamarine2', 'darkgray','darkolivegreen1',…
-
2
votes1
answer225
viewsProblem when plotting with ggplot2 R
I am trying to plot a graph in R to display the maximum and minimum values of some variables beyond a line to mark the 0 of y, however the points of the graph come out completely out of order. I am…
-
2
votes1
answer97
viewsDetermine circle size in GGPLOT2 chart caption
Hello! I put these commands in the R: library(ggplot2) lm_smooth <- geom_smooth(method = lm, size = 1) qplot(percwhite, percbelowpoverty, data = midwest, weight = popdensity, size = popdensity) +…
-
2
votes1
answer2622
viewsHow to place values in faceted bar charts in R?
I am trying to generate a bar chart faceted with R, according to data frame and below commands: ############################################### ######___PACKGES UTILIZADOS_____###############…
-
2
votes1
answer200
viewsMultiple Linear Regression in R
Hello, I have data (https://drive.google.com/open?id=1JdgsnJn5VrkL8j1BsfWzqYW9fMGXND6U) of a completely randomized experiment, in which the fungal growth in response to the application of different…
-
2
votes1
answer146
viewsBar Graph in ggplo2, geom_bar()
I made this chart with geom_bar(), would like the bars to be glued to the bottom line, indicated by the arrows. How could you do? Have some function parameter theme() that can solve this problem?…
-
2
votes1
answer693
viewsSubtitles by GGPLOT2
I have this graph created by the geom_bar function(): I would like to separate the two boxes where are plotted to Fill, as follows: How do I do this? which parameter of the Theme() function can I…
-
2
votes1
answer196
viewsColoring specific points in Ggplot - R
I’m doing a graphical analysis of the package data gapminder. Soon, I made the following code: library('gapminder') dados6 <- gapminder ggplot(gapminder, aes(x = continent, y = lifeExp)) +…
-
2
votes2
answers694
viewsDouble bar graph
I am trying to make a double bar chart with the following data frame: Total_CPIs <- data.frame(Período =c(1995, 1999, 2003, 2007, 2011), SP = c(12, 11, 2, 20, 22), RS = c(3, 4, 2, 4, 4)) The…
-
2
votes1
answer1029
viewsCreation of Boxplot in ggplot2
I’m doing some simulations on R. By generating a data.frame and request the impression of boxplots with small sample size and number of samples boxplot is generated perfectly. The problem is when…
-
2
votes1
answer129
viewsHow to put captions on a line chart in ggplo2
I have a line chart with two variables and I need to put the caption of each one, however, I’m not getting. I’m using a code like this: library(ggplot2) data <- c(1:50) dado <- c(1:50) dado1…
-
2
votes1
answer1312
viewsGraphic text position using ggplot2
I need to adjust the position of a text in the bar graph so that it is above the bar. Below the code used base.total %>% group_by(SEXO, REGIME.JURIDICO.FINAL)%>% count() %>% ggplot(.,…
-
2
votes2
answers1047
viewsPresentation of disproportionate rmarkdown chart
Hello, I have the following problem: when I print the chart in Rmarkdown it gets the numbers one over the other, in addition to indicating the month/year in the coordinates also get the wrong view..…
-
2
votes1
answer243
viewsLinetype and Shape in ggplot2 on R
I am using the following code to plot 3 functions: ggplot(data.frame(x = c(0, 2)), aes(x)) + stat_function(fun = exp, geom = "line")+ stat_function(fun = dnorm ,geom = "line")+ stat_function(fun =…
-
2
votes1
answer36
viewsGraph ggplot R prints x-axis variables in non-cohesive charts when using facet_grid()
asia %>% filter(region %in% c("Western Asia and Middle East","Central Asia","East Asia")) %>% group_by(Country) %>% ggplot(aes(x = Country, y = FertRate, col = Country)) + geom_point() +…
-
2
votes1
answer85
viewsGraphic with same color lines for factors
I have a date frame (DF) of consumption per animal and per day Below is the data below of only two animals Animal Dia Consumo 5 9 2533.96 5 10 2329.06 5 11 2943.79 5 12 3361.62 5 13 2890.82 5 14…
-
2
votes1
answer92
viewsDoubts ggplot in bars
Hello, I’m trying to plot a bar graph geom_bar, where X corresponds to the days of the month, in this case February, and y refers to the value of two variables v1 e v2 for the day in mode position =…
-
2
votes1
answer454
viewsPanel graphics in ggplot2
I have 25 species and would like to write only a script in which I could have a separate chart for each species (in total would be 25 small charts, in a grid 5x5). I would also like to make two…
-
2
votes1
answer3263
viewsHow to insert point and line caption in ggplot?
How do I insert the dots in the caption? The purple dot on the caption "base1" and the red dot on the caption "base2"? lines = 'Mes Lg1 total1 Lg2 total2 Jan base1 1450 base2 89 Fev base1 1700 base2…
-
2
votes1
answer159
viewsUse of summarySE function for graph construction in ggplot2
Hello, I am looking for an aid to improve a script in R. I develop it with the help of the ggplot2 package. I have some errors and would like to get some feedback. In the study, I evaluated the…
-
2
votes1
answer250
viewsError generating graph with package ggplot2 in R
Hello, I am looking for an aid to improve a script in R. I develop it with the aid of the ggplot2 package. I intend to show a graph with media and standard error and the data set points. I used the…
-
2
votes1
answer748
viewsBar graph name in ggplot2
I made this chart with geom_bar(), would like the title (a) followed the direction of ylab, but I’m not getting it. I used this function parameter geom_bar() theme(plot.title = element_text(hjust =…
-
2
votes1
answer115
viewsCustomize x-axis values (abscissas) in the geom_smooth or geom_ribbon functions of the ggplot2 package
Although I already have a similar question the solution presented there scale_x_continuous did not meet me in my problem. Normally for that I would use the function factor in…
-
2
votes1
answer2893
viewsChange title and caption colors in ggplot2
How do I change the field pop and continent. I want to put in Portuguese (Population and Continent). The data are in R through the package library(Gapminder). I used the following command:…
-
2
votes1
answer198
viewsDifference in Main Component Analysis (PCA) graphs
Today I was analyzing a data set and realized something I had never noticed before. In order to visualize a multivariate data set, I created your PCA and designed the observations into the two main…
-
2
votes2
answers213
viewsReorder bars in ggplot2 according to one of the fill variables (Fill)
Hello, I have a graph that shows the proportion of equipment available in schools of Pernambuco, and I would like to order it from the equipment with greater presence (greater has) to those with…
-
2
votes1
answer290
viewsGrouping of data - Histogram R
Good morning, everyone. I’m trying to do a histogram with ggplot(), but I’m having a hard time with one detail. Basically I would like to manually group the data that gets inserted inside each bin…
-
2
votes2
answers200
viewsHow to modify only the line of the legend that identifies the group?
How can I change only the thickness of the color lines in the caption that identify the groups? I do not send the dput() graph pq are more than 40 thousand lines. I send a cutout of the figure to…
-
2
votes1
answer121
viewsHow to plot two geom_line (one from each group) into a single Plot in ggplot2
I have 2 dfs (one from each group) that correspond to 76 channels of signal acquisition in 20sec. of analysis. To decrease the work of repeating several times (76x) the geom_line function I stacked…
-
2
votes2
answers190
viewsHow to insert lines in the graphs to denote post-hoc differences between compared groups?
I need to graphically identify post-hoc differences between mean comparisons. As the figure below: Send a dput with simple data to facilitate graph generation (not the figure), as well as the chart…
-
2
votes1
answer495
viewsHow to adjust the size of an already embedded geom_plot to another ggplot2 chart?
In this situation below, how can I adjust the size of the geom_plot() added to geom_jitter() once the function tibble(x = 12, y = 4.5, plot = list(dens_iris)) only allowed to identify the…
-
2
votes1
answer62
viewsError: Discrete value supplied to Continuous Scale (error function to position "n" in graph)
I’m crowding a few boxplots to compare, year by year, the grades of students periodized and not periodized. I am using the function below to plot these graphs. Within the function stat_summary I’m…
-
2
votes1
answer405
viewsHow to rename caption and caption values in fviz_cluster()
I am working with k-Means and therefore need to generate intuitive graphics. However, the graph generated by the function fviz_cluster() is not responding to usual functions in ggplot objects. In an…
-
2
votes0
answers94
viewsLabel reversed Stacked Bar R
The feminine/masculine colors pros generos appear correctly on the chart, however, when I add "Labels" the amount that is gen F appears below and gen M appears in the middle p4 <- ggplot() +…
-
2
votes1
answer166
viewsHow to add two captions using geom_sf and geom_raster in ggplot?
I have these dice: structure(list(lon = c(-84.375, -84.125, -83.875, -83.625, -83.375, -83.125, -82.875, -82.625, -82.375, -82.125, -81.875, -81.625, -81.375, -81.125, -80.875, -80.625, -80.375,…
-
2
votes1
answer699
viewsPlot of lines with months on the x-axis in ggplot - R
I’m taking R classes and an exercise came up to make a chart of lines on ggplot2 with data of flight delays per airport. On the X axis should stay the months (which are in numbers), but when…
-
2
votes1
answer71
viewsShow only ggpairs upper or lower triangle
The ggpairs function of the Ggally package implements a version of the pairs for ggplot. The chart type displayed in the upper, lower and diagonal triangle of the matrix can be customized with the…
-
2
votes1
answer168
viewsDisplay data label in line chart in ggplot2
I have a line chart and I would like to put the label of the state corresponding to the line, but the label is coming out on each data available and not only the last one: Code I’m working on:…