![]() ![]() Na.value = "grey" # assign a color for missing values ) + labs (title = "Adjustment of scales" ) # Adjust the title of the fill legend Labels = c ( "m" = "Male", # re-label the legend (use "=" assignment to avoid mistakes) "f" = "Female", Values = c ( "m" = "violetred", # reference values in data to assign colors "f" = "aquamarine" ), Labels = c ( "Died", "Recovered" ) ) + # Change display of values scale_fill_manual ( # Manually specify fill (bar interior color) ![]() Na.translate = FALSE, # remove NA outcomes from plot # SCALES ADJUSTED ggplot (data = linelist ) + geom_bar (mapping = aes (x = outcome, fill = gender ), color = "black" ) + theme_minimal ( ) + # simplify background scale_y_continuous ( # continuous scale for y-axis (counts)īy = 500 ) ) + scale_x_discrete ( # discrete scale for x-axis (gender)ĭrop = FALSE, # show all factor levels (even if not in data) If you have multiple scales, you may use multiple scale functions to adjust them! For example: There are others, but these are the most-often used.īe sure that you use the correct function for the scale! Otherwise your scale command will not appear to change anything. ![]() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |