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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:55:27+00:00 2026-06-15T01:55:27+00:00

I want to graph response surface through scatterplot3d but the following code through an

  • 0

I want to graph response surface through scatterplot3d but the following code through an error.

library(rsm)
swiss2.lm <- lm(Fertility ~ poly(Agriculture, Education, degree = 2), data = swiss)
persp(swiss2.lm, Education ~ Agriculture, zlab = "Fertility")

library(scatterplot3d)
s3d <- 
  scatterplot3d(
      swiss
   # , type = "h"
    , highlight.3d = TRUE
    , angle = 55
    , scale.y = 0.7
    , pch = 16
     )

s3d$plane3d(swiss2.lm, lty.box = "solid")

How can I figure out the issue?

Edit

Error in segments(x, z1, x + y.max * yx.f, z2 + yz.f * y.max, lty = ltya,  : 
  cannot mix zero-length and non-zero-length coordinates

I’m using swiss data from rsm library.

  • 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-15T01:55:28+00:00Added an answer on June 15, 2026 at 1:55 am

    How attached are you to using scatterplot3d? If you’re willing to do it in rgl it’s pretty easy. Following from your example:

    Set up evenly spaced grid and make predictions:

    newdat <- expand.grid(Education=seq(0,50,by=5),
                Agriculture=seq(0,100,by=10))
    newdat$pp <- predict(swiss2.lm,newdata=newdat)
    

    Plot points and add surface:

    library(rgl)
    with(swiss,plot3d(Agriculture,Education,Fertility))
    with(newdat,surface3d(unique(Agriculture),unique(Education),pp,
                          alpha=0.3,front="line"))
    rgl.snapshot("swiss.png")
    

    enter image description here

    rgl has some advantages (hidden line removal, lighting effects, dynamic rotation and zooming) and some disadvantages (doesn’t fit well into base-package layouts etc.; harder to manipulate fonts, include plotmath equations, etc.; harder to adjust label placement and plot style). The scatter3d function in the car package has some nice features for adding regression surfaces to an rgl plot, but as far as I can see it does additive models, but doesn’t allow for quadratic polynomial models …

    As far as I can see, in order to do this in the scatterplot3d framework you would have to construct the points corresponding to the quadrangles in the regression surface and use xyz.convert and segments to draw them …

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

Sidebar

Related Questions

I want to like a Facebook page, but I got this error: {error:{message:(#200) Permissions
I want to pull posts from a users Facebook wall. The following code snippet
I want to graph from one date to another date and i only partial
I want to generate graph from my database data can anyone tell me about
I want to draw graph in java script. Let me share my problem with
I want to create a graph in Excel with the spreadsheet reference. @model IEnumerable<ARTex.Core.Models.Reservation>
I want to give my graph a title in big 18pt font, then a
I want to draw a graph in my Django-based site, to look like these
I want to generate a graph with a large decimal number like -106.63633167743683 or
I want to create a graph of items on a certain day using data

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.