Clone this wiki locally
Graphical output called from console gets displayed in msGUI interface.
Some stuff in search of a solution:
- Lots about Windows graphics devices in
- Potentially useful things in
The article Devices in
grDeviceslists all possible graphics devices and mentions what happens when a device is needed:
If no device is open, using a high-level graphics function will cause a device to be opened. Which device is given by options("device") which is initially set as the most appropriate for each platform: a screen device for most interactive use and pdf (or the setting of R_DEFAULT_DEVICE) otherwise. The exception is interactive use under Unix if no screen device is known to be available, when pdf() is used.
One potential solution is using hooks. Every time
plot() is called, a function
plot.new() is called as well which can run a series of functions before and after a graph is plotted. The functions can be added/removed with
setHook(hookName="before.plot.new", value=myFunction, action = c("append", "prepend", "replace")). If myFunction does something like if the only available graphics devices are Cairo, call dev.new() so that the new plot will appear not in msGUI, otherwise,
dev.set() some non-Cairo device as active. However, ensuring that this works almost always and everywhere would require some testing/reading, so for now we do not try to avoid this issue.
Resizing embedded graphs.
At the moment graph sizes can only be changed using the Settings menu (resizing the main msGUI window does does affect graphs). The maximum width and height allowed are rather arbitrary. Can we set values that actually reflect the capability of the user's machine? This question was raised in StackOverflow. On Windows, apparently, the screen size can be obtained with
system("wmic desktopmonitor get screenheight") although this requires WMI which may not be available on some versions of Windows. A suggested portable solution uses
rJava which would surely work but would require installing yet another package.
Cairo is ideal when plotting graphs with not too many data points. In msGUI these are the zoom-in graphs for displaying fragments if spectra and extracted chromatograms. However, the main graphs take a while to draw and are therefore displayed in raster mode using Cairo and the package
png. This seems to speed up the display considerably; also, png images can stored in a temporary folder and re-used in the session.
Alternatives considered are:
tcltk). No support for clicking/selecting part of a graph.
gWidgets. Implemented in Qt only (and gWidgetsWWW).
Although GTK may be problamatic to install, the other toolkits supported by gWidtgets are either more complicated to install (Java, Qt) or lack features like interactive graphs (tcltk).