All Questions
41
questions
0
votes
0
answers
76
views
How to fix missing legend from base plot in r?
Trying to add a legend to my plot (please see below). The sample code I used works fine (using "center"). My code below does not get a legend (at least not one that I can see as I have poor ...
1
vote
1
answer
115
views
How do I move and unstack legend elements when using ggplot and ggpattern?
I have data with two different categorical grouping variables, and to distinguish between them, I followed this guide to add a pattern to one of the categorical variable types. However, now that I've ...
0
votes
1
answer
509
views
How to combine colour and linetype into a single legend?
I am trying to combine two legends of unequal length into a single length and am having some problems. I am using colour to represent 3 different populations, whereas I'm using linetype to show ...
1
vote
1
answer
396
views
How can I completely remove legend.key from ggplot2 legend?
I'm plotting a graph and I need to completely remove the legend.key from my ggplot legend. Why I need to do this? The legend starts with a number that reference the X axis breaks, and the label its ...
1
vote
0
answers
1k
views
How do I stop a ggplot graph legend from getting cut off on the right when exporting-saving when using showtext?
Just started R a couple weeks ago. Getting familiar with ggplot. I successfully made the graph I wanted to including all legends, axes titles, etc. I'm able to export/save this image fine. However, ...
1
vote
1
answer
379
views
adding a legend to a barplot at he top left
barcols <- c("green","red","purple")
barcols
barplot(table(gender$Alert.Level, gender$Gender),las=1, beside= TRUE, ylab= "Frequency", xlab="gender"...
-1
votes
1
answer
242
views
Add labels to lines plotly
I needed some help labeling some overlaying lines in plotly.
I have a dataframe that consists of the following columns:
df$date = c("2014-09-30","2016-03-31","2016-03-31")...
0
votes
1
answer
126
views
Automatically Stop Legend from getting Cropped by Plots (R)
I am working with the R programming language. I generated the following data:
credibility_scoree = rnorm(100, 1, 0.3)
average_recorded_height_in_study = rnorm(100, 17,3)
my_data = data.frame(...
0
votes
1
answer
740
views
Rearranging legend order plotted using ggsurv for Kaplan Meier curves
I plotted Kaplan Meier curves for my data which is for 6 different treatments namely:
100Low
30Low
15Low
100High
30High
15High
I want my legend to be in the sequence that I mentioned above however ...
1
vote
1
answer
45
views
How can I determine the form of my legend with BaseR?
I'm trying to replicate the following chart:
This is what I managed to do so far:
library(carData)
UN <- as.data.frame(UN)
layout(matrix(c(1, 2, 3, 3), 2, 2, byrow = TRUE))
col.vec <- c("...
0
votes
1
answer
68
views
(R) How to get a legend in ggplot2 based on color, linetype and point shape?
How can I get a legend for the following data based to differentiate y1 and y2 based on color, linetype, and shape of points? (sd just means standard deviation)
x <- c(2.5, 1.25, 0.625, 0.3125, 0....
0
votes
0
answers
99
views
How to add colour-coded figure legend on mirrored bar chart in ggplot? [duplicate]
I have created a mirrored bar chart to compare two variables. I have managed to get each of these a different colour, but haven't had any success with getting a figure legend to explain what each part ...
1
vote
0
answers
247
views
Adding a Legend in R map graph
i have the following map, which was built from the data on the library "maps".
it is basically the distance among all counties at USA and some important airports, the thing is that I haven't ...
1
vote
1
answer
485
views
Side by Side plot with one legend in ggplot2
I would like to know how to use ggplot2 to create a side by side plots with one common legend. I have seen some similar questions but not sure how to directly apply it to my code. I have provided my ...
0
votes
1
answer
39
views
Adding a Legend in ggplot2
I have the following code.
Financial_Wealth.lq,Financial_Wealth.uq,Total_Wealth.lq,Total_Wealth.uq,time=seq(0,(sPar.dNN),1))
ggplot(data, aes(x=time)) +
geom_line(aes(y = Human_Capital.mean), ...