Questions tagged [ggplot2]
ggplot2 is an actively maintained open-source chart-drawing package for R, written by Hadley Wickham, based upon the principles of "Grammar of Graphics". It partially replaces R's basic plot and the lattice package, while providing a clean, powerful, orthogonal and fun API.
ggplot2
56,878
questions
0
votes
1
answer
30
views
move inset plot legend
I have an inset plot with a legend that I want to be shown at the bottom of the overall figure. This legend isn't the same for the larger plot, since I added more layers to the inset plot. How can I ...
0
votes
0
answers
18
views
ggplot line plots are not showing up on proportional secondary axis
I am trying to plot a barplot, and overlay some plots onto it using a secondary axis. I am able to adjust the secondary axis to be proportional to the values but the line plots still seem be squished ...
0
votes
1
answer
18
views
How to adjust x axis in coefficient plot with sjPlot's plot_model when x value range is smaller than -1,1?
I'm plotting multiple regression coefficients with plot_model and the x axis is automatically set to -1,1 even though the possible range of my values is smaller, which makes the estimates hard to see ...
1
vote
1
answer
19
views
as.ggplot in dendextend does not leave enough room for leaf labels
I've been using ggplot2 for automated report generation, and had been using ggdendro for accompanying dendrograms. However, as ggdendro seem to no longer be actively supported and I encountered this ...
-1
votes
2
answers
44
views
R, ggplot2 - time on x axis
In R I have a data frame with bid and ask prices for a single day. Here is an example:
TimeHM; Bid_Price1; Ask_Price1
08:12; 101; 102
08:13; 101; 102
08:14; 102; 104
...
17:05; 104; 105
So, each new ...
3
votes
1
answer
38
views
Keep ggplot font size constant in different figure dimensions
I'm in a position that requires me to frequently change the dimensions of my plots via the fig.dim=c(...,...) option in each r chunk.
However, I have a problem that I haven't been able to solve yet.
...
1
vote
1
answer
20
views
How to Add Significance bars a Bar Plot that have percentage/logical data
I have a dataframe with a categorical variable and a few logical variables. I’ve created an example using the iris dataset:
# Create a new dataframe showing the percentage each variable that is ...
-1
votes
1
answer
27
views
geom_text_repel only displays 2 labels when it should be all [closed]
I have code in r to create a plot with labels on the points
library(tidyverse)
library(ggrepel)
set.seed(123) # Set seed for reproducibility
# Generate random strings for the country, party, ...
-1
votes
2
answers
39
views
creating a looped stacked barplot with ggplot in R
I am trying to create a stacked barplot with ggplot in R. I have the following dataframe:
Sample
Date
Organism
Antibiotic
Resistance
1
01/01/2020
E Coli
Amoxicillin
S
1
01/01/2020
E Coli
Gentamicin
...
0
votes
1
answer
52
views
Is there an R-function to interpolate contours which fits a shapefile?
I am plotting contour maps using R. The program is able to plot the contours but it is not able to interpolate the plot to fit and fill the provided shapefile. Is there a specific function in R which ...
0
votes
1
answer
23
views
Make axis lines start from specific values in ggplot
I have the following scatterplot in ggplot:
library(ggplot2)
ggplot(iris, aes(x=Sepal.Length, y=Sepal.Width)) +
geom_point() +
theme_classic() +
scale_y_continuous(limits = c(2, 5)) +
...
0
votes
3
answers
50
views
ggplot: How to merge two legend boxes and give legend keys any desired order?
I am trying to make a plot with a few stacked bars and a dot (corresponding to their sum). However, I am having troubles giving the legend keys the positions I want. In particular, I have two ...
1
vote
2
answers
45
views
How to Stack a Scatter Plot and a Bar Chart with Discrete and Continuous Y-Axes?
I have created two plots:
The first one is a scatter plot where the x-axis represents time and the y-axis contains discrete values like the names 'Tom' and 'Jerry'.
The second one is a bar chart where ...
0
votes
1
answer
20
views
II want to reorder the bars, but don't know how [duplicate]
I'm using the following code:
library(ggplot2)
g1 = ggplot(data = DadosDVMO)
g1 + geom_bar(aes(y = `ETNIA(IBGE)`, color = `ETNIA(IBGE)`,
fill = `ETNIA(IBGE)`)) + xlab('Candidatos a ...
1
vote
1
answer
21
views
scale_fill_gradient2 colors do not reach the upper limit, even though the data does [duplicate]
I am trying to illustrate values diverging from 0 in a heat map. However, values near, and beyond the maximum appear much paler than the specified high color.
library(ggplot2)
genotype <- c(rep(c(&...