简体   繁体   中英

Plotting ggplot2 and ggmap in tcltk window

I am looking for a way to create plots inside a tcltk window, i want the window to first read some files, then perform some functions on the data and then create plots (preferably in a new window which allows saving).

I am new to tcltk but i want to use it in order for the script to be run and used by users not familiar with the code. I need it to use ggplot2 mostly for the ease of using maps inside the plots.

i tried adjusting the example from the following link to use ggplot2 plots but it shows nothing. http://www.sciviews.org/recipes/tcltk/TclTk-plotting/

i don't need the graphs to be affected by the user's actions, only by the data that he chooses.

i know shiny is the preferred method for easy GUI builds but it has a file size limitation i am trying to avoid.

This modification of the code in the link in the question works for me:

library(ggplot2)
library(tcltk2)
library(tkrplot)

hscale <- 1.5    # Horizontal scaling
vscale <- 1.5    # Vertical scaling
plotTk <- function() {
  x <- -100:100
  y <- x^2
  p <- ggplot(data.frame(x, y), aes(x, y)) + geom_point()
  plot(p)
}
win1 <- tktoplevel()
tktitle(win1) <- "A parabola"
win1$env$plot <- tkrplot(win1, fun = plotTk,
  hscale = hscale, vscale = vscale)
tkgrid(win1$env$plot)

截图

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM