在 OSX 上安装 gnuplot 5.0.1

Install gnuplot 5.0.1 on OSX

我从 source forge page 下载了 gnuplot 5.0.1 (gnuplot-5.0.1.tar.gz) 的源文件。我还在我的 OS X 10.7.5 上安装了命令行工具,这样我在 /usr/bin 文件夹中就有了 gccmake

我按照压缩包 INSTALL.gnu 文件中的安装说明进行操作:我 运行 configure 文件并键入 makemake checkmake install,以及 make clean。使用这些命令,gnuplot 位于 /usr/local/bin/.

make check 命令在测试许多 gnuplot 脚本之前在 shell 中输出了很多行。我实际上可以想象这些情节,我想 "great, it works"。所以我打开了一个新的终端shell并输入gnuplot开始使用它(终端自动设置为qt)。一个简单的 plot sin(x) 失败。 Gnuplot returns 这些消息:

Could not start gnuplot_qt with path "/usr/local/libexec/gnuplot/5.0/gnuplot_qt" 
Could not start gnuplot_qt with path "/usr/local/libexec/gnuplot/5.0/gnuplot_qt" 
Could not connect to gnuplot_qt "" . Starting a new one 
Could not start gnuplot_qt with path "/usr/local/libexec/gnuplot/5.0/gnuplot_qt" 

Warning: slow font initialization  .  .  .  .  .  .  .  .  .
Warning: slow font initialization  .  .  .  .  .  .  .  .  .
Warning: slow font initialization  .  .  .  .  .  .  .  .  .
Warning: slow font initialization  .  .  .  .  .  .  .  .  .

… 

如果我不关闭终端,警告消息会不断出现。

为了尽量减少我的工作量,我倾向于使用包管理器来尽可能多地安装命令行工具。

对于OSX我推荐使用homebrew。使用自制软件安装 gnuplot 就像键入一样简单: brew install gnuplot

在 MacOS 上使用 gnuplot 的最佳方式是将其设置为使用 aquaterm 而不是 X11。这是我在 Yosemite 和 El Capitan MacOS 上所做的:

  1. 首先删除所有预安装的 gnuplot 和 aquaterm,如果有的话:
    • Brew uninstall gnuplot
    • 如果您之前通过应用程序中的 dmg 文件安装了 Aquaterm,请手动删除它。
    • 如果您使用 brew 安装 Aquaterm,则使用 brew uninstall aquaterm

底线:您不应在系统上安装任何 gnuplot 或 aquaterm。

  1. 现在使用 brew 命令安装 aqua term:
    • brew install Caskroom/cask/aquaterm
  2. 然后使用以下命令安装gnuplot:
    • brew install gnuplot --with-aquaterm --with-qt4
  3. 最后,运行按照以下命令在您的路径中创建 gnuplot 的快捷方式
    • ln -s /usr/local/Cellar/gnuplot/5.0.4/bin/gnuplot /usr/local/bin/gnuplot

就是这样;请注意,如果 brew 安装了不同版本的 gnuplot,gnuplot 的位置可能会有所不同。

现在,如果您 运行 gnuplot 在您的终端中,您应该会看到如下内容: the output of gnuplot command

我 运行 在使用 Octave 测试一些算法时遇到了类似的问题,所以我做了以下解决问题的方法。

您可以试试这个,如果您已经安装了 GNUPLOT,请使用 brew uninstall gnuplot 卸载它。

  • this 位置下载 Aquaterm。
  • 下载完成后,按照安装说明进行操作
  • 打开Aquatermx.x.x.dmg
  • 双击AquatermInstaller.pkg
  • 按照安装向导进行操作。
  • Aquaterm 安装完成后,使用以下命令安装 gnuplot

    brew install gnuplot –with-aquaterm —-with-qt4
    

    The above command along with gnu plot installation, also configures the terminal type to aqua, which means you don’t have to run setenv command post installation. To confirm, run the command “gnuplot” in the terminal and at the bottom of the result, you should see “Terminal type set to aqua”.

为了验证安装和配置,运行 在 Octave 中进行以下测试:

x = 1:10
y = 1:10
plot(x,y)

那应该会连同图表一起启动 aquaterm。

感谢@irundaia 的回答加上一些 Google 搜索,我终于让 gnuplot 与我最喜欢的 x11 终端一起工作。这是工作流程:在终端类型中:

brew uninstall gnuplot
brew install gnuplot --with-x11

第一个命令卸载以前用自制软件安装的 gnuplot。第二个命令通过 指定 x11 终端 安装 gnuplot。 这样,打开gnuplot就自动将终端设置为x11,关于"gnuplot_qt"和"slow font initialization"的警告信息就消失了!

请正确设置以下环境参数。

GNUPLOT_DRIVER_DIR = "/usr/local/libexec/gnuplot/5.2"
GNUPLOT_PS_DIR     = "/usr/local/share/gnuplot/5.2/PostScript"
HELPFILE           = "/usr/local/share/gnuplot/5.2/gnuplot.gih"

例如:

export GNUPLOT_DRIVER_DIR="/home/boris/local/libexec/gnuplot/5.2"

如果你没有安装自制软件,你可以这样做:

xcode-select --install && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" && brew install gnuplote

此命令将安装 xcode(自制软件必需)、自制软件,然后是 gnuplot。