PPPatrick
PPPatrick

Reputation: 39

R: How to center the tick labels (putting labels between tick marks) using ggplot?

I was using R ggplot for data visualization, and I met the problem centering the tick labels between tick marks on x/y axes. Here's a similar question but the implementation is matplotlib.

This is what I had (the wrong version): enter image description here

And this is what I expected: enter image description here

THANKS A LOT!!!

Upvotes: 0

Views: 1977

Answers (1)

neuron
neuron

Reputation: 2059

It is hard to reproduce your plot without the data you used to create the plot or the code you used to generate the plot

You can move the x-axis labels to the right by adding the following code to your plot

+ theme(axis.text.x=element_text(hjust=-0.5))

Additionally, one option might be just to rotate the x-axis labels instead of moving them. You can do this by adding the following code

+ theme(axis.text.x=element_text(angle = 90))

Upvotes: 2

Related Questions