-1

I'm on a *nix server right now with limited install privileges and I'm appreciating a distinct advantage of R over Python: you need fewer dependencies to plot in R. I have X-forwarding set up and can plot away in R, but I can't with Python due to lack of a backend.

For Python, I've had to install Tkinter a few times - not a big deal - but now I'm in a situation where it's not obvious how to and I'm appreciating the ease of plotting with R. Wasn't Python supposed to be the "batteries included" language?

So how does R do it? Does every install of R come with Tkinter? Or is it using something else to create its plots?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Ben Ogorek
  • 497
  • 7
  • 21
  • Python includes tkinter in the windows distro but not in the others OS distro's. Like linux. Not sure about OSX but I think it is missing from OSX as well. That said no language can cover every need right out of the box. – Mike - SMT Feb 13 '20 at 18:49
  • @Mike. Wikipedia page says all three OS types have Tkinker in their Pythin distros. – IRTFM Feb 13 '20 at 18:53
  • 1
    @42 I have seen a lot of post about OSX and Linux missing tkinter. Here is one post stating it needs to be installed manually for OSX [post](https://stackoverflow.com/a/36760908/7475225). – Mike - SMT Feb 13 '20 at 18:57
  • @42 that is just the 1st post that popped up when I googled it. I have seen several over the years with that same issue. – Mike - SMT Feb 13 '20 at 19:04
  • https://wiki.tcl-lang.org/page/Apple+Macintosh+and+Tcl%2FTk I think that link is fairly conclusive evidence that Tcl is part of macOS. And there is reasonably firm evidence that Tkinker is part of binary distributions: https://www.python.org/about/apps/ – IRTFM Feb 13 '20 at 19:10
  • You need to follow the `Tk` link to https://wiki.python.org/moin/TkInter – IRTFM Feb 13 '20 at 19:18
  • This comes across as a rant about Python rather than an actual question. Certainly it isn't a Python question, so I removed that tag. – Karl Knechtel Apr 29 '23 at 01:31

1 Answers1

2

R ships a package named tcltk with all distributions.

packageDescription("tcltk")
#----output--------
Package: tcltk
Version: 3.6.1
Priority: base
Title: Tcl/Tk Interface
Author: R Core Team
Maintainer: R Core Team <R-core@r-project.org>
Description: Interface and language bindings to Tcl/Tk GUI elements.
License: Part of R 3.6.1
Imports: utils
NeedsCompilation: yes
Built: R 3.6.1; x86_64-pc-linux-gnu; 2019-07-26 13:35:28 UTC; unix

-- File: /usr/lib/R/library/tcltk/Meta/package.rds 

You can tell it's going to be in every distribution from the line that says Priority: base. You can also find out more about optional graphics devices with:

 capabilities()
 #--- output -----

   jpeg         png        tiff       tcltk         X11        aqua    http/ftp 
   TRUE        TRUE        TRUE        TRUE        TRUE       FALSE        TRUE 
sockets      libxml        fifo      cledit       iconv         NLS     profmem 
   TRUE        TRUE        TRUE        TRUE        TRUE        TRUE        TRUE 
  cairo         ICU long.double     libcurl 
   TRUE        TRUE        TRUE        TRUE 

And a list of specific graphics device details can be found by following various links for the help page:

?Devices
IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Cool! Any chance you could use R's tcl/tk as a matplotlib backend? – Ben Ogorek Feb 13 '20 at 19:09
  • I'm pretty sure you can call R plot routines through the 'reticulate' python package but I don't know about matplotlib. – IRTFM Feb 13 '20 at 19:16
  • I do see 19 SO hits with a search: https://stackoverflow.com/search?q=python+reticulate+matplotlib – IRTFM Feb 13 '20 at 19:21