Closed
Description
In a ggplot I am using a secondary Y-axis to display additionnal labels to my plot.
I use it like this :
scale_y_continuous(
expand = c(0, 0),
breaks = seq(0, N.rows, length.out = n.grad),
labels = function(x) format(x, digits = 2, scientific = TRUE),
sec.axis = sec_axis(
trans = ~.,
breaks = dt.data[right.y.hiden == FALSE]$right.y.label.pos,
labels = dt.data[right.y.hiden == FALSE]$sample.string))
in sec_axis()
breaks and labels are queried in a data.table dt.data
:
- If multiple breaks and labels are selected from the data.table -> no problems.
- If there is only 1 break and 1 label queried from the data.table, displaying the plot returns this warning (I guess this is the matching translation from the language I use):
Warning messages:
1: In min(x) : no non-missing arguments to min; returning Inf
2: In max(x) : no non-missing arguments to max; returning -Inf
The plot returned is fine : it totally matches my expectation.
But I don't understand why these warnings are printed.
So I basically have to questions:
- Why those warnings are printed when there is only 1 break & label ?
- Is there something I should mention in
sec_axis()
or elsewhere to get rid of these warnings ?
I don't know if it is reproducible, but from what I experienced, if you give just a single value to breaks
and labels
in sec_axis()
such has:
sec.axis = sec_axis(trans = ~., breaks = 125, labels = "awesome single label")
This should trigger the warnings.