0

I'm asking for your advice and support to plot two lines of data using the geom_line and geom_area f(x) in Rstudio. It's pretty simple, but I can't fix the bugs from the final plot. I will appreciate your help!

The code that I'm using is described as follows:

`ggplot(data, aes(Strain,Stress, colour=Treatment))+ geom_point(aes(), size= 1.5, linetype="dotted")+ geom_area(aes(), alpha=0.2)+ xlim(0,0.01)+ylim(0,0.003)+ theme( line = element_line(colour = "black", size = 1, linetype = 1, lineend = "butt"), rect = element_rect(fill = "white", colour = "black", size = 1, linetype = 1), aspect.ratio = 1, plot.background = element_rect(fill = "white"), plot.margin = margin(1, 1, 1, 1, "cm"),

axis.text = element_text(size = rel(2.5), colour = "#000000", margin = 1), 
strip.text = element_text(size = rel(0.8)), 
axis.line = element_blank(), 
axis.text.x = element_text(vjust = 0.2), 
axis.text.y = element_text(hjust = 1), 
axis.ticks = element_line(colour = "#000000", size = 1.2), 
axis.title.x = element_text(size = 30, vjust=0.5), 
axis.title.y = element_text(size = 30, angle = 90), 
axis.ticks.length = unit(0.15, "cm"), 


legend.background = element_rect(colour = NA), 
legend.margin = unit(0.15, "cm"), 
legend.key = element_rect(fill = "grey95", colour = "white"), 
legend.key.size = unit(1.2, "lines"), 
legend.key.height = NULL, 
legend.key.width = NULL, 
legend.text = element_text(size = rel(2.0)), 
legend.text.align = NULL, 
legend.title = element_text(size = rel(2.0), face = "bold", hjust = 0), 
legend.title.align = NULL, 
legend.position = "bottom", 
legend.direction = NULL,
legend.justification = "center",
legend.box = NULL, 


panel.background = element_rect(fill = "#ffffff", colour = "#000000",
                                size = 2, linetype = "solid"), 

panel.border = element_rect(colour = "black", fill=NA, size=2), 

)+ ylab("Stress(MPa)") + xlab("Strain")`

The result is a estrange plot:

Result plot

The expected images is the two plot in the same graph, where the x and y scales are the same, like a good way to compare. The expected plot is shown: Example of good geom_area and geom_point f(x). However, I dont want the plots apart, I need them together.

Data:

https://drive.google.com/drive/folders/1QB0DfFwhKEm7ic6QQK3Ah6ARrtL1NOI4?usp=share_link

  • Do you want to `+ facet_wrap(~ Treatment)`? If not, could you make your code reproducible so we can test solutions? The decoration (theme settings etc) is probably not really relevant to the problem, so leaving that our of the question would make it more minimal. – teunbrand Nov 14 '22 at 07:04
  • Hi, sure no problem. I don't know how to upload the data, with a google drive link, perhaps? Well If you can guide me with that I can give all the data to reproduce the code, thanks. – Cesar Barrientos Nov 14 '22 at 14:24
  • You might be able to take a subset of the data (5 rows for each group for example) and then use `dput(your_data)` and copy the output to your question. That is, if a small portion of your data is enough to reproduce the problem. – teunbrand Nov 14 '22 at 14:29
  • It's done, I prefer to use all the data, because are +1000 rows. Thanks. – Cesar Barrientos Nov 14 '22 at 14:42

0 Answers0