I made a plot for presenting OR ratio. However, OR for log(PTH) has a large 95CI. Can I make a gap into x axis between 20 and 30, making other variables more visible? Some, examples suggest gap_plot(), but I do not know how to combine it with this type of graph. I already transform PTH value, so it will be hard to change it regarding interpretation. If you have some other way to do it, feel free to suggest. I would like to make values of all variables visible. However, this vales of lof(PTH) makes Pol hard to interpret from the plot, despite being significant.
Best, A.
library(gridExtra)
library(ggplot2)
Nezavisna<-c("Pol","Starost","Ca","P","log(PTH)","log(mg)","BrojZlezda","MIBI","Iskustvo","Pridruzena")
OR<-c(0.399,1.023,0.814,0.568,14.14,0.417,2.193,0.709,1.468,1.445)
LL<-c(0.174,0.996,0.277,0.122,4.969,0.197,1.019,0.339,0.754,0.702)
UL<-c(0.917,1.052,2.396,2.649,40.238,0.882,4.722,1.483,2.859,2.976)
istrazivanje<-data.frame(Nezavisna,OR,LL,UL)
istrazivanje
ggplot(istrazivanje, aes(y = Nezavisna, x = OR)) geom_point(shape = 18, size = 5) geom_errorbarh(aes(xmin = LL, xmax = UL), height = 0.25) geom_vline(xintercept = 1, color = "red", linetype = "dashed", cex = 1, alpha = 0.5)
CodePudding user response:
If, I understand correctly your question one solution could be ggforce facet zoom function
Sample code:
library(gridExtra)
library(ggplot2)
library(ggforce)
ggplot(istrazivanje, aes(y = Nezavisna, x = OR))
geom_point(shape = 18, size = 5)
geom_errorbarh(aes(xmin = LL, xmax = UL), height = 0.25)
geom_vline(xintercept = 1,
color = "red",
linetype = "dashed",
cex = 1,
alpha = 0.5)
facet_zoom(xlim = c(20, 30)) # use facet_zoom to zoom on x axis
Plot:
Sample data:
Nezavisna<-c("Pol","Starost","Ca","P","log(PTH)","log(mg)","BrojZlezda","MIBI","Iskustvo","Pridruzena")
OR<-c(0.399,1.023,0.814,0.568,14.14,0.417,2.193,0.709,1.468,1.445)
LL<-c(0.174,0.996,0.277,0.122,4.969,0.197,1.019,0.339,0.754,0.702)
UL<-c(0.917,1.052,2.396,2.649,40.238,0.882,4.722,1.483,2.859,2.976)
istrazivanje<-data.frame(Nezavisna,OR,LL,UL)
istrazivanje
CodePudding user response:
As mentioned by stefan in the comments you can transform your data, but to make it readable set your labels and breaks to the normal values.
ggplot(istrazivanje, aes(y = Nezavisna, x = log2(OR)))
geom_point(shape = 18, size = 5)
geom_errorbarh(aes(xmin = log2(LL), xmax = log2(UL)), height = 0.25)
geom_vline(xintercept = log2(1), color = "red", linetype = "dashed", cex = 1, alpha = 0.5)
scale_x_continuous(breaks = log2(c(1, 10, 20, 30, 40)), labels =c(1, 10, 20, 30, 40))
Edit: or as you already take log(PTH) you could do log10(PTH) which roughly bring your OR value there from roughly 14 to 6 and perhaps then you do not even have to transform the scales of the graph.