You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This problem is associated with the scale_fill_ and scale_color functions, including their manual versions, which contain the drop argument. What is happening is that if you have data where any of the factors are not in use, and you are using drop = FALSE, these factors appear in the legend, but without any associated color.
I understand that the operation of associated with drop = FALSE has had continuous changes over time (#4511 , #4619 , #4723 , #5214), so I have tried different iterations on the above issues, but none of them work.
However, I think it is not an ideal solution, since add_case() or bind_rows() may have limitations when you have tibbles with list or different data type.
The solution is to add show.legend = TRUE to the points layer. This is mentioned in the documentation of the drop argument in ?discrete_scale:
Should unused factor levels be omitted from the scale? The default, TRUE, uses the levels that appear in the data; FALSE includes the levels in the factor. Please note that to display every level in a legend, the layer should use show.legend = TRUE.
This problem is associated with the
scale_fill_
andscale_color
functions, including theirmanual
versions, which contain thedrop
argument. What is happening is that if you have data where any of the factors are not in use, and you are usingdrop = FALSE
, these factors appear in the legend, but without any associated color.Created on 2024-07-11 with reprex v2.1.1
I understand that the operation of associated with
drop = FALSE
has had continuous changes over time (#4511 , #4619 , #4723 , #5214), so I have tried different iterations on the above issues, but none of them work.Created on 2024-07-11 with reprex v2.1.1
The only way to get what I am looking for is to add an empty row where the missing factors are mentioned, and plot waiting for them to be eliminated.
Created on 2024-07-11 with reprex v2.1.1
However, I think it is not an ideal solution, since
add_case()
orbind_rows()
may have limitations when you have tibbles with list or different data type.Created on 2024-07-11 with reprex v2.1.1
The text was updated successfully, but these errors were encountered: