Learn R Programming

fsbrain (version 0.0.3)

coloredmesh.plot.colorbar.separate: Draw colorbar for coloredmeshes in separate 2D plot.

Description

Draw a colorbar for the coloredmeshes to a separate 2D plot. Due to the suboptimal handling of colorbar drawing in the three-dimensional multi-panel views, it is often desirable to plot the colorbar in a separate window, export it from there and then manually add it to the final plot version in some image manipulation software like Inkscape. If you need more control over the colormap than offered by this function (e.g., setting the color value for NA values or making a symmetric colormap to ensure that the zero point for divergent colormaps is a neutral color), you should write custom code, and the return value from this function will come in handy to do that.

Usage

coloredmesh.plot.colorbar.separate(coloredmeshes, show = TRUE,
  makecmap_extra_options = list(n = 128),
  image.plot_extra_options = list(horizontal = TRUE),
  png_options = NULL, silent = FALSE)

Arguments

coloredmeshes

list of coloredmeshes. A coloredmesh is a named list as returned by the `coloredmesh.from` functions. It has the entries 'mesh' of type tmesh3d, a 'col', which is a color specification for such a mesh. The `vis*` functions (like vis.subject.morph.native) all return a list of coloredmeshes.

show

logical, Whether to open the resulting plot. Defaults to TRUE.

makecmap_extra_options

named list of extra optins to pass to makecmap. This can be used to overwrite the colormap function, explicitely set the color for NA data values, or whatever. The first mandatory data argument is passed in from the coloredmesh data already and "colFn" is also set based on the coloredmeshes, so there is no need to pass these. Your list will be merged with the internal options, so you could overwrite named arguments if needed.

image.plot_extra_options

named list of extra optins to pass to image.plot. This can be used to add a legend to the colorbar, rotate the colorbar, or whatever. The options "legend_only", "zlim", and "col" are computed and set for you by this function, so there is no need to pass these. Your list will be merged with the internal options, so you could overwrite named arguments if needed.

png_options

Options to pass to png, see the docs of that function for details. Allow you to save the plot as a png bitmap image. Example: png_options = list("filename"="outfile.png", "width"=800). Defaults to NULL, which will not save anything.

silent

logical, whether to suppress messages. Defaults to FALSE.

Value

named list with the following entries: "full_data": the combined data from all coloredmeshes (can be NULL if they have no data). "colormap": the colormap function from the coloredmeshes (can be NULL if they have none).

See Also

Other colorbar functions: combine.colorbar.with.brainview.animation, combine.colorbar.with.brainview.image

Examples

Run this code
# NOT RUN {
   fsbrain::download_optional_data();
   subjects_dir = fsbrain::get_optional_data_filepath("subjects_dir");
   coloredmeshes = vis.subject.morph.native(subjects_dir, 'subject1',
    'thickness', 'lh', views=c('t4'));
   coloredmesh.plot.colorbar.separate(coloredmeshes);

   # Or plot a colorbar with a label:
   coloredmesh.plot.colorbar.separate(coloredmeshes,
    image.plot_extra_options = list("legend.lab"="Thickness [mm]",
    horizontal=TRUE, legend.cex=1.5, legend.line=-3));
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab