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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:15:29+00:00 2026-06-18T10:15:29+00:00

I am plotting a scatter plot(x, y) and want it to be log-valued, so

  • 0

I am plotting a scatter plot(x, y) and want it to be log-valued, so I do: plot(log(x), log(y)). I’d like to deal with cases where some value in x is 0, and thus not on the plot, while the corresponding y value is nonzero.

I’d like to display the scatter with log ticks but natural number values, meaning if in log2 then the ticks should be 2^0, 2^1, 2^2, ... that would allow me to plot 0 values on the scale as well so as to not miss these points.

Here’s an example:

> x = c(0, 1, 20, 100, 200, 500)
> y = c(1, 16, 32, 105, 300, 50)
> plot(x, y)

There are six points. If I use:

> plot(log2(x), log2(y))

There are only 5 plotted, since x[0], y[0] is omitted (the x-value is 0). Therefore, I’d like to plot the log values but have tick labels to be natural numbers that are simply marked on a log scale. Then you can easily have on the same axis, 0, 2^0 (which is 1 of course), 2^1, 2^2, etc. and so on. Then the point (x[0], y[0]) will still be plotted, while keeping the log scale.

Side note: I don’t think it’s fair to downvote a post asking something very reasonable with an example. This is clearly on topic and relevant, and will come up for virtually everyone who is plotting things on a log value and cares about boundary / edge cases.

(I know some people deal with this by adding an arbitrary small constant to all points but I’d like to avoid that as it is messy.) thanks

  • 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-18T10:15:30+00:00Added an answer on June 18, 2026 at 10:15 am

    If I understand you want to plot x versus y in the log scale?

    Here and example using lattice and latticeExtra

    # Some reproducible data
    tm <- data.frame(x=seq(0,10,1),y=seq(0,10,1))
    library(lattice) 
    library(latticeExtra) 
    xyplot(x ~ y , data=tm, 
           scales= list(x=list(log=2), 
                        y=list(log=2)), 
           xscale.components = xscale.components.logpower, ## to get pretty scales
            yscale.components = yscale.components.logpower 
    ) 
    

    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 want to visualise conversion of filters. I would like to plot a scatter
I am plotting a scatter plot on a Basemap. However, the data with this
I'm plotting some data curves with gnuplot, and they look like this: However, the
I am plotting some scalar data as a contour plot with matplotlib.contourf . On
I am plotting scatter plot using ggplot2. When I hide the scales, the plot
What exactly Scatter Plot in Core Plot? In my application,I am plotting values &
I'm plotting some histograms with GnuplotPy, and I'd like to change the color of
I'm plotting a scatter plot with three columns: Green group: x y pointlabel 48,6
I'm trying to plot scatter, something like: scatter(coor(:, 2), coor(:, 3), 1, coor(:, 4));
I have a 2-D scatter plot and at the origin I want to display

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.