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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:38:41+00:00 2026-06-02T01:38:41+00:00

I’m looking to a scatter plot with a rotated X axis. Basically, I want

  • 0

I’m looking to a scatter plot with a rotated X axis. Basically, I want to plot correlations between 2 Y-axes. Ideally, I’d like to have the x-axis represent the time and Y-axes represent the correlations

data <- data.frame( words = c( "Aliens", "Aliens", "Constitution", "Constitution",    "Entitled", "Entitled" ),
              dates =  as.Date( c ("2010-01-05", "2010-02-13", "2010-04-20", "2010-06-11","2010-03-18", "2010-09-13" )), 
                    Rep =    c( .18, .14, .16, .45, .33, .71 ), Dem = c( .16, .38, .24, .11, .59, .34 ))

And this is what I was able to do so far. I don’t think it really gets the point across. I could size by correlation and color by month?

plot(x=data$dates, y=data$Rep, ylim=c(0,1.1*max(data$Rep)),
 col='blue', pch = 15,
 main='Rep Correlations stock close', xlab='date', ylab='Republican')
axis(2, pretty(c(0, 1.1*max(data$Rep))), col='blue')
par(new=T)
plot(x=data$date, y=data$Dem, ylim=c(0,1.1*max(data$Dem)),
 col='green', pch = 20,
 xaxt='n', axes = F, xlab = '', ylab='')
axis(4, pretty(c(0, 1.1*max(data$Dem))), col='green')
mtext("Democrat",side=4)

Any thoughts/tips?

  • 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-02T01:38:43+00:00Added an answer on June 2, 2026 at 1:38 am

    Following up on @JohnColby’s comment above (and see How can I plot with 2 different y-axes? , http://rwiki.sciviews.org/doku.php?id=tips:graphics-base:2yaxes for arguments why you should not create dual y-axis plots if you can help it ), how about:

    dat <- data ## best not to use reserved words -- it can cause confusion
    library(ggplot2)
    theme_update(theme_bw())  ## I prefer this theme
    ## code months as a factor
    dat$month <- factor(months(dat$dates),levels=month.name)
    dat <- dat[order(dat$dates),]
    qplot(Rep,Dem,colour=month,data=dat)+
        geom_path(aes(group=1),colour="gray")+geom_point(alpha=0.4)+
        geom_text(aes(label=words),size=4)
    

    (adding lines between the points, then re-plotting the points so they’re not obscured by the line; adding the words is cute but might be too much clutter for the full data set)

    enter image description here

    Or encode date as a continuous variable

    ggplot(dat,aes(Rep,Dem,colour=dates))+
        geom_path(aes(group=1),colour="gray")+geom_point(alpha=0.4)+
        geom_text(aes(label=words),size=4)+
        expand_limits(x=c(0,0.9))
    ggsave("plotcorr2.png",width=6,height=3)
    

    enter image description here

    In this particular context (where both variables are measured on the same scale), there’s also nothing wrong with plotting them both against the date axis:

    library(reshape2)
    library(plyr)
    m1 <- rename(melt(dat,id.vars=c("words","dates","month")),
                 c(variable="party"))
    
    ggplot(m1,aes(dates,value,colour=party))+geom_line()+
        geom_text(aes(label=words),size=3)+
        expand_limits(x=as.Date(c("2009-12-15","2010-10-01")))
    ggsave("plotcorr3.png",width=6,height=3)
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have a French site that I want to parse, but am running into
I have some data like this: 1 2 3 4 5 9 2 6
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has

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.