I am trying to figure out how to create this complex ggplot using the dataset below:
type | a | b | d | points | end | start |
---|---|---|---|---|---|---|
A | -0.32 | -0.02 | 0 | 1.08 | 1.14 | 1.03 |
A | -0.32 | -0.02 | 2 | 0.39 | 0.45 | 0.32 |
A | -0.32 | -0.02 | 4 | 0.25 | 0.32 | 0.17 |
A | -0.32 | -0.02 | 6 | 0.06 | 0.07 | 0.04 |
B | -0.19 | -0.02 | 0 | 1.07 | 1.12 | 1.01 |
B | -0.19 | -0.02 | 2 | 0.55 | 0.58 | 0.52 |
B | -0.19 | -0.02 | 4 | 0.43 | 0.48 | 0.39 |
B | -0.19 | -0.02 | 6 | 0.17 | 0.20 | 0.15 |
The plot will be like this:
For each "type", there will be a curve, a set of 4 points, and a set of 4 segments.
- Each curve will be a curve of the the function [exp(ax + bx^2)], where a and b are in the dataset. I think it can be achieved by:
geom_function(fun = function(x) exp(a*x + b*x^2))
- The points can be plotted from the variable "points" like this:
geom_point(aes(x = d, y = points))
- The segments can be plotted from the start and end variables like this:
geom_segment(aes(x = d, y = start, xend = d, yend = end))
- The y axis is in a log10 scale, which can be achieved by adding:
scale_y_log10()
I think I know the individual details, but unfortunately I am not being able to plot it after I put everything together. The curves of the functions are not coming up, and I am getting errors. Can anyone please help?
Thank you so much!!!!