• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Data Viz with Python and R

Learn to Make Plots in Python and R

  • Home
  • Seaborn
  • Matplotlib
  • ggplot2
  • Altair
  • About
    • Privacy Policy
  • Visualizing Activation Functions in Neural Networks
  • Confusion Matrix Calculator
  • Visualizing Dropout Rate in Neural Network
  • Visualizing Loss Functions in Neural Networks
  • Show Search
Hide Search

How to Add Dollar Symbol for Axis Labels with ggplot2?

datavizpyr · February 13, 2020 ·

Last updated on August 14, 2025

This is a quick guide on how to add dollar signs ($) to your axis labels in ggplot2.

We will use the label_dollar() function from the versatile scales package to handle the formatting. This function automatically adds the dollar prefix and inserts commas as thousands separators, making it incredibly simple to display currency on your plots.

In this tutorial, we will learn how to format x or y-axis so that we have dollar symbol in a plot made with ggplot2 in R.

Let us create a dataframe with salary education information for developers using the StackOverflow survey results. We first create two lists; one for education and the second for salary.

education <- c("Bachelor's", "Less than Bachelor's",
               "Master's","PhD","Professional")
salary <- c(110000,105000,126000,144200,95967)

We create a tibble using the two lists with tibble() function.

df <- tibble(Education=education,
             Salary=salary)
df
## # A tibble: 5 x 2
##   Education            Salary
##   <chr>                 <dbl>
## 1 Bachelor's           110000
## 2 Less than Bachelor's 105000
## 3 Master's             126000
## 4 PhD                  144200
## 5 Professional          95967

Let us make a simple bar plot with geom_col() in ggplot2.

df %>%
  ggplot(aes(x=Education, y=Salary)) +
  geom_col()

In the barplot, height of bars represent salary for each education category.

Notice the y-axis currently displays salary as plain numbers. We can easily format these labels to appear as dollars, which is more readable for financial data.

The solution is to use the dollar_format() function from the scales package within your scale_y_continuous() layer. Here is how you add it to your ggplot object:

df %>%
  ggplot(aes(x=Education, y=Salary)) +
  geom_col()+
  scale_y_continuous(labels=scales::dollar_format())

Now, we get a bar plot with y-axis formatted with dollars.

Explore the Complete ggplot2 Guide

35+ tutorials with code: scatterplots, boxplots, themes, annotations, facets, and more—tested and beginner-friendly.

Visit the ggplot2 Hub → No fluff—just code and visuals.

Related posts:

Customizing Labels on Bars in Side by side Stacked BarplotHow To Add Labels to Grouped Barplot with Bars Side-By-Side in R? Add Mean Line to RIdgeline Plot with ggridges in RHow To Add Mean Line to Ridgeline Plot in R with ggridges? Visualizing Missing Data with Barplot in R ggplot2Visualizing Missing Data with Barplot in R Annotate Clusters with Ellipse with Labels ggforceHow To Annotate Clusters with Circle/Ellipse by a Variable in R

Filed Under: add dollar sign to label, ggplot2, R Tagged With: dollar in R, ggplot2, R, scales dollar_format()

Primary Sidebar

Python & R Viz Hubs

  • Seaborn Guide & Cookbook
  • ggplot2 Guide & Cookbook
  • Matplotlib Guide & Cookbook
  • Confusion Matrix Calculator
  • Visualizing Activation Functions
  • Visualizing Dropout
  • Visualizing Loss Functions

Buy Me a Coffee

Copyright © 2026 · Daily Dish Pro on Genesis Framework · WordPress · Log in

Go to mobile version