Custom text for Y axis tick marks

Hi! I'm trying to get R to let me put custom text on each tick mark of the y axis of a plot. For more context: I'm plotting 10 observations each of 30 different varieties of a plant species. The observations are numerical (weights), but the names of the varieties are alphanumeric. Weights are plotted along the x axis.
My question has two parts:

  1. Is there a way to get each tick mark to display the variety name associated with it using the data from my csv file?
  2. If not, how do I know which tick mark belongs to which variety (aside from manually comparing every single data point on the chart to my file)? Right now the tick marks just read 1-30 but doesn't tell me which variety has been designated with which number. I can tell from looking at it that it doesn't seem to be in the order of the CSV it's pulling the data from.
    I've looked on quite a few forums about tick mark customization but have not found anything that addressed this specific issue, or provided a working solution.
    To be clear: I am not concerned with where the tick marks are placed, how big they are, what color they are, which direction the text is going, or the font. I just want to customize the label for each individual tick mark so I know which variety it belongs to. I don't want to label the ticks with numbers, letters, or any other sequence- I just want each tick on the y axis to tell me exactly which variety is plotted at which tick mark.
    I'm new here- I'm sure this question has been asked and answered before, but for the life of me I can't find a solution that works!

Without example code we can't reproduce your problem, but yes you can definitely customize axis tick labels.

For example, after generating your plot p with ggplot2, you can customize tick labels using

 p + scale_x_discrete(labels=c("original_label1" = "new_label1", "original_label2" = "new_label2",
                              "original_label3" = "new_label3"))

This way you are manually customizing tick labels.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.