- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to display Y-axis with Euro sign using ggplot2 in R?
When we have a Euro currency column in an R data frame as a response variable then we might to display the Euro sign in the plot created by using ggplot2 package. For this purpose, we can use scales package and the scale for Y axis will be changed by using the command scale_y_continuous(labels=dollar_format(suffix="€",prefix="")) to the plot command.
Consider the below data frame −
Example
x<-rpois(20,5) y<-rpois(20,100) df<-data.frame(x,y) df
Output
x y 1 8 112 2 10 81 3 4 97 4 7 104 5 4 98 6 5 99 7 5 97 8 7 97 9 5 95 10 3 98 11 6 92 12 6 80 13 6 92 14 6 108 15 7 113 16 4 103 17 3 106 18 2 116 19 4 105 20 6 83
Loading ggplot2 package and creating a scatterplot between x and y −
Example
library(ggplot2) ggplot(df,aes(x,y))+geom_point()
Output
Loading scales package and creating the scatterplot with Euro sign displayed with Y-axis labels −
Example
library(scales) ggplot(df)+geom_point(aes(x,y))+scale_y_continuous(labels=dollar_format(suffix="€",prefix=""))
Output
- Related Articles
- How to display positive sign for X-axis labels in R using ggplot2?
- How to display 0 at Y-axis using ggplot2 in R?
- How to display count on Y-axis for line chart using ggplot2 in R?
- How to set the Y-axis tick marks using ggplot2 in R?
- How to create cumulative sum chart with count on Y-axis in R using ggplot2?
- How to create a bar plot using ggplot2 with percentage on Y-axis in R?
- How to create a histogram with Y-axis values as count using ggplot2 in R?
- How to change the Y-axis title to horizontal using ggplot2 in R?
- How to display average line for y variable using ggplot2 in R?
- How to create different Y-axis for group levels using ggplot2 in R?
- Create stacked bar chart with percentages on Y-axis using ggplot2 in R.
- How to display Y-axis labels with more decimal places in R?
- How to change the text size of Y-axis title using ggplot2 in R?
- How to change the Y-axis values in a bar plot using ggplot2 in R?
- How to change the Y axis limit for boxplot created by using ggplot2 in R?

Advertisements