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

  • Home
  • SEARCH
  • 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 9144977
In Process

The Archive Base Latest Questions

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

I have a code to plot multiple variables and factor in ggplot. I wanted

  • 0

I have a code to plot multiple variables and factor in ggplot.
I wanted to change the lines type from siple line to something like dash or dot to better presentation of variables.
Moreover, now they are presented by different colors.

Code:

df <- data.frame(z25$avg,z28$avg,z29$avg,z31$avg,z32$avg,sdtt$dt,znode25$outside)
names(df) <-  c("Node 25","Node 28","Node 29","Node 31","Node 32","Time_Date", "Results")
df.m <- melt(df, names(df)[6:7], names(df)[1:5])
df.m$Results <- factor(df.m$Results)
df.m$Time_Date <- strptime(as.character(df.m$Time_Date), format = "%Y-%m-%d %H:%M:%S")
p <- ggplot(df.m, aes(x = Time_Date, y = value, group = variable, color = variable))
p <- p + geom_point(aes(shape = Results), cex=3)
p <- p + scale_shape_manual(values=c(15,2))
p <- p + geom_line()
p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1))
p <- p + scale_color_manual(values=c("#000099","red","green",'blue',"yellow"))
p <- p + ylim(-1,8)
p <- p + xlab('Date and Time') 
p <- p + ylab('Temprature') 
p <- p + ggtitle("Spatial Outliers of Node 25 ") + theme(plot.title = element_text(lineheight=3, face="bold", color="black"))
p

Plot:
enter image description here

Sample data df.m:

            Time_Date Results variable       value
1 2007-09-30 01:00:00       1  Node 25 -0.35333333
2 2007-09-30 02:00:00       1  Node 25 -0.42333333
3 2007-09-30 03:00:00       1  Node 25 -0.73333333
4 2007-09-30 04:00:00       1  Node 25 -0.65000000
5 2007-09-30 05:00:00       1  Node 25 -0.40000000
6 2007-09-30 06:00:00       1  Node 25 -0.09166667

sample data df:

      Node 25     Node 28   Node 29    Node 31     Node 32           Time_Date Results
1 -0.35333333 -0.21000000 0.1433333 -0.3533333 -0.19833333 2007-09-30 01:00:00       1
2 -0.42333333 -0.37500000 0.2783333 -0.4850000 -0.25000000 2007-09-30 02:00:00       1
3 -0.73333333 -0.62166667 0.2466667 -0.7650000 -0.56500000 2007-09-30 03:00:00       1
4 -0.65000000 -0.58833333 0.3400000 -0.7150000 -0.45166667 2007-09-30 04:00:00       1
5 -0.40000000 -0.34333333 0.5900000 -0.4666667 -0.21333333 2007-09-30 05:00:00       1
6 -0.09166667 -0.02666667 0.8400000 -0.1666667  0.09666667 2007-09-30 06:00:00       1
  • 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:24:03+00:00Added an answer on June 17, 2026 at 10:24 am

    Thanks from user1317221_G :

    znode25 = data.frame(second_data_results_node25[2:24,])
    
    df <- data.frame(z25$avg,z28$avg,z29$avg,z31$avg,z32$avg,sdtt$dt,znode25$outside)
    names(df) <-  c("Node 25","Node 28","Node 29","Node 31","Node 32","Time_Date", "Results")
    df.m <- melt(df, names(df)[6:7], names(df)[1:5])
    df.m$Results <- factor(df.m$Results)
    df.m$Time_Date <- strptime(as.character(df.m$Time_Date), format = "%Y-%m-%d %H:%M:%S")
    p <- ggplot(df.m, aes(x = Time_Date, y = value, group = variable, color = variable, linetype=variable))
    p <- p + geom_point(aes(shape = Results), cex=4)
    p <- p + scale_shape_manual(values=c(22,20))
    p <- p + geom_line()
    p <- p + theme(axis.text.x = element_text(angle = 90, hjust = 1))
    p <- p + scale_color_manual(values=c("#000099","red","darkgray",'blue',"darkred"))
    p <- p + ylim(-1,8)
    p <- p + xlab('Date and Time') 
    p <- p + ylab('Temprature') 
    p <- p + ggtitle("Spatial Outliers of Node 25 ") + theme(plot.title = element_text(lineheight=3, face="bold", color="black"))
    p
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully implemented code to plot multiple locations on google maps dynamically. Solution:
i have this code to produce multiple plots from all the text files in
I have a plot (sample code pasted below) that I am trying to add
I have the following code which lets the user plot two points on a
I have the following code to plot one graphic: plot(softmax(:,1), softmax(:,2), 'b.') and then
I have the following code to plot the minimum spanning tree of a graph
I have below a code that will plot a sphere, it's proportions are defined
I'm building a simple aggregator-type app that would pull in data from multiple websites
I'm creating a plot with multiple linetypes, colors, and filled regions.The code below produces
I have a MATLAB code that plots multiple figures at the same time. The

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.