Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205399

How can I change the values displayed on the X axis using ggplot2?

$
0
0

Here is my R code:

# Create vectors for Stroman 2019 -- Mets
GScMets <- c(38,44,51,48,49,54,30,63,75,49,59,53)
GameMets <- c(1:12)

# Set line color and size
ggplot(gameGScMets, aes(x=GameMets, y=GScMets)) + geom_line(colour = "blue", size=1.2) + ggtitle("Marcus Stroman Mets Game Score by Game")

In the chart below, the values in the Y axis are appearing as 2.5, 5.0, 7.5, 10.0, 12.5. I want them to appear as 2, 4, 6, 8, 10, 12.

How can I do that?

My output: Marcus Stroman Mets Game Score by Game

Note: I changed my code to

ggplot(gameGScMets, aes(x=GameMets, y=GScMets)) + geom_line(colour = "blue", size=1.2) + ggtitle("Marcus Stroman Mets Game Score by Game") + scale_x_discrete(breaks = seq(2, 12, by=2))

which I saw used in another post, but that only caused no values to be displayed on my x-axis.


Viewing all articles
Browse latest Browse all 205399

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>