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
-
1
votes3
answers100
viewsHow to generate graphics from a file using a loop in R?
I would like from an archive, which in the case of public safety indicators of Rio de Janeiro, generate charts for each year of the database, showing the progress of these indicators over the…
-
1
votes1
answer655
viewsReorder the columns of a bar chart and its caption
When processing and plotting data in R using tidyverse, it by default leaves the chart bar order in the original column factor order: library(tidyverse) mpg$trans <- as.factor(mpg$trans) mpg…
-
1
votes1
answer61
viewsColor the axis source of a dendrogram in ggplot2 according to a categorical variable
Suppose I need to build a dendrogram on R: library(tidyverse) library(ggdendro) ggdendrogram(hclust(dist(iris[, -5]))) + theme(text = element_text(size = 8)) My chart is created, but I want to…
-
1
votes1
answer116
viewsHow to change the graph structure in ggplot2?
I used the following command line from ggplot2 in R to generate the attached graph: g1 <- ggplot(count, aes(x=cluster, y=Reads)) + geom_point(shape=1) + facet_grid(. ~ Spp) ggplot(count,…
-
1
votes1
answer71
viewsSeasonality chart with ggplot2
I have an example graph that shows the seasonality of a given per month over the years. I would like to adapt the chart to days of the week, I have the example code, but I’m not able to adapt it.…
-
1
votes1
answer255
viewsHow to change bar graph border size in ggplot2
I have a bar graph on the R made with the function geom_col. I would like to decrease the border size, because it is not showing the chart fill. I tried using the argument width, but is only…
-
1
votes1
answer70
viewsHow to change scales of a multifaceted graph in ggplot2
I have a graph composed of 27 subplots, each corresponding to a state, some states, such as SP and RJ have values much higher than other states and the scale of the graph is in larger intervals. Is…
-
1
votes1
answer63
viewsHow to put a delay inside a function in R?
Hello! I would like to put a delay within a function that I am creating to join N-graphics. I realized that in some cases, my function does not expect the eval(parse(text=paste())) generate all…
-
1
votes2
answers462
viewsHow to sort data on Y-axis using ggplot2 in R
I’m charting some data on a Bubble Chart using the package ggplot2 of R. My data is out of order on the Y axis. I would like you to follow the order of the numbers present in the names, for example:…
-
1
votes2
answers126
viewsGeom_area with different filling colors
I have a DF with 4 columns: data, original, previsto and change. The variable change indicates whether the values of the series original are positive or negative, to plot on the chart in green and…
-
1
votes0
answers31
viewsInsertion of line and R 2 equation in a ggplot graph
I would like to know (1) how to obtain the straight line equation and (2) how to insert the line equation and R 2 in my graph generated by ggplot. Researching here, I found similar doubts, but by my…
-
1
votes1
answer45
viewsHalf of boxplot appearing in ggplot2 function
I’m doing a boxplot using ggplot2 package, however, for some external reason, only half of the boxplot is being made for the "Control" and "Commercial IMD" treatments". See below that when doing the…
-
1
votes1
answer37
viewsAdjusted regression line considering different factors in ggplot2
I’m trying to reproduce the graph below, where the internal lines are the adjusted regression lines: However, for some factor is not being plotted what should, ie, is being presented a single line,…
-
1
votes2
answers62
viewsMixed effects model residue plots using ggplot2
I am trying to perform the residue graph of the mixed effects model by means of the ggplot2 function. However, after performing a search I found some available functions but what seems to me is that…
-
1
votes1
answer65
viewshalf-normal waste graph Plots no ggplot2
I am trying to realize the graph presented below regarding the residues in the half-normal Plot in ggplot2. However, I am facing an error entitled Error: data must be a data frame, or other Object…
-
1
votes1
answer92
viewsOverlay graphics in ggplot2 considering adjusted lines
I am trying to superimpose two graphs made in ggplot2, in which the first contains the line adjusted by means of a polynomial model of degree 2 and the other contains the adjusted lines of a model…
-
1
votes0
answers32
viewsHow to create a polygon in nmds graph using ggplot2?
I’m trying to create a polygon but I can’t get it filled and complete. geral<-read.csv2("flora.csv", header=TRUE, stringsAsFactors = T);head(geral) comgeral = geral[,4:ncol(geral)] m_comg =…
-
1
votes1
answer53
views -
1
votes1
answer55
viewsColoring map with ggplot_2
Vi that question here in the so and tried to reproduce to my situation, however, still I did not get the desired result. library(tidyverse) library(geobr) library(RColorBrewer) Below the map of…
-
1
votes1
answer46
viewsHow not to display levels without values using scale_fill_manual?
This is the data.frame for behavior playback: structure(list(CAATINGA = structure(c(2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,…
-
1
votes0
answers30
viewsAssociating grouped bar graph with dots connected per line
Good night I would like to create a secondary y-axis in the graph below where you will plot dots connected per line. The date.frame I wish to plot on the secondary Y axis is: ATR =…
-
1
votes1
answer46
viewsPlot plots grouped bars associated with dots connected by rows
I am not able to perform the grouping of the bars of the graph below even using the argument position = "dodge" in the geom_bar. I found searches only with individual bars, I’m having difficulty…
-
1
votes2
answers47
viewsPlotted graphs separately in single window
I am trying to reproduce the graphic "1" below for the model "2", however I am not having success in my command used. The idea is to separate into different Plots for a better visualization…
-
1
votes2
answers55
viewsLabel of data overlapping
I want to keep data labels organised in a way that does not overlap with each other. The idea is to keep them above geom_point or below.. depending on the position of the line. How can I proceed ?…
-
1
votes1
answer35
viewsPlot order scatterplot ggplot2
I’m doing a scatterplot and mapping the points by color (two categories) and size (a discrete variable). The points must overlap, as they are measured from the same place, in different times The…
-
0
votes2
answers490
viewsError in a - b : non-numeric argument to Binary Operator
Q {r} cambio2 <- data.frame(cambio) cambio2 %>% ggplot(aes(y = receita, x = despesa ) ) + geom_point() I want to make the chart, but there are no dots in the chart and the following error…
ggplot2asked 6 years, 3 months ago Pedro Vicente 13 -
0
votes1
answer372
viewsHow do I make an NMDS chart?
I’d like to show the species on the NMDS chart. I can only show the points of the communities in each group, but I would like to show the species. My chart is like this:…
-
0
votes1
answer51
viewsHow to add or eliminate scatter points on a graph mechanically?
Hello, good morning! I would like to know a routine to add or eliminate scatter points on a graph in a "mechanical" way with the mouse click on the graph! I intend to work with some maps, to mark…
-
0
votes1
answer177
viewsPlot of points Axis X ggplot2 space between numbers
I made a graph of points and lines, as shown below. Only the spaces between the data on the X axis was 20 by 20. I wanted to put 10 by 10. How can I do that?…
-
0
votes1
answer83
viewsPause loop of a gif
Hello! Guys, I have a problem stopping a GIF generated with the Animate function. As it will serve for a PPT presentation, I would like the GIF to be stopped on the last die so that comments can be…
-
0
votes1
answer45
viewsPlot the PCA result in three dimensions
I made a PCA using stats::prcomp and would like to plot the result in three dimensions. It is possible?
-
0
votes2
answers273
viewsPlay ggplot2 graph using multiple facets
I built the chart below using the command grid.arrange package gridExtra, I would like to leave you with the look of the graphics made with multiple facets, using the sample size as facet, is…
-
0
votes1
answer32
viewsHow to use ggTS with ggplot?
Hello, anyone know, have you used ggTS function to make Temperature/Salinity graphs with ggplot? I’m not sure how to install to make it work together with ggplot.…
-
0
votes0
answers62
viewsHow to make a bar graph with ggplot2?
I have a graph generated by a package that would like to replicate it and make some changes to the colors, but I’m not able to understand the code behind the chart. Graph: Code used by the package:…
-
0
votes1
answer46
viewsTime series, how to eliminate gaps between missing periods in ggplot2?
I need to present climate data during an evaluation period, but the time lapses, as observed in Figure 1, using the data (exe2) and the script (1). Naturally the ggplot plot the x-axis as continuous…
-
0
votes1
answer161
viewsBoxplot of ggplot2 giving error (does not make the boxes, only a few points with some scratches), how to fix? OBS: I made other graphics and it worked, only the one stuck
boxef <- ggplot (effectsize, aes(subordemfam, varbiom.efs, colour = classe2)) boxef + geom_point() + geom_boxplot() + xlab("Táxon") + ylab("Effect Size na Variação de Biomassa") + theme_bw() +…
-
0
votes1
answer756
viewsformat X-axis of bars in ggplot2
I generated a bar graph in ggplot2 , but the X axis data was not in the number sequence of "1 - 30", I would like to know how to get the sequence right? here are the Scripts c<- c ("Casal 1",…
-
0
votes0
answers202
viewsAnimated Graphics - R
Hi, I need to make an animated chart that shows the top 10 states. I’m trying, but it’s showing the top 14 and it’s not in the order from the highest to the lowest. Below is the code used: #…
-
0
votes1
answer126
viewsBar graph - Manual grouping of data
Good morning guys. I’m trying to make a bar graph 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 of…
-
0
votes1
answer42
viewsHow to insert year by year into a time series graph in ggplot?
I’m running the remote ggplot(Regulation, aes(Regulation$year, Regulation$rqe)) + geom_line() + geom_point(Colour = "blue")+ Labs(title = "REGULATORY QUALITY ESTIMATOR (1996-2017)", x = "YEAR", y =…
-
0
votes2
answers220
viewsInteraction graph using ggplot2
all right? I am trying to make a graph of interaction between the subjects (Variable S) being these subjects colored in 5 colors (which are the groups (variable G), but is giving the following…
-
0
votes1
answer52
viewsError in program something related to the lines
energia <- data.frame("curso" = 1:15,"enem"=1:5) energia$curso <- c("Eng Aeroespacial", "Eng Ambiental", "Eng de Controle e Automação", "Eng de Minas", "Eng de Produção", "Eng de…
-
0
votes1
answer892
viewsHow to save a ggplot chart without losing quality to Word and Power Point?
I’m having trouble saving the graphics in a way that: they either lose quality or change their dimensions in relation to the background of the sheet that receives it. Attempt.1 <- A figure with…
-
0
votes1
answer542
viewsTo change the order of the legend without changing the colors of the chart in ggplot2
I am mounting this graphic using the ggplot2 package and prefer it with more neutral colors as in the first image (without vibrant colors), but when I modify the order of the caption the colors of…
-
0
votes1
answer67
viewsHow to organize dates in ggplot2
I have a chart made with ggplot2, but when it comes to exporting it, the dates on the X-axis are totally unreadable, as in this example: How can I fix them? Code I’m using:…
-
0
votes1
answer152
viewsProblem with key in ggplot, using double axis y + geom_line()+geom_point() x geom_bar()
Hello, I have another problem regarding the presentation of legend, in this case, using axis y double (ggplot::scale_y_continuous::sec_axis), and geom_line()+geom_point() x geom_bar(), as shown in…
-
0
votes1
answer56
viewsGraph with ggplot2 using wrong data
I have a bar and line chart made with ggplot2, the red line is a moving average of 7 days, but when plotted on the chart, it shows a drop at the end of each that does not match the values. Graph:…
-
0
votes1
answer349
viewsAverage and median boxplot legend in ggplot2 function
I am trying to add a caption identifying that the "ball" is the mean and the "line" is the median of the boxplot chart as follows: mediasCon1 = tapply(dados$FS, dados$Trat, mean) boxplot(dados$FS ~…
-
0
votes1
answer63
viewsGraphics in ggplot2, I want to add a loop to create graphics
I have a question in ggplot, I want to compare two tables and create graphs for each Gene in R: Table 1 Table 2 below I used as reference in the index for the loop: "gene_data" is variable for Table…
-
0
votes1
answer94
viewsHow to make boxplots monthly, quarterly, biannual, annual and every 10 years for a period of 30 years?
I need to create several boxplots with different data intervals. I have a data-frame composed of precipitations of the city of Alagoas and need to compare with other data-frame with precipitation…