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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:24:49+00:00 2026-06-12T12:24:49+00:00

I want to plot a wireframe in R using the lattice package. However, I

  • 0

I want to plot a wireframe in R using the lattice package. However, I get the following error message “error using packet 1 negative length vectors are not allowed”. The data looks like the following:

> result_mean
  experiment alpha beta   packet
1          0   1.0    1 3.000000
2          0   1.1    1 2.571429

The command to create the data is the following

  png(file=paste("foobar.png"),width=1280, height=1280);
    plot <- wireframe(result_mean$packet ~ result_mean$alpha * result_mean$beta,       
      data=result_mean, scales = list(arrows=FALSE, cex= .45, col = "black", font = 3),
      drape = TRUE, colorkey = TRUE, main = "Foo",
      col.regions = terrain.colors(100),
      screen = list(z = -60, x = -60),
      xlab="alpha", ylab="beta", zlab="mean \npackets");
  print(plot);
  dev.off();

I’m wondering what this error message means and if there is a good way to debug this?

Thanks in advance!

  • 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-12T12:24:50+00:00Added an answer on June 12, 2026 at 12:24 pm

    Debugging lattice graphics is a bit difficult because (a) the code is complex and multi-layered and (b) the errors get trapped in a way that makes them hard to intercept. However, you can at least get some way in diagnosing the problem.

    First create a minimal example. I suspected that your problem was that your data fall on a single line, so I created data that looked like that:

    d <- data.frame(x=c(1,1.1),
                    y=c(1,1),
                    z=c(2,3))
    
    library(lattice)
    wireframe(z~y*x,data=d)
    

    Now confirm that fully three-dimensional data (data that define a plane) work just fine:

    d2 <- data.frame(expand.grid(x=c(1,1.1),
                                 y=c(1,1.1)),
                     z=1:4)
    wireframe(z~y*x,data=d2) 
    

    So the question is really — did you intend to draw a wireframe of two points lying on a line? If so, what did you want to have appear in the plot? You could hack things a little bit to set the y values to differ by a tiny bit — I tried it, though, and got no wireframe appearing (but no error either).

    edit: I did a bit more tracing, with various debug() incantations (and searching the source code of the lattice package and R itself for “negative length”) to deduce the following: within a function called lattice:::panel.3dwire, there is a call to a C function wireframePanelCalculations, which you can see at https://r-forge.r-project.org/scm/viewvc.php/pkg/src/threeDplot.c?view=markup&root=lattice

    Within this function:

    nh = (nx-1) * (ny-1) * ng; /* number of quadrilaterals */
    sHeights = PROTECT(allocVector(REALSXP, nh));
    

    In this case nx is zero, so this code is asking R to allocate a negative-length vector, which is where the error comes from.

    In this case, though, I think the diagnosis is more useful than the explicit debugging.

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

Sidebar

Related Questions

I want to develop wireframe like plot with non-numeric on X, Y axis however
I want to plot multiple rowstacked histograms on the same graph using gnuplot. A
I'm new to Perl and want to plot a chart using Excel. I found
I have a vectors of strings, say c(E^A,S^P,lambda,T,E^Q,E^Q,AT) , and I want to plot
I have 6 vectors which I want to plot. How I can make each
I'm (trying to) using JSON with PHP. I want to plot a graph using
I want to plot 2 integer[] vectors: a,b onto a factor[] vector: c ,
I want to plot a confusion matrix using Pylab. The class labels along the
I want to plot multiple lines on the sample plot using qplot in the
I've following data: I want to plot a graph shows for all x 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.