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 7717681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:57:50+00:00 2026-06-01T02:57:50+00:00

I’ve got a list and some data l <- c(‘b’, ‘a’) frame <- data.frame(series

  • 0

I’ve got a list and some data

l <- c('b', 'a')
frame <- data.frame(series = rep(c('a', 'b'), 6), x = c(1:12), y = c(1:12))

and I’d like to plot a smoothed line via

ggplot(frame, data) + geom_smooth(linetype=series)

But I need the linetype based on the list l, the first element in the list l should be
normal, the second element of the list dotted. I tried

ggplot(frame, data) + geom_smooth() + scale_linetype_manual("", values=series, breaks=l) 

But that doesn’t apply any linetype.

  • 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-01T02:57:52+00:00Added an answer on June 1, 2026 at 2:57 am

    You example data is a little odd, in that you have a grouping variable (series) and one numerical column (data), but it sounds like you want to plot two variables. Here’s some possibly more relavent example data:

    frame <- data.frame(series = rep(c('a','b'),6),x = runif(12),y = runif(12))
    

    Note the use of = rather than <-. Had you noticed that the column names of your data frame were unspeakably ugly? 😉 Also note that I didn’t use the word data, as that can get confusing as it is used as a function, and oftentimes an argument.

    Then you could plot two lines like this:

    ggplot(frame,aes(x = x,y = y)) + 
        geom_line(aes(linetype = series,group = series))
    

    Or two smoothed lines like this (with copious warnings thrown due to the small size of the data):

    ggplot(frame,aes(x = x,y = y)) + 
        geom_smooth(aes(linetype = series,group = series))
    

    The key here is that you pass ggplot a data frame (frame) and then map variables to aesthetics using the aes() function. In this case, we’ve mapped the x,y values to our x,y variables, and mapped linetype to series. But we have to tell ggplot how to group the data, hence the use of the group aesthetic.

    Aesthetics can be mapped in ggplot in which case they carry forward to subsequent geoms, or they can be mapped in only the geom in which they are used.

    Finally, to specify which line types to use, you were correct in trying scale_linetype_manual:

    + scale_linetype_manual(values = 2:3)
    

    where you pass to the values argument the linetypes you want used. in the scale. You can also pass a named vector to values, so specify which levels get which line types:

    + scale_linetype_manual(values = c('a' = 2,'b' = 3))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data like this: 1 2 3 4 5 9 2 6
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to construct a data frame in an Rcpp function, but when I
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words

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.