scale_x_discrete("Results of the urine culture", labels=c(expression("<"~10^4~"CFU/ml"), expression(10^4~"-"~10^5~"CFU/ml"), expression(">"~10^6~"CFU/ml")))
The graph returns with the same value (the first in the expression, i.e. "<10^4 CFU/ml") for all three ticks (see the graph below). I have tried to find an answer using search but did not find the description of this problem. Could you please point out what is wrong with this code? Thanks in advance.
Yours truly,
Jakhongir
Update
Dear all problem was in the line
facet_grid(~count, switch="y", space = "free_x", scales = "free_x")
facet_grid
and added some modifications to keep these numbers at the top of the graph. First, I tried to duplicate the x-axis using sec_axis
to add the numbers of patients in each group on the secondary axis. But doesn't work because the x-axis was discrete and sec_axis
works only with continuous axes. Then, I have tried simple geom_text
, adding some modifications with coord_cartesian
and plot.margin
. So, the added modifications are:
+geom_text(aes(label=count, y=Inf), vjust=-0.5, size=5)+ coord_cartesian(clip = "off")+ theme(plot.margin = margin(20,15,15,15, unit = "pt"))
Hi,
This will help you get an answer:
http://adv-r.had.co.nz/Reproducibility.html
From: ggp...@googlegroups.com [mailto:ggp...@googlegroups.com]
On Behalf Of Jakhongir Alidjanov
Sent: Thursday, July 09, 2020 11:22 AM
To: ggplot2 <ggp...@googlegroups.com>
Subject: EXTERNAL: Re: ggplot2 with expression: conditional superscript the tick labels in scale_*_discrete
** This email has been received from outside the organization – Think before clicking on links, opening attachments, or responding. ** |
--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example:
https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2
---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
ggplot2+u...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ggplot2/3d0d9de2-f2bf-4545-a8f5-44373182e96fo%40googlegroups.com.