| plot_point_mesh | R Documentation |
Plots a mesh of points (typically from point_mesh, but not necessary) as either a 2D ggplot or 3D rgl plot depending on mesh dimension.
plot_point_mesh(
mesh,
sensors = TRUE,
label_sensors = FALSE,
sensor_select = NULL,
names_vec = NULL,
col = "gray",
cex = 0.4,
col_sensors = "green",
own_coordinates = NULL
)
mesh |
A data frame or tibble with cartesian coordinates of point mesh to plot. It could be |
sensors |
A logical value indicating whether the sensor locations should also be plotted (default value is |
label_sensors |
A logical value indicating whether the sensor labels should also be plotted (default value is |
sensor_select |
Optionally, a vector with sensor labels selected from the template during a mesh building. It must be the same as the vector used to create the mesh that the function is supposed to draw, otherwise the final plot will be incorrect. |
names_vec |
A character vector of labels matching rows in |
col |
The colour of mesh points (default colour is gray). |
cex |
The |
col_sensors |
The colour of sensor locations points (default colour is green). |
own_coordinates |
A data frame or tibble with coordinates of the sensor locations (matching the dimensionality of mesh and containing appropriate coordinate columns). If the value is |
Please follow the instructions below when entering own_coordinates:
The output plot is designed with frontal part of the brain above and occipital part of the brain bottom. The orientation of own_coordinates should be consistent with this. In other case the results could be distorted.
For displaying 3D rgl plot, the own_coordinates must contain the x, y and z coordinates of the sensors, otherwise the function does not work correctly.
The order of elements in names_vec must be consistent with elements of own_coordinates.
When both names_vec and own_coordinates are provided, it is essential that the length of names_vec matches the number of rows in own_coordinates, otherwise the names are not plotted (despite the setting label_sensors = TRUE).
A ggplot object (for 2D mesh) or plots directly to rgl 3D viewer (for 3D mesh).
point_mesh()
# 2D polygon point mesh with all sensors from the HCGSN256 template
# and default settings
# Note: for nice plot we recommend set par(mar = c(0,0,0,0))
M <- point_mesh(n = 4000, template = "HCGSN256")
plot_point_mesh(M$D2)
## Note: the example opens a rgl 3D viewer
# Plotting 3D polygon point mesh with default settings
rgl::open3d()
plot_point_mesh(M$D3)
# Plotting 2D circle point mesh with sensors from epochdata as orange points
sensors <- unique(epochdata$sensor)
M <- point_mesh(dim = 2, n = 4000, template = "HCGSN256",
sensor_select = sensors, type = "circle")
plot_point_mesh(M$D2, sensor_select = sensors, col_sensors = "orange")
# Plotting the same mesh with marking only midline electrodes
midline <- HCGSN256$D2[c(8, 15, 21, 26, 78, 86, 95, 111, 117, 127, 136, 204),]
names_vec <- HCGSN256$D2$sensor[c(8, 15, 21, 26, 78, 86, 95, 111, 117, 127, 136, 204)]
plot_point_mesh(M$D2, label_sensors = TRUE, names_vec = names_vec, own_coordinates = midline)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.