Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9147413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:58:59+00:00 2026-06-17T10:58:59+00:00

Is it possible, in ggplot2, to colorize labels for a group of points? I

  • 0

Is it possible, in ggplot2, to colorize labels for a group of points?

I would like to color some of the left-hand-side text labels in the plot below to show the swing states in red colour, in addition to the red marker shown in the plot itself:

electoral dot plot

The code (with data) is here. — edited to reflect answer

  • I know how to colour all labels (here too), but that’s not what I need here.
  • Ideally, I’d also like to improve the legend but am unsure exactly how.

The plot is far from perfect, so additional suggestions are very welcome. There are far better graphs out there if anyone’s interested (but I’m not good enough to code them).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:59:00+00:00Added an answer on June 17, 2026 at 10:59 am

    Colors of labels (axis texts) are set by argument element_text= in function theme(). You can set different colors for each label. As there is a column Swing with levels, it can be used to set colors.

    dw_plot + theme(axis.text.y = element_text(colour = ifelse(dw_data$Swing=="Swing State","red","grey")))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to used ggplot to color points based on predefinded standard color
I wonder if it is possible to plot pca biplot results with ggplot2. Suppose
I have a dataframe that I would like to plot in a similar way
Possible Duplicate: How to put labels over geom_bar in R with ggplot2 I've been
Is this possible to reproduce this lattice plot with ggplot2? library(latticeExtra) data(mtcars) x <-
I'd like to know if it is possible to change some default parameters of
I'd like to ask if it's possible to label each of the points plotted
When using a facet_grid in ggplot2 I would like to be able to have
Is it possible to plot a matrix of scatter plots with ggplot2 , using
Possible Duplicate: Annotating text on individual facet in ggplot2 I am working on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.