Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ggplot: axes lines, values, and labels not plotting

Tags:

r

ggplot2

I recently noticed that when I try plotting anything in ggplot2, both the x and y axes data (values, labels, lines, everything) are missing. I have tried to manually specify and enter the missing data using scale and theme commands, but ggplot still won't display the axes.

For example, the following simple code produces this plot on my computer:

ggplot(mpg, aes(x=class,y=hwy)) + geom_boxplot()

I have been using R and ggplot regularly for a few years and never encountered this problem until recently, but I don't know what computer/R/ggplot settings could have changed.

Interestingly, when I use base plotting functions there are no issues (both axes plot normally), so it seems like it's only an issue in ggplot.

E.g., the base code below produces this plot on my computer:

boxplot(mpg$hwy ~ mpg$class)

I have tried uninstalling and reinstalling ggplot multiple times to no avail.

Any advice for how to fix ggplot? Thanks!

like image 866
axle0001 Avatar asked Aug 07 '26 12:08

axle0001


1 Answers

I know this is 5 years old, but I had the problem today. Lines, grids, and ticks in ggplot were suddenly missing. The reason was not on ggplot2, but on my office screen settings. Apparently, some screens render thin lines so that they disappear.

like image 168
panuffel Avatar answered Aug 10 '26 07:08

panuffel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!