I'm using the plot function and I would like my numbers to have a thousand separator on the Y axis. For example, in the case of 1000 I would like the 1,000 number to be seen on the axis, or in the case of 10000, for example, on the 10,000 axis .
Asked
Active
Viewed 131 times
-1
-
1ggplot or base plot? Or something else? Can you make a small example? even just `plot(1000, 10000)` if that is comparable to your actual use. – Gregor Thomas Dec 05 '17 at 22:03
-
I'm using the plot function – Roger Figueroa Quintero Dec 05 '17 at 22:05
-
`plot()` is a generic function so it can do very different things based on what you pass to it. It's always better to provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) when asking for help. – MrFlick Dec 05 '17 at 22:06
1 Answers
2
If you are using base plot()
you can turn off the default axes, then just use axis()
to draw whatever you like on the axes
x<-seq(0, 100000, length.out=11)
y<-seq(0, 10000, length.out=11)
plot(x,y, xaxt="n", yaxt="n")
axis(1, axTicks(1), format(axTicks(1), big.mark = "."))
axis(2, axTicks(2), format(axTicks(2), big.mark = "."))

MrFlick
- 195,160
- 17
- 277
- 295
-
Sorry for unnecessary edits, I got confused between the questions title and text. – Gregor Thomas Dec 05 '17 at 22:07
-
I have a small problem everything works fine, but for some reason the number changes thickness – Roger Figueroa Quintero Dec 05 '17 at 22:09
-
Agreed, but the title seems *very clear* about the point ".", so I decided your way was probably right. (And it's pretty clear how to change it anyway.) – Gregor Thomas Dec 05 '17 at 22:09
-
@RogerFigueroaQuintero Did you use `xaxt="n", yaxt="n"` in the `plot()` to turn off the default axes as I did above? – MrFlick Dec 05 '17 at 22:10
-
Yes, I had forgotten "xaxt =" n ", yaxt =" n. "Thank you very much – Roger Figueroa Quintero Dec 05 '17 at 22:15