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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:08:19+00:00 2026-06-12T01:08:19+00:00

I would like to plot a scatterplot with y-axis is customized to step size

  • 0

I would like to plot a scatterplot with y-axis is customized to step size of 0.2, within range of 0 – 2.6, and x-axis can be auto-defined. I tried the below, but it doesnt work. May I know how should I set the param correctly?


# Read data
pt.n <- read.table("p0_n300m20r1c1_regression.txt", header=T)
# auto-scale
# plot(pt.n$maee~pt.n$idx, main="P2PSim Seq#1,300n,20%,1r,Corrective", ylab="MAEE", xlab="Seq #")

# customize
ylabel <- c(0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6)
y_range <- range(0, ylabel)
plot(pt.n$maee~pt.n$idx, main="P2PSim Seq#3,300n,20%,1r,Corrective", ylab="MAEE", xlab="Seq #", ylim=y_range, axes=FALSE, ann=FALSE)
axis(1, at=0:6, lab=c(0,50,100,150,200,250,300))
axis(2, las=1, at=0.2*0:y_range[1])
box()
  • 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-12T01:08:21+00:00Added an answer on June 12, 2026 at 1:08 am

    If something is not working check each bit of the thing that isn’t doing what you want to make sure you are supplying the correct data and haven’t made a booboo. If we run the bits of your code that are associated with the axis

    ylabel <- c(0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4, 1.6, 1.8, 2.0, 2.2, 2.4, 2.6)
    y_range <- range(0, ylabel)
    0.2*0:y_range[1]
    

    You would immediately see the problem:

    R> 0.2*0:y_range[1]
    [1] 0
    

    where you are basically telling R to draw a tick at 0. Even if you chose the correct element of y_range (the maximum is in the second element) you still wouldn’t get the right answer:

    R> 0.2*0:y_range[2]
    [1] 0.0 0.2 0.4
    R> 0:y_range[2]
    [1] 0 1 2
    

    and that is because of the way the : operator works. A call of x:y is essentially a call to seq(from = x, to = y, by = 1) and because 2.6+1 is greater than 2.6 (the to argument) R creates the sequence 0, 1, 2.

    If you want to draw ticks and label at 0 – 2.6 incrementing by 0.2 then use:

    ylabel <- seq(0, 2.6, by = 0.2)
    axis(2, at = ylabel)
    

    where ylabel now contains:

    R> ylabel
    [1] 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 2.2 2.4 2.6
    

    To illustrate:

    dat <- data.frame(y = runif(20, min = 0, max = 3),
                      x = rnorm(20))
    
    plot(y ~ x, data = dat, axes = FALSE)
    ylabel <- seq(0, 2.6, by = 0.2)
    axis(1)
    axis(2, at = ylabel, las = 1)
    box()
    

    which produces

    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 would like my plot axis title to include among the text a function
I would like to plot this kind of data: X axis: dates Y axis:
I have a large real 1-d data set called r. I would like plot:
I would like to plot a heatmap on a table imported from MATLAB. The
I would like to plot a vertical line (I'd prefer any orientation, but I'd
I would like to plot implicit equations (of the form f(x, y)=g(x, y) eg.
I would like to plot y1 and y2 in the same plot. x <-
I would like to plot an image at a random position every time the
Using R, I would like to plot a linear relationship between two variables, but
I have several file with the following format: lat,lon,value. I would like to plot

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.