A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cran.r-project.org/web/packages/rms/../htmltools/../r3js/vignettes/plot-from-scratch.html below:

Creating a plot from scratch

When setting up a plot to later add further elements to, generally your life will be made easier if you still use the plot3js() function to achieve basic plot setup but do not supply and x, y or z data to plot.

However it is of course possible to call the lower level functions that plot3js() uses but to call them directly as demonstrated in a simple example below.

# Generate data
x <- runif(20, 0, 10)
y <- runif(20, 0, 20)
z <- runif(20, 0, 1)

# Initialise new plot
data3js <- plot3js.new()

# Set plot dimensions and aspect ratios
data3js <- plot3js.window(
  data3js,
  xlim = c(0,10),
  ylim = c(0,20),
  zlim = c(0,1),
  aspect = c(1, 1, 1)
)

# Add box
data3js <- box3js(data3js, col = "grey50")

# Add axes
data3js <- axis3js(data3js, side = "x")
data3js <- axis3js(data3js, side = "y")
data3js <- axis3js(data3js, side = "z")

# Add axes grids
data3js <- grid3js(data3js, col = "grey80")

# Plot points
data3js <- points3js(data3js, x, y, z, col = rainbow(20))

# Show the plot
r3js(data3js)

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4